FFmpeg Android Java

http://hiteshsondhi88.github.io/ffmpeg-android-java/

 

FFmpeg Android Java

  • FFmpeg for Android compiled with x264, libass, fontconfig, freetype and fribidi
  • Supports Android L

Supported Architecture

  • armv7
  • armv7-neon
  • x86

Adding Library to Project

  • Download and copy AAR File to app/libs and add to your app/build.gradle file
    repositories {
        flatDir {
            dirs 'libs'
        }
    }
    
    dependencies {
        compile(name:'FFmpegAndroid', ext:'aar')
    }
    
  • Or Grab via gradle
    compile 'com.github.hiteshsondhi88.libffmpeg:FFmpegAndroid:0.2.5'
  • Or Maven
    <dependency>
      <groupId>com.github.hiteshsondhi88.libffmpeg</groupId>
      <artifactId>FFmpegAndroid</artifactId>
      <version>0.2.5</version>
    </dependency>

Usage

Load Binary

This method copies the ffmpeg binary to device according to device's architecture. You just need to put this once in your code, whenever you are starting the application or using FFmpeg for the first time. This command does the following:

  • Loads/Copies binary to device according to architecture
  • Updates binary if it is using old FFmpeg version
  • Provides callbacks through FFmpegLoadBinaryResponseHandler interface
FFmpeg ffmpeg = FFmpeg.getInstance(context);
try {
  ffmpeg.loadBinary(new LoadBinaryResponseHandler() {

    @Override
    public void onStart() {}

    @Override
    public void onFailure() {}

    @Override
    public void onSuccess() {}

    @Override
    public void onFinish() {}
  });
} catch (FFmpegNotSupportedException e) {
  // Handle if FFmpeg is not supported by device
}

Execute Binary

This method executes ffmpeg command and provides callback through FFmpegExecuteResponseHandler interface. You also need to pass command as argument to this method.

  • To execute "ffmpeg -version" command you just need to pass "-version" as cmd parameter.
FFmpeg ffmpeg = FFmpeg.getInstance(context);
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
}

Available Methods

  • loadBinary(FFmpegLoadBinaryResponseHandler ffmpegLoadBinaryResponseHandler) throws FFmpegNotSupportedException
  • execute(Map<String, String> environvenmentVars, String cmd, FFmpegExecuteResponseHandler ffmpegExecuteResponseHandler) throws FFmpegCommandAlreadyRunningException
  • execute(String cmd, FFmpegExecuteResponseHandler ffmpegExecuteResponseHandler) throws FFmpegCommandAlreadyRunningException
  • getDeviceFFmpegVersion() throws FFmpegCommandAlreadyRunningException
  • getLibraryFFmpegVersion()
  • isFFmpegCommandRunning()
  • killRunningProcesses()
  • setTimeout(long timeout)

Sample Application

Sample ffmpeg library gif

JavaDoc

License

  • Check file LICENSE.GPLv3 and Make sure to follow the licensing terms and conditions of the project and the software used to build the project.

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值