切记删除原有ffmpeg
1、编译yasm。
./configure --prefix=/usr/local/yasm
make
make install
2、解压x264,进入目录,输入:
./configure --prefix=/usr/local/x264 --enable-shared --enable-static --enable-yasm
make
make install
3、解压ffmpeg,进入目录,输入:
./configure --prefix=/usr/local/ffmpeg --enable-shared --enable-yasm --enable-libx264 --enable-gpl --enable-pthreads --extra-cflags=-I/usr/local/x264/include --extra-ldflags=-L/usr/local/x264/lib
make
make install
编译完成后,修改环境编译,我在/etc/profile文件下增加如下字段:
FFMPEG=/usr/local/ffmpeg
X264=/usr/local/x264
YASM=/usr/local/yasm
export FFMPEG X264 YASM
export PATH=$PATH:$FFMPEG/bin:$X264/bin:$YASM/bin
export LD_LIBRARY_PATH=$YASM/lib:$X264/lib:$FFMPEG/lib:$LD_LIBRARY_PATH
测试
进入/usr/local/ffmpeg/bin目录;
./ffmpeg -v
如果无异常则安装成功;
异常
错误信息:
ffmpeg: error while loading shared libraries: libavdevice.so.56: cannot open shared object file: No such file or directory
此情况是因为ffmpeg未找到相关依赖包,可以通过以下方法解决
先 find / -name libavdevice.so.56 得到该文件的目录地址,我找到的是在ffmpeg安装目录的lib目录下;
然后 vim /etc/ld.so.conf 将上述目录添加到最后一行并保存退出;
再 ldconfig 使配置生效
附 ld.son.conf
/usr/local/ffmpeg/lib
/usr/local/lib
辅助
http://blog.csdn.net/defonds/article/details/9698959