android ffmpeg 优点_在Android中集成FFmpeg

介绍

FFmpeg是一个优秀的开源的视频、音频处理程序;

Android是没法直接集成的,需要自己下载源码去编译;在网上找了一下,没找到可以直接用而且没bug的库,就自己折腾了一下

FFmpeg具体编译过程:https://www.jianshu.com/p/81cb36b610f4

集成方法

Step 1. Add the JitPack repository to your build file

//Add it in your root build.gradle at the end of repositories:

allprojects {

repositories {

...

maven { url 'https://jitpack.io' }

}

}

Step 2. Add the dependency

//Add the dependency

dependencies {

implementation 'com.github.tyhjh:FFmpeg:-SNAPSHOT'

}

使用方法:

//调用FFmpeg命令,command为FFmpeg命令,返回值为0,则操作成功

String command;

int result = FFmpeg.getsInstance().run(command.split(" "));

图片转GIF示例

//本项目提供一个视频转GIF示例,其他功能可以通过调用FFmpeg命令自己实现

new Thread(new Runnable() {

@Override

public void run() {

String pathFrom = "/mnt/sdcard/av.mp4";

String pathTo = "/mnt/sdcard/av.gif";

Setting setting = new Setting(true,

1080,

1920,

20,

0,

20);

Mv2Gif.convert(pathFrom, pathTo, setting);

}

}).start();

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值