1.安装依赖库
sudo apt-get update
sudo apt-get install yasm nasm build-essential
sudo apt-get install libgmp3-dev pkg-config gnutls-bin libaom-dev libass-dev libbluray-dev libfdk-aac-dev
sudo apt-get install libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libopenmpt-dev libopus-dev
sudo apt-get install libshine-dev libsnappy-dev libsoxr-dev libspeex-dev libtheora-dev libtwolame-dev libvo-amrwbenc-dev
sudo apt-get install libwavpack-dev libwebp-dev libx264-dev libx265-dev libxvidcore-dev liblzma-dev libvpx-dev
2.下载代码
ubuntu:~/workspace$ git clone https://git.ffmpeg.org/ffmpeg.git ffmpeg
Cloning into 'ffmpeg'...
remote: Enumerating objects: 305, done.
remote: Counting objects: 100% (305/305), done.
remote: Compressing objects: 100% (193/193), done.
remote: Total 688369 (delta 192), reused 137 (delta 111)
Receiving objects: 100% (688369/688369), 162.87 MiB | 9.69 MiB/s, done.
Resolving deltas: 100% (557383/557383), done.
ubuntu:~/workspace$ cd ffmpeg/
#查看当前分支
ubuntu:~/workspace/ffmpeg$ git branch
* master
#查看远端分支
ubuntu:~/workspace/ffmpeg$ git branch -a
* master
remotes/origin/HEAD -> origin/master
remotes/origin/master
remotes/origin/oldabi
remotes/origin/release/0.10
remotes/origin/release/0.11
remotes/origin/release/0.5
remotes/origin/release/0.6
remotes/origin/release/0.7
remotes/origin/release/0.8
remotes/origin/release/0.9
remotes/origin/release/1.0
remotes/origin/release/1.1
remotes/origin/release/1.2
remotes/origin/release/2.0
remotes/origin/release/2.1
remotes/origin/release/2.2
remotes/origin/release/2.3
remotes/origin/release/2.4
remotes/origin/release/2.5
remotes/origin/release/2.6
remotes/origin/release/2.7
remotes/origin/release/2.8
remotes/origin/release/3.0
remotes/origin/release/3.1
remotes/origin/release/3.2
remotes/origin/release/3.3
remotes/origin/release/3.4
remotes/origin/release/4.0
remotes/origin/release/4.1
remotes/origin/release/4.2
remotes/origin/release/4.3
remotes/origin/release/4.4
remotes/origin/release/5.0
remotes/origin/release/5.1
remotes/origin/release/6.0
# 切换到 分支4.4
ubuntu:~/workspace/ffmpeg$ git checkout release/4.4
Branch 'release/4.4' set up to track remote branch 'release/4.4' from 'origin'.
Switched to a new branch 'release/4.4'
ubuntu:~/workspace/ffmpeg$ git branch
master
* release/4.4
3.编译源码
#进入 ffmpeg 目录
ubuntu:~/workspace$ cd ffmpeg
#执行 make
ubuntu:~/workspace/ffmpeg$ sudo make
#执行 make install
ubuntu:~/workspace/ffmpeg$ sudo make install
#耐心等待完成。。。。
4.添加环境变量
#vim 打开 .bashrc
ubuntu:~/workspace/ffmpeg$ sudo vim ~/.bashrc
#在文件最后写入并保存
#FFmpeg
export PATH=$PATH:/home/ubuntu/workspace/ffmpeg/bin
#执行 source 命令
ubuntu:~/workspace/ffmpeg$ source ~/.bashrc
ubuntu:~/workspace/ffmpeg$ sudo vim /etc/ld.so.conf.d
#加入lib 路径 保存退出
/home/ubuntu/workspace/ffmpeg/lib/
#执行 ldconfig
ubuntu:~/workspace/ffmpeg$ sudo ldconfig
#执行 ffmpeg -version
ubuntu:~/workspace/ffmpeg/lib$ ffmpeg -version
ffmpeg version n4.4.4 Copyright (c) 2000-2023 the FFmpeg developers
built with gcc 11 (Ubuntu 11.3.0-1ubuntu1~22.04)
configuration: --prefix=/home/ubuntu/workspace/ffmpeg --enable-gpl --enable-nonfree --enable-libfdk-aac --enable-libx264 --enable-libx265 --enable-filter=delogo --enable-debug --disable-optimizations --enable-libspeex --enable-shared --enable-pthreads --enable-version3 --enable-hardcoded-tables --cc=gcc --host-cflags= --host-ldflags=
libavutil 56. 70.100 / 56. 70.100
libavcodec 58.134.100 / 58.134.100
libavformat 58. 76.100 / 58. 76.100
libavdevice 58. 13.100 / 58. 13.100
libavfilter 7.110.100 / 7.110.100
libswscale 5. 9.100 / 5. 9.100
libswresample 3. 9.100 / 3. 9.100
libpostproc 55. 9.100 / 55. 9.100