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

下载源码


编译

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等类似的库找不到

  1. –extra-cflags=-I 和 –extra-ldflags 手动指定头文件和库路径
  2. 将使用到的库路径添加至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流
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页