一.编译安装过程
注意是参考[1],但有问题。
- 安装nasm
wget https://www.nasm.us/pub/nasm/releasebuilds/2.14/nasm-2.14.tar.gz
tar xvf nasm-2.14.tar.gz
cd nasm-2.14/
./configure --enable-shared --prefix=/home/work/zxc/video_install/ffmpeg/x64/
make && make install
export PATH=$PATH:/home/work/zxc/video_install/ffmpeg/x64/bin
或者修改/etc/profile,执行source /etc/profile - 安装x264
wget http://download.videolan.org/pub/videolan/x264/snapshots/last_stable_x264.tar.bz2
bzip2 -d last_stable_x264.tar.bz2
tar -xvf last_stable_x264.tar
cd x264-snapshot-20181112-2245-stable/
./configure --enable-shared --prefix=/home/work/zxc/video_install/ffmpeg/x64/
make && make install - 安装ffmpeg
wget https://ffmpeg.org/releases/ffmpeg-4.1.tar.bz2
bzip2 -d ffmpeg-4.1.tar.bz2
tar -xvf ffmpeg-4.1.tar
cd ffmpeg-4.1/
./configure --enable-shared --enable-gpl --enable-libx264 --prefix=/home/work/zxc/video_install/ffmpeg/x64/ --extra-cflags=-I/home/work/zxc/video_install/ffmpeg/x64/include --extra-ldflags=-L/home/work/zxc/video_install/ffmpeg/x64/lib
make && make install
二.ffmpeg编译安装报错
(1)执行ffmpeg报错, ffmpeg: error while loading shared libraries: libavdevice.so.55: cannot open shared object file: No such file or directory。
原因:没有添加编解码器库 ldconfig 路径
解决方法:参考[2],编辑/etc/ld.so.conf,然后执行ldconfig保存,我这里发现两个地方有libavdevice.so文件,都添加才执行ffmpeg成功。
# vim /etc/ld.so.conf
/usr/local/lib
/home/work/zxc/video_install/ffmpeg/x64/lib
另外,需要注意如果想用ffplay播放视频,是需要图形界面的,linux不支持。
三.references
[1] https://blog.csdn.net/smilefyx/article/details/32714743
[2] https://stackoverflow.com/questions/12901706/ffmpeg-error-in-linux ffmpeg出错解决