安装ffmpeg,发现过程还是挺复杂的,安装过程中遇到不少问题,一一解决后,总结了详细的安装过程
1、安装各种库:
sudo apt-get install -y autoconf automake build-essential git libass-dev libfreetype6-dev libsdl2-dev libtheora-dev libtool libva-dev libvdpau-dev libvorbis-dev libxcb1-dev libxcb-shm0-dev libxcb-xfixes0-dev pkg-config texinfo wget zlib1g-dev
sudo apt-get install -y yasm cmake mercurial
2、安装ysam
git clone git://github.com/yasm/yasm.git
cd yasm
./configure
make
sudo make install
3、下载安装最新版nasm:Index of /pub/nasm/releasebuilds/2.13.03
解压后,进入目录,执行:
./configure
make
sudo make install
4、安装x264
git clone VideoLAN / x264 · GitLab - 如果超时,到Download - The Yasm Modular Assembler Project下载
cd x264.git
./configure --enable-shared --enable-static
sudo make install
5、安装ffmpeg
下载:Download FFmpeg,解压后,进入目录,执行:
./configure --enable-static --enable-shared --enable-ffmpeg --enable-libx264 --enable-gpl
make
sudo make install
make时间很长。
instal以后,执行ffmpeg会失败:
ffmpeg: error while loading shared libraries: libavdevice.so.59: cannot open shared object file: No such file or directory
6、修改环境变量
sudo gedit /etc/ld.so.conf
打开文本后,加入如下路径:
/usr/local/lib/
#最后面的斜杠一定要带上,别忘了!
#该路径为libavdevice.so.59所在路径
sudo ldconfig
至此,终于能运行ffmpeg了。
$ ffmpeg
ffmpeg version 5.0 Copyright (c) 2000-2022 the FFmpeg developers
built with gcc 7 (Ubuntu 7.5.0-3ubuntu1~18.04)
configuration: --enable-static --enable-shared --enable-ffmpeg --enable-libx264 --enable-gpl
libavutil 57. 17.100 / 57. 17.100
libavcodec 59. 18.100 / 59. 18.100
libavformat 59. 16.100 / 59. 16.100
libavdevice 59. 4.100 / 59. 4.100
libavfilter 8. 24.100 / 8. 24.100
libswscale 6. 4.100 / 6. 4.100
libswresample 4. 3.100 / 4. 3.100
libpostproc 56. 3.100 / 56. 3.100
Hyper fast Audio and Video encoder
usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...
也可以播放一个视频试试:
$ ffplay media1.mp4