您的位置:首页 > 其它

FFmpeg 编译安装使用总结

2014-05-29 09:55 423 查看
最近想把这段时间学的东西整理下,免得自己健忘。

1.FFmpeg 介绍:

ffmpeg是音视频的分离,转换,编码解码及流媒体的完全解决方案,其中最重要的就是libavcodec库。它被mplayer或者xine使用作为解码器。还有,国内比较流行的播放器影音风暴或MyMPC的后端ffdshow也是使用ffmpeg的解码库的.

ffmpeg软件包经编译过后将生成三个可执行文件,ffmpeg,ffserver,ffplay。其中ffmpeg用于对媒体文件进行处理,ffserver是一个http的流媒体服务器,ffplay是一个基于SDL的简单播放器。

ffmpeg中有五个库文libavcodec,libavformat,libavutil,libswscale,libpostproc,其中库libavcodec,libavformat用于对媒体文件进行处理,如格式的转换;libavutil是一个通用的小型函数库,该库中实现了CRC校验码的产生,128位整数数学,最大公约数,整数开方,整数取对数,内存分配,大端小端格式的转换等功能;libswscale,libpostproc

暂时不知道何用。

2.FFmpeg下载:

最新的FFmpeg可以通过svn下载,svn辅助软件有:

SubVersion,从 http://subversion.tigris.org/ 下载,支持linux。

TortoiseSVN,从 http://tortoisesvn.tigris.org/ 下载,是很不错的SVN客户端程序,为windows外壳程序集成到windows资源管理器和文件管理系统的Subversion客户端,用起来很方便。

3.FFmpeg安装:

1).安装apr 和apr-util ,安装在/usr/local 下

2).subversion安装,(笔者用的是1.7.16版本)在apache.org网站能下到

wgethttp://subversion.tigris.org/downloads/subversion-1.7.16.tar.gz

tar -vxf subversion-1.7.16.tar.gz

cd subversion-1.7.16

./configure–with-apr=/usr/local/apr-httpd –with-apr-util=/usr/local/apr-util-httpd/

make

make install

注:在安装过程中如果出现缺少sqlite3
需要下载安装sqlite-amalgamation-3.7.3.tar.gz

tar –xvf sqlite-amalgamation-3.7.3.tar.gz

将解压出来的sqlite3.c
拷贝到subversion-1.7.16
下的sqlite-amalgamation
目录下


3).FFmpeg下载: 可以直接通过svn命令获取最新的ffmpeg,命令如下:

svn checkoutsvn://svn.mplayerhq.hu/ffmpeg/trunk ffmpeg

4).FFmpeg 支持库的安装

* xvid

xvid的获取地址如下:http://www.xvid.org/

wget http://downloads.xvid.org/downloads/xvidcore-1.1.3.tar.gz
配置编译

for x86

#./configure --prefix=/usr/ --enable-shared

#make

#make install

for arm

#CC=arm-linux-gcc ./configure--prefix=/usr/local/arm/arm-linux --build=i686-pc-linux --host=arm-linux--target=arm-linux

#make

#make install

* x264

x264的获取地址如下: svnco svn://svn.videolan.org/x264/trunk x264

配置编译

for x86

#./configure --enable-shared --prefix=/usr/

#make

#make install

for arm

#CC=arm-linux-gcc ./configure --enable-pthread--enable-shared --host=arm-linux --prefix=/usr/local/arm/arm-linux

#make

#make install

* 支持mp3

lame的获取地址如下: http://lame.sourceforge.net/index.php
配置编译

for x86

./configure --enable-shared –prefix=/usr/

* AC3和dts编码的支持

libdts编译参数

./configure --prefix=/usr

make

make install

* mpg4 aac格式支持,

如果ffserver服务器还针对手机用户服务,所以,类似aac,mpg4铃声格式的支持,我们也得做。这里我们安装faad2和faac就行,下载请到http://www.audiocoding.com/modules/mydownloads/http://prdownloads.sourceforge.net/faac

FAAD2的编译

cd faad2

autoreconf -vif

./configure --prefix=/usr --with-mp4v2 --enable-shared

make

make install

faac的编译

cd faac

chmod +x bootstrap

./bootstrap

./configure --prefix=/usr --with-mp4v2 --enable-shared

make

make install

* 支持3gp格式,

这也是现在好多手机支持的格式,所以也得支持编译, 编译的时候加上--enable-amr_nb --enable-amr_wb参数就行,根据编译系统的提示,所以我们得下载一些编译3gp所需得文件。

源码网址:http://www.3gpp.org/ftp/Specs

wget http://www.3gpp.org/ftp/Specs/archive/26_series/26.204/26204-510.zip
解压以后把里面的文件都拷贝到libavcodec/amrwb_float

wget http://www.3gpp.org/ftp/Specs/archive/26_series/26.104/26104-510.zip
解压以后把里面的文件都拷贝到libavcodec/amr_float

好了,基本ffmpeg支持的格式,我们基本都做好前期准备了(如果有安装不成功的可以换一个包重新安装),下面是ffmpeg的编译

网上的很多安装配置方法基本都是:./configure --enable-gpl --enable-shared --enable-amr_nb--enable-amr_wb --enable-mp3lame --enable-amr_if2 --enable-libogg--enable-libvorbis --enable-libxvid --enable-a52 --enable-a52bin--enable-libfaadbin --enable-dts
--enable-pp --enable-libfaad --enable-libfaac--enable-libx264 –enable-pthreads

但是我自己编译试过发现这个配置过不了会出现如下错误,可能因为版本的不同,现在包含的库写法有一些是不一样的

Unknown option”—enable-amr_nb”、 Unknown option ”—enable-mp3lame”、 Unknown option ”—enable-amr_wb”、
Unknown option ”—enable-amr_if2”、 Unknown option ”—enable-libogg”、 Unknown option ”—enable-a52”。。。。。

经查实,新版库变成如下:

--enable-libmp3lame

--enable-libopencore-armnb

--enable-libopencore-armwb

至于其他的unknwon option 依然没有找到解决方法,所以笔者在配置的选项中去掉了对应的选项,最后的配置命令如下:

./configure--prefix=/usr --enable-gpl --enable-shared --enable-libmp3lame--enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libvorbis--enable-libx264 --enable-pthreads --enable-swscale --enable-avfilter--enable-nonfree
--enable-version3 –enable-postproc --enable-x11grab

make

make install

至此FFmpeg 编译完成了。进入ffmpeg目录输入 ffmpeg 命令查看是否安装成功。

如果出现ffmpeg: relocation error: /usr/lib/libavfilter.so.3: symbolsws_isSupportedEndiannessConversion, version LIBSWSCALE_2 not defined in filelibswscale.so.2 with link time reference
解决方法:在FFmpeg目录下 exportLD_LIBRARY_PATH=/usr/lib/

OK,FFmpeg可以正常使用了
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: