Skip to content Skip to sidebar Skip to footer

Ffmpeg - Cannot Find Executebinaryresponsehandler - Android/java

I am trying to make a module for react-native that will change a video into a gif. I have little to no experience with android studios/java, but I would love to learn more! I am us

Solution 1:

First of all you should init ffmpeg correctly.

FFmpeg ffmpeg = FFmpeg.getInstance(this.reactContext);

// please add following method after

ffmpeg.loadBinary(newFFmpegLoadBinaryResponseHandler() {
            @OverridepublicvoidonFailure() {
                // probably your device not supported
            }

            @OverridepublicvoidonSuccess() {
                // you should init flag here (isLoaded, isReady etc.)
            }

Only after onSuccess() you can work with commands.

Then please check following answer by LordNeckbeard.

So your code should be something like this:

if (isFFmpegLoaded) {
    // ffmpeg.execute(commands from link from the answer) 
}

Please do not forget to remove all spaces from command's string and "ffmpeg" word. To keep command more readable I will recommend to build command like this:

final String[] command = new String[11]; // example of the first commandin the answer
        command[0] = "-y";
        command[1] = "-ss";
        command[2] = "30";
        command[3] = "-t";
        command[4] = "3";
        command[5] = "-i";
        command[6] = "-t";
        command[7] = "filePath";
        command[8] = "-vf"; 
        command[9] = "fps=10,scale=320:-1:flags=lanczos,palettegen";
        command[10] = "palette.png"; 

Please make sure that you have storage permission to work with file just in case you are working on external storage.

Based on this strategy ffmpeg works well for me. Thanks and good luck!

Solution 2:

First of all, you should use: File - Invalidate Caches/Restart - Invalidate and Restart and try to reimport ExecuteBinaryResponseHan‌dler. If the problem hasn't been resolved you can try the small hack. Inside your project create package com.github.hiteshsondhi88.libffmpeg and class:

publicclassExecuteBinaryResponseHandlerimplementsFFmpegExecuteResponseHandler {

    @Override
    public void onSuccess(String message) {

    }

    @Override
    public void onProgress(String message) {

    }

    @Override
    public void onFailure(String message) {

    }

    @Override
    public void onStart() {

    }

    @Override
    public void onFinish() {

    }
}

It should be as on image:

enter image description here

Then inside your build.gradle file in defaultConfig block add multiDexEnabled true

enter image description here

Then you will be able to use that class

Post a Comment for "Ffmpeg - Cannot Find Executebinaryresponsehandler - Android/java"