下载源码
- 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
- 1
- 2
- 3
2. yasm
cd yasm
./configure --prefix=/usr/local/yasm
make
make install
- 1
- 2
- 3
- 4
3. libx264
cd x264
./configure --prefix=/usr/local/x264 --enable-shared --enable-static --enable-yasm
make
make install
- 1
- 2
- 3
- 4
4. libfaac
apt-get install libfacc-dev
- 1
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
- 2
- 3
- 4
可能出现的问题
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
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
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
- 1
- 2
- 3
- 4
- 5
测试
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流