Ubuntu下编译ffmpeg
官网指导:https://trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu
下载源代码
1 | git clone https://git.ffmpeg.org/gitweb/ffmpeg.git |
切换分支
查看远程分支,切换release版本最新的分支到本地,为了稳定,编译少bug,选择release版本的1
2git branch -a
git checkout -b remotes/origin/release/4.1
在当前目录创建个bin文件夹,最为编译安装文件夹
1 | mkdir bin |
安装环境
1 | sudo apt-get update -qq && sudo apt-get -y install \ |
1 | sudo apt-get install nasm |
安装libx264
H.264 video encoder
启用需要 configured 配置 –enable-gpl –enable-libx2641
sudo apt-get install libx264-dev -y
安装libx265
H.265/HEVC video encoder.1
sudo apt-get install libx265-dev libnuma-dev -y
安装libvpx
VP8/VP9 video encoder/decoder
启用需要 configured 配置 –enable-libvpx1
sudo apt-get install libvpx-dev -y
libfdk-aac
AAC audio encoder.
Requires ffmpeg to be configured with –enable-libfdk-aac (and –enable-nonfree if you also included –enable-gpl)1
sudo apt-get install libfdk-aac-dev -y
libmp3lame
MP3 audio encoder.
Requires ffmpeg to be configured with –enable-libmp3lame.1
sudo apt-get install libmp3lame-dev -y
libopus
Opus audio decoder and encoder.
Requires ffmpeg to be configured with –enable-libopus.
1 | sudo apt-get install libopus-dev -y |
libaom
AV1 video encoder/decoder:
手动安装在ffmpeg_build文件夹下,也可以收到下载release版本编译安装1
2
3
4
5
6git -C aom pull 2> /dev/null || git clone --depth 1 https://aomedia.googlesource.com/aom && \
mkdir aom_build && \
cd aom_build && \
PATH="$HOME/bin:$PATH" cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX="$HOME/ffmpeg_build" -DENABLE_SHARED=off -DENABLE_NASM=on ../aom && \
PATH="$HOME/bin:$PATH" make && \
make install
配置configure
生成静态库,动态库, 安装到相对目录./bin文件下1
./configure --prefix=./bin--enable-static --enable-shared
1 | PATH="$HOME/bin:$PATH" PKG_CONFIG_PATH="$HOME/ffmpeg_build/lib/pkgconfig" ./configure \ |
编译并安装
1 | #-j 8 多个编译一起执行,加快变异速度。多线程?多核处理? |
在bin文件夹中lib有生成的静态库和动态库
1 | root@ubuntu:/home/hx/Downloads/ffmpeg/bin/lib# ls |