bravobit / FFmpeg-Android

FFMpeg/FFprobe compiled for Android
https://bravobit.nl/
MIT License
741 stars 176 forks source link

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

Open BabuinGH opened 6 years ago

BabuinGH commented 6 years ago

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?

Brianvdb commented 6 years ago

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?

BabuinGH commented 6 years ago

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 commented 6 years ago

@Brianvdb do you have any suggestions?

Brianvdb commented 6 years ago

Your command works fine for me on x86 emulator.

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

BabuinGH commented 6 years ago

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

BabuinGH commented 6 years ago

@Brianvdb any suggestions?