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 Sep 5, 2018 · 26 revisions
  1. Add MobileFFmpeg dependency from jcenter()

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

    import com.arthenica.mobileffmpeg.FFmpeg;
    
    int rc = FFmpeg.execute("-i file1.mp4 -c:v mpeg4 file2.mp4");
    
    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.", rc));
    }
    
  3. Stop an ongoing operation.

    FFmpeg.cancel();
    
  4. Enable log callback.

    Config.enableLogCallback(new LogCallback() {
        public void apply(LogMessage message) {
            Log.d(Config.TAG, message.getText());
        }
    });
    
  5. 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()));
        }
    });
    
  6. Set log level.

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

    Config.setFontDirectory(this, "fonts", Collections.EMPTY_MAP);
    
Clone this wiki locally