[关闭]
@Tyhj 2018-06-18T05:28:49.000000Z 字数 776 阅读 1469

在Android中集成FFmpeg

Android


原文链接:https://www.zybuluo.com/Tyhj/note/1184684

集成方法

Step 1. Add the JitPack repository to your build file

  1. //Add it in your root build.gradle at the end of repositories:
  2. allprojects {
  3. repositories {
  4. ...
  5. maven { url 'https://jitpack.io' }
  6. }
  7. }

Step 2. Add the dependency

  1. //Add the dependency
  2. dependencies {
  3. implementation 'com.github.tyhjh:FFmpeg:-SNAPSHOT'
  4. }

使用方法:

  1. //调用FFmpeg命令,command为FFmpeg命令,返回值为0,则操作成功
  2. String command;
  3. int result = FFmpeg.getsInstance().run(command.split(" "));

图片转GIF示例

  1. //本项目提供一个视频转GIF示例,其他功能可以通过调用FFmpeg命令自己实现
  2. new Thread(new Runnable() {
  3. @Override
  4. public void run() {
  5. String pathFrom = "/mnt/sdcard/av.mp4";
  6. String pathTo = "/mnt/sdcard/av.gif";
  7. Setting setting = new Setting(true,
  8. 1080,
  9. 1920,
  10. 20,
  11. 0,
  12. 20);
  13. Mv2Gif.convert(pathFrom, pathTo, setting);
  14. }
  15. }).start();

相关文章:Android录屏+视频转Gif实现
项目源码:https://github.com/tyhjh/FFmpeg

添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注