简体   繁体   中英

Android FFMpeg No such file or directory error

I am using ffmpeg for android (using the gradle plugin 'com.writingminds:FFmpegAndroid:0.3.2') and I am trying to crop a video to a 16:9 (w:h) ratio. The original video is 1080:1920 (w:h). When I execute the command I get an IOException No such file or directory.

The command I am using:

-i /storage/emulated/0/Movies/MyApp/result_joined.mp4 -vf crop=1080:607   -preset ultrafast /storage/emulated/0/Movies/MyApp/result_cropped.mp4

The exception:

java.io.IOException: Error running exec(). Command: 
[/data/user/0/my.package.name/files/ffmpeg, -i, /storage/emulated/0/Movies/MyApp/result_joined.mp4, -vf, crop=1080:607, -preset, ultrafast, /storage/emulated/0/Movies/MyApp/result_cropped.mp4] Working Directory: null Environment: null
Caused by: java.io.IOException: No such file or directory

After searching several stack overflow questions with no help. I also tried to save files to internal storage instead of external storage. Same result

Any help?

You need to call loadBinary method after creating instance of FFmpeg .

try {
    ffmpeg.loadBinary(new LoadBinaryResponseHandler() {
        @Override
        public void onFailure() {
          Logger.i(TAG, "ffmpeg not supported");
        }
    });
} catch (FFmpegNotSupportedException e) {
    e.printStackTrace();
}

I am getting same Exception. I forgot to load FFmpeg Library. first we have to load this library. Run this Function before Run The Command.

void LoadFFmpegLibrary()
{
    if(ffmpeg==null)
    {
        ffmpeg = FFmpeg.getInstance(context);
        try {
            ffmpeg.loadBinary(new LoadBinaryResponseHandler() {

                @Override
                public void onStart() {}

                @Override
                public void onFailure() {
                    Toast.makeText(context, "Failed", Toast.LENGTH_SHORT).show();
                }

                @Override
                public void onSuccess() {
                    Toast.makeText(context, "Success", Toast.LENGTH_SHORT).show();
                }

                @Override
                public void onFinish() {}
            });
        } catch (FFmpegNotSupportedException e) {
            e.printStackTrace();
        }
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM