您的位置:首页 > 运维架构 > Linux

在CentOS-4.4 x86_64安装FFmpeg (非原创)

2011-01-05 11:51 531 查看
本文提到的安装方式基本都是采用源代码编译的方式,非RPM包安装,请读者注意。
FFmpeg软件只是个解码编码软件,如果支持多种格式必须先安装好对应的库,下面就说下我装的库:
1. 安装faad2

# wget http://downloads.sourceforge.net/faac/faad2-2.6.1.tar.gz # tar xvfz faad2-2.6.1.tar.gz
# cd faad2
# ./bootstrap
# ./configure
# make
# make install
2. 安装liba52

# wget http://liba52.sourceforge.net/files/a52dec-0.7.4.tar.gz # tar xvfz a52dec-0.7.4.tar.gz
# cd a52dec-0.7.4
# ./configure
# make
# make install
3. 安装libdirac

# wget http://downloads.sourceforge.net/dirac/dirac-0.10.0.tar.gz # tar xvfz dirac-0.10.0.tar.gz
# cd dirac-0.10.0
# ./configure
# make
# make install
4. 安装faac2

# wget http://downloads.sourceforge.net/faac/faac-1.26.tar.gz # tar xvfz faac-1.26.tar.gz
# cd faac
# ./bootstrap
# ./configure
# make
# make install
5. 安装libamrnb

# wget http://ftp.penguin.cz/pub/users/utx/amr/amrnb-7.0.0.2.tar.bz2 # tar xvfj amrnb-7.0.0.2.tar.bz2
# cd amrnb-7.0.0.2
# ./configure
# make
# make install
6. 安装libamrwb

# wget http://ftp.penguin.cz/pub/users/utx/amr/amrwb-7.0.0.3.tar.bz2 # tar xvfj amrwb-7.0.0.3.tar.bz2
# cd amrwb-7.0.0.3
# ./configure
# make
# make install
7. 安装libmp3lame

# wget http://downloads.sourceforge.net/lame/lame-3.97.tar.gz # tar xzf lame-3.97.tar.gz
# cd lame-3.97
# ./configure
# make
# make install
8. 安装libx264
此软件包需要用git来获取,所以要先安装git:

# wget http://kernel.org/pub/software/scm/git/git-1.6.2.tar.gz (地址要确认)
# tar zxvf git-1.6.2.tar.gz
# cd git-1.6.2
# ./configure
# make
# make install
然后安装libx264

# /usr/local/bin/git clone git://git.videolan.org/x264.git x264
# cd x264
# ./configure --enable-pthread --enable-shared --disable-asm
# make
# make install
8. 安装libnut,该软件需要用svn获取源代码,svn可以直接用yum install svn来装。先下载:

# svn co svn://svn.mplayerhq.hu/nut/src/trunk libnut

下载后代码保存在新建立的libnut目录下,对于64位Linux需要修改配置文件:

# cd libnut
# vi config.mak
在最后一个CFLAGS下一行增加:

CFLAGS += -fPIC
然后编译安装:

# make
# make install
9. 安装libogg

# wget http://downloads.xiph.org/releases/ogg/libogg-1.1.3.tar.gz # tar xvf libogg-1.1.3.tar.gz
# cd libogg-1.1.3
# ./configure
# make
# make install
10. 安装libtheora (svn获取)

# svn co http://svn.xiph.org/trunk/theora theora
# cd theora
# ./autogen.sh
# ./configure
# make
# make install
11. 安装libvorbis

# wget http://downloads.xiph.org/releases/vorbis/libvorbis-1.2.0.tar.gz # tar xvfz libvorbis-1.2.0.tar.gz
# cd libvorbis-1.2.0
# ./configure
# make
# make install
12. 安装libxvid

# wget http://downloads.xvid.org/downloads/xvidcore-1.2.1.tar.gz # tar xvf xvidcore-1.2.1.tar.gz
# cd xvidcore-1.2.1/build/generic
# ./bootstrap.sh
# ./configure --disable-assembly
# make
# make install

上面的媒体支持库安装完后,可以设置下环境准备编译FFmpeg了!
13. 修改环境变量

# vi /etc/ld.so.conf
在文件末增加一行:

/usr/local/lib
然后生效之:

# ldconfig
14. 安装FFmpeg
可以通过svn获取,不过文件比较大,所以特别慢:

# svn checkout svn://svn.mplayerhq.hu/ffmpeg/trunk ffmpeg
# cd ffmpeg
也可以自己下载:

# http://www.ffmpeg.org/releases/ffmpeg-0.5.tar.bz2 # bzip2 -d ffmpeg-0.5.tar.bz2
# tar -xf ffmpeg-0.5.tar
# cd ffmpeg-0.5
编译(64位系统需要设置PKG_CONFIG_PATH参数):

# export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig CFLAGS="-fPIC -m64"
# ./configure --enable-shared /
--enable-gpl /
--enable-nonfree /
--enable-postproc /
--enable-avfilter /
--enable-avfilter-lavf /
--enable-pthreads /
--enable-libamr-nb /
--enable-libamr-wb /
--enable-libdirac /
--enable-libfaac /
--enable-libfaad /
--enable-libfaadbin /
--enable-libmp3lame /
--enable-libnut /
--enable-libtheora /
--enable-libvorbis /
--enable-libx264 /
--enable-libxvid /
--enable-decoder=libx264 /
--enable-encoder=libx264
# make
# make install

14. 可能出现的错误:

/usr/include/linux/videodev.h:56: error: syntax error before "ulong"
/usr/include/linux/videodev.h:72: error: syntax error before '}' token
libavdevice/v4l.c: In function `grab_read_header':
libavdevice/v4l.c:75: error: storage size of 'tuner' isn't known
libavdevice/v4l.c:133: error: invalid application of `sizeof' to incomplete type `video_tuner'
libavdevice/v4l.c:140: error: invalid application of `sizeof' to incomplete type `video_tuner'
libavdevice/v4l.c:75: warning: unused variable `tuner'
这可能是源代码videodev.h不是针对次版本Linux写的,标准C没有ulong类型,所以要改成unsigned long

15. 运行ffmpeg -formats,可能出的错误:

ffmpeg: error while loading shared libraries: libavfilter.so.0: cannot open shared object file: No such file or directory
这事没有设置环境路径造成了,增加一个ffmpeg.conf配置文件:

# cd /etc/ld.so.conf.d
# vi ffmpeg.conf
在文件内写上:

/usr/local/lib
然后确认生效:

# ldconfig
16. 其他:
本文中没有提到libgsm的安装,请参考下面的资料。
原文地址 http://www.blogjava.net/javaren/articles/install_ffmpeg_on_linux_64bit.html
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: