FFmpeg - cannot find ExecuteBinaryResponseHandler - Android / Java

I am trying to create a module for action-native that will change the video in gif. I have little experience with android studios / java, but I would like to know more! I use this library to convert videos to gifs. Here is my code:

package com.reactlibrary;

import android.widget.Toast;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
import com.github.hiteshsondhi88.libffmpeg.FFmpeg;

public class RNGifMakerModule extends ReactContextBaseJavaModule {

  private final ReactApplicationContext reactContext;

  public RNGifMakerModule(ReactApplicationContext reactContext) {
    super(reactContext);
    this.reactContext = reactContext;
  }

  @Override
  public String getName() {
    return "RNGifMakerModule";
  }

  @ReactMethod
  public void alert(String message) {
      Toast.makeText(getReactApplicationContext(), "Error", Toast.LENGTH_LONG).show();
      String[] cmd = {"-i"
              , message
              , "Image.gif"};
      conversion(cmd);
  }

  public void conversion(String[] cmd) {

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

    try {


      // to execute "ffmpeg -version" command you just need to pass "-version"
      ffmpeg.execute(cmd, new ExecuteBinaryResponseHandler() {

        @Override
        public void onStart() {
        }

        @Override
        public void onProgress(String message) {
        }

        @Override
        public void onFailure(String message) {
        }

        @Override
        public void onSuccess(String message) {
        }

        @Override
        public void onFinish() {
        }
      });
    } catch (FFmpegCommandAlreadyRunningException e) {
      // Handle if FFmpeg is already running
      e.printStackTrace();
    }
  }
}

And I get this error:

Error:(43, 31) error: cannot find symbol class ExecuteBinaryResponseHandler

This seems strange, because the documentation for ffmpeg-android-java says that it uses almost exactly the same code.

Bounty

The prize will be awarded to you if you can find a way to convert .mp4 video to gif. You do not have to use it FFmpeg, but your solution should work with java / android studios.

+6
2

, ffmpeg.

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

// please add following method after

ffmpeg.loadBinary(new FFmpegLoadBinaryResponseHandler() {
            @Override
            public void onFailure() {
                // probably your device not supported
            }

            @Override
            public void onSuccess() {
                // you should init flag here (isLoaded, isReady etc.)
            }

onSuccess() .

, , LordNeckbeard.

, :

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

, "ffmpeg". , :

final String[] command = new String[11]; // example of the first command in 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"; 

, , , .

, ffmpeg . !

Update:

:

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

, ffmpeg

+3

, : File - Invalidate Caches/Restart - Invalidate Restart reimport ExecuteBinaryResponseHan‌dler. , . com.github.hiteshsondhi88.libffmpeg :

public class ExecuteBinaryResponseHandler implements FFmpegExecuteResponseHandler {

    @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() {

    }
}

:

enter image description here

build.gradle defaultConfig multiDexEnabled true

enter image description here

+1

All Articles