android ffmpeg及相关开源库使用

http://blog.csdn.net/kevenshao/article/details/26225473

FFMPEG是一个领先的多媒体框架,是一个功能强大的提供视音频解决方案的开源库,其中包括了众多的decode, encode, transcode, mux, demux, stream, filter等实现。许多视频音频播放器都使用了这个框架,官方网站:http://ffmpeg.org/

【Android中作用】

1. 首先要编译ffmpeg源码为.so动态库,然后在android中用JNI的方式调用ffmepg接口。

     这有一篇文章介绍如何编译: How to Build FFmpeg for Android

     按照步骤可以成功编译,如果有遇到问题,请评论留言。

2. 使用Java的JNI方式调用.so库

     一个好的设计方案是:自己按照需求设计一个动态库,如libinit.so,由这个so暴露接口供java调用,然后在libinit.so中去封装调用ffmpeg的.so库。


在实际使用中,发现ffmpeg还是比较复杂的,接口文档不多,要想使用接口得去熟悉下源代码,比较花费时间。

所以以下介绍下目前开源的使用ffmpeg 实现方案。

【JavaCV】

官方网站:https://code.google.com/p/javacv/

                    https://github.com/bytedeco

这个开源库功能非常强大,包含OpenCV, FFmpeg, libdc1394, PGR FlyCapture, OpenKinect, videoInput, and ARToolKitPlus,甚至人脸识别。

所以如果仅仅使用ffmpeg的话,里面有两个类可以使用FFmpegFrameGrabber.java和FFmpegFrameRecorder.java,我只用这两个类实现了从视频中抽离出音频的方案,其它功能还没有过多研究。

andoird中使用javacv的方案:

Eclipse (Android 2.2 or newer):

Follow the instructions on this page: http://developer.android.com/training/basics/firstapp/
1. Go to File > New > Folder, select your project as parent folder, type "libs/armeabi" as Folder name, and click Finish.
2. Copy javacpp.jar and javacv.jar into the newly created "libs" folder.
3. Extract all the *.so files from javacv-android-arm.jar, opencv-2.4.8-android-arm.jar, and ffmpeg-2.1.1-android-arm.jar directly into the newly created "libs/armeabi" folder, without creating any of the subdirectories found in the JAR files.
4. Navigate to Project > Properties > Java Build Path > Libraries and click "Add JARs...".
5. Select both javacpp.jar and javacv.jar from the newly created "libs" folder.
Or point your build file to the Maven repository http://maven2.javacv.googlecode.com/git/, and make sure that the library files of OpenCV and FFmpeg (*.so, *.dylib, or *.dll) can be found either in their default installation directories or in the system library PATH, which under Windows includes the current working directory. (For answers to problems frequently encountered with OpenCV on the Windows platform, please refer to Common issues with OpenCV under Windows 7.)

【Vitamio】

官方网站:https://www.vitamio.org/Download/

 源代码及Sample: https://github.com/yixia/VitamioBundle

Vitamio 能够流畅播放720P甚至1080P高清MKV,FLV,MP4,MOV,TS,RMVB等常见格式的视频,还可以在 Android 与 iOS 上跨平台支持 MMS, RTSP, RTMP, HLS(m3u8) 等常见的多种视频流媒体协议,包括点播与直播。

这个开源框架主要是封装了ffmpeg,同时做了许多扩展。

简单介绍架构:

1. 封装libvinit.so,通过过它去调用libffmepg.so及其它动态库。

2. vitamio\res\raw\libarm.so,大家会看到这个so很大,其实它是个7zip压缩文件,在ubuntu下解压($ 7z x file)会发现,里面包含了众多的so文件。

具体使用请看sample及文档。


以上是目前发现的比较好的视音频多媒体解决方案的开源方案,如果还有其它比较好的,请评论推荐,大家共同完善。


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值