Skip to content
This repository has been archived by the owner on Jan 6, 2025. It is now read-only.

Android

Taner Sener edited this page Dec 31, 2018 · 26 revisions
  1. Add MobileFFmpeg dependency from jcenter()

    dependencies {`
        implementation 'com.arthenica:mobile-ffmpeg-full:4.2'
    }
    
  2. Execute commands.

    import com.arthenica.mobileffmpeg.FFmpeg;
    
    FFmpeg.execute("-i file1.mp4 -c:v mpeg4 file2.mp4");
    
  3. Check execution output.

    int rc = FFmpeg.getLastReturnCode();
    String output = FFmpeg.getLastCommandOutput();
    
    if (rc == RETURN_CODE_SUCCESS) {
        Log.i(Config.TAG, "Command execution completed successfully.");
    } else if (rc == RETURN_CODE_CANCEL) {
        Log.i(Config.TAG, "Command execution cancelled by user.");
    } else {
        Log.i(Config.TAG, String.format("Command execution failed with rc=%d and output=%s.", rc, output));
    }
    
  4. Stop an ongoing operation.

    FFmpeg.cancel();
    
  5. Get media information for a file.

    MediaInformation info = FFmpeg.getMediaInformation('<file path or uri>');
    
  6. List enabled external libraries.

    List<String> externalLibraries = Config.getExternalLibraries();
    
  7. Enable log callback.

    Config.enableLogCallback(new LogCallback() {
        public void apply(LogMessage message) {
            Log.d(Config.TAG, message.getText());
        }
    });
    
  8. Enable statistics callback.

    Config.enableStatisticsCallback(new StatisticsCallback() {
        public void apply(Statistics newStatistics) {
            Log.d(Config.TAG, String.format("frame: %d, time: %d", newStatistics.getVideoFrameNumber(), newStatistics.getTime()));
        }
    });
    
  9. Set log level.

    Config.setLogLevel(Level.AV_LOG_FATAL);
    
  10. Register custom fonts directory.

    Config.setFontDirectory(this, "<folder with fonts>", Collections.EMPTY_MAP);
    
Clone this wiki locally