本文参考:
https://blog.csdn.net/makymilk/article/details/107400119
害怕链接失效,所以自己写一个备份。
一、下载安装包
git clone https://git.ffmpeg.org/ffmpeg.git --config http.proxy= --config http.sslVerify=false
二、编译安装
进入刚才下载的ffmpeg目录
./configure --prefix=/usr/local/ffmpeg --enable-debug=3 --enable-shared --disable-static
指令解释:
--prefix=/user/local/ffmpeg指定目录
--enable-debug=3 调试等级
--enable-shared 生成动态库
--disable-static 不允许生成静态库
编译
make -j 4
安装
sudo make install
配置环境变量:
vim ~/.bashrc
export PATH="$PATH:/usr/local/ffmpeg/bin"
source ~/.bashrc
验证是否安装成功:
cluo@cluo:~/ffmpeg$ ffmpeg
ffmpeg version N-106738-g3946cb02fc Copyright (c) 2000-2022 the FFmpeg developers
built with gcc 9 (Ubuntu 9.4.0-1ubuntu1~20.04.1)
configuration: --prefix=/usr/local/ffmpeg --enable-debug=3 --enable-shared --disable-static
libavutil 57. 24.101 / 57. 24.101
libavcodec 59. 27.100 / 59. 27.100
libavformat 59. 23.100 / 59. 23.100
libavdevice 59. 6.100 / 59. 6.100
libavfilter 8. 37.100 / 8. 37.100
libswscale 6. 6.100 / 6. 6.100
libswresample 4. 6.100 / 4. 6.100
Hyper fast Audio and Video encoder
usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...
Use -h to get full help or, even better, run 'man ffmpeg'
ok了
三、编译报错解决
错误:
nasm/yasm not found or too old. Use --disable-x86asm for a crippled build.
解决方法:需要安装yasm的汇编编译器
sudo apt-get install yasm
错误:
ffmpeg: error while loading shared libraries: libavdevice.so.58: cannot open shared object file: No such file or directory
解决方法:
vim ~/.bashrc
export LD_LIBRARY_PATH=/usr/local/ffmpeg/lib/
source ~/.bashrc
错误:
gcc is unable to create an executable file
解决方法:
sudo apt-get install gcc