linux安装ffmpeg:
- 新建一个ffmpeg文件夹:mkdir ffmpeg
- 如果没安装wget,先安装:yum install wget
- wget http://www.ffmpeg.org/releases/ffmpeg-4.4.tar.xz 或者是.gz(.gz和.xz是两种不同的压缩方式)
- tar -xvf ffmpeg-4.4.tar.xz
- 先安装gcc和yasm编译器:yum install gcc,yum install yasm
- 安装音频和视频编码库:
-
wget https://sourceforge.net/projects/lame/files/lame/3.100/lame-3.100.tar.gz/download --no-check-certificate
-
下载的文件名为download,修改文件名为lame-3.100.tar.gz
-
tar -zxvf lame-3.100.tar.gz
-
cd lame-3.100
-
./configure --enable-shared
-
make && make install
-
wget http://download.videolan.org/x264/snapshots/x264-snapshot-20191217-2245.tar.bz2
-
tar -jxvf x264-snapshot-20191217-2245.tar.bz2
-
如果提示no file 安装解压工具:yum -y install bzip2
-
./configure --enable-shared --enable-static --disable-asm
-
make && make install
-
- 到ffmpeg解压的目录下执行 ./configure --enable-libmp3lame --enable-libx264 --enable-gpl --prefix=/usr/local/ffmpeg
- make && make install
- 如果找不到make,先安装:yum -y install gcc automake autoconf libtool make
- 添加环境变量:vi /etc/profile
- 按下i,移动到最后一行,输入export PATH=$PATH:/usr/local/ffmpeg/bin,按下esc,输入:wq保存退出
- source /etc/profile设置生效
- ffmpeg -version查看是否安装成功
报错处理
- 报错:./ffmpeg: error while loading shared libraries: libmp3lame.so.0: cannot open shared object file: No such file or directory
- 解决办法:ln -s /usr/local/lib/libmp3lame.so.0.0.0 /usr/lib64/libmp3lame.so.0
- 报错:/ffmpeg: error while loading shared libraries: libx264.so.157: cannot open shared object file: No such file or directory
- 解决办法:export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH export CFLAGS=/usr/local/include:$CFLAGS