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

linux下编译支持librtmp、libx264、libfaac的ffmpeg

2015-07-29 17:04 639 查看

下载源码

librtmp http://rtmpdump.mplayerhq.hu/ 我采用的是rtmpdump-2.4

libx264 http://download.videolan.org/x264/snapshots/ 我采用的是最新版

libfaac 由于是ubuntu,我当时直接apt-get install libfaac-dev了

yasm http://yasm.tortall.net/Download.html 版本为yasm-1.3.0

ffmpeg http://www.ffmpeg.org/download.html 版本为ffmpge-2.6.3

编译

1. librtmp

cd rtmpdump
make
make install


2. yasm

cd yasm
./configure --prefix=/usr/local/yasm
make
make install


3. libx264

cd x264
./configure --prefix=/usr/local/x264 --enable-shared --enable-static --enable-yasm
make
make install


4. libfaac

apt-get install libfacc-dev


5. ffmpeg

cd ffmpeg
./configure --prefix=/usr/local/ffmpeg --enable-shared --enable-libx264 --enable-gpl --enable-pthreads --extra-cflags=-I/usr/local/x264/include --extra-ldflags=-L/usr/local/x264/lib
make
make install


可能出现的问题

1. libx264 not found等类似的库找不到

–extra-cflags=-I 和 –extra-ldflags 手动指定头文件和库路径

将使用到的库路径添加至PATH中

vim /etc/profile  //文件末尾加入下面内容

export PATH=/usr/local/bin:$PATH
export PATH=/usr/local/yasm/bin:$PATH
export PATH=/usr/local/yasm/lib:$PATH
export PATH=/usr/local/x264/bin:$PATH
export PATH=/usr/local/x264/include:$PATH
export PATH=/usr/local/x264/lib:$PATH
export PATH=/usr/local/sbin:$PATH
export PATH=/usr/local/bin:$PATH
export PATH=/usr/sbin:$PATH
export PATH=/sbin:$PATH
export PATH=/usr/local/lib:$PATH

//保存退出
source /etc/profile
ldconfig


2. error while loading shared libraries: libx264.so: cannot open shared object file: No such file

vim /etc/ld.so.conf
...
/usr/local/lib
/usr/local/x264/lib //添加x264库路径,添加完保存退出
ldconfig


测试

ffmpeg -v //查看ffmpeg版本
ffmepg    //测试ffmpeg运行是否缺少库引用
ffmpeg -i 'rtmp://192.168.1.12/live/livestream live=1' -vcodec copy -acodec copy -f flv -y rtmp://192.168.1.12/live/livestream1 //测试ffmpeg是否可以使用librtmp转rtmp流
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: