FFmpeg-Android icon indicating copy to clipboard operation
FFmpeg-Android copied to clipboard

Could not crop the video with ratio height = width of device

Open BabuinGH opened this issue 7 years ago • 6 comments

Hi , I am trying to use this library to fix the x86 issues on Android 7. However, I have the below issue.

When tried to crop the video with this setting, it throws an error String[] cmds = new String[]{"-i", file.getAbsolutePath(), "-filter:v", "crop=out_h=in_w", croppedUrl};

Error: cropVideo:onProgress(): Failed to set value 'crop=out_h=in_w' for option 'filter:v': Option not found.

Please could you help to get this work?

BabuinGH avatar Mar 27 '18 21:03 BabuinGH

That command seems to work fine for me. On what device are you testing this? Could you provide me your full code so I can reproduce this?

Brianvdb avatar Mar 28 '18 15:03 Brianvdb

Thanks for the quick response @Brianvdb !! I am testing it on Emulator with Samsung S7 x86 settings. Here is the code

import nl.bravobit.ffmpeg.ExecuteBinaryResponseHandler;
import nl.bravobit.ffmpeg.FFmpeg;

public class VideoCropUtils {
    private static final String TAG = "VideoCropUtils";

    public static String cropVideo(Context context, final File file, final BaseCaptureInterface mBaseCaptureListener) {
        FFmpeg ffmpeg = FFmpeg.getInstance(context.getApplicationContext());
        String croppedUrl = file.getParent() + "/Cropped_" + file.getName();
        String[] cmds = {"-i", file.getAbsolutePath(), "-vf", "crop=out_h=in_w", "-threads", "5", "-preset", "ultrafast", "-strict", "-2", croppedUrl};

        if (ffmpeg.isSupported()) {
            ffmpeg.execute(cmds, new ExecuteBinaryResponseHandler() {
                @Override
                public void onProgress(String message) {
                    Log.d(TAG, "cropVideo:onProgress(): " + message);
                }

                @Override
                public void onSuccess(String message) {
                    file.delete();
                    Log.d(TAG, "cropVideo:onSuccess(): " + message);
                    mBaseCaptureListener.videoCropStatus(true);
                }

                @Override
                public void onFailure(String message) {
                    super.onFailure(message);
                    Log.d(TAG, "cropVideo:onFailure(): " + message);
                }


                @Override
                public void onFinish() {
                    super.onFinish();

                }
            });
        } else {
            Log.d(TAG, "FFMpeg not supported");
        }

        return croppedUrl;
    }

}

BabuinGH avatar Mar 28 '18 18:03 BabuinGH

@Brianvdb do you have any suggestions?

BabuinGH avatar Mar 29 '18 22:03 BabuinGH

Your command works fine for me on x86 emulator.

Which exact ROM are you using and which Android API version?

Brianvdb avatar Mar 30 '18 09:03 Brianvdb

@Brianvdb , Here are the details of emulator I'm trying on. screen shot 2018-03-30 at 11 58 19 am

BabuinGH avatar Mar 30 '18 19:03 BabuinGH

@Brianvdb any suggestions?

BabuinGH avatar Apr 02 '18 02:04 BabuinGH