由于编译安装的不确定性,这里使用容器测试
docker run --name=ffmpeg -p 2222:22 -v /Users/zen/container:/mnt --privileged -it ubuntu /bin/bash
- 先安装需要的软件
$ apt install libfdk-aac-dev \
libmp3lame-dev \
libtheora-dev \
libvorbis-dev \
yasm \
libx264-dev \
libxvidcore-dev \
libaom-dev \
libass-dev \
libopencv-dev \
build-essential \
libavformat-dev \
libssl-dev \
libopenh264-dev \
libopenjp2-7-dev \
librsvg2-dev \
libsvtav1enc-dev \
libtesseract-dev \
libtwolame-dev \
libvpx-dev \
libwebp-dev \
libx265-dev \
make
- 设定配置文件
./configure --prefix=/opt/ffmpeg \
--enable-shared \
--enable-libfdk-aac \
--enable-libaom \
--enable-gpl \
--enable-nonfree \
--enable-postproc \
--enable-avfilter \
--enable-pthreads \
--enable-libmp3lame \
--enable-libtheora \
--enable-libvorbis \
--enable-libx264 \
--enable-libxvid \
--enable-libx265 \
--enable-libwebp \
--enable-libvpx \
--enable-libass \
--enable-libmp3lame \
--enable-libopenh264 \
--enable-libopenjpeg \
--enable-librsvg \
--enable-libsvtav1 \
--enable-libtesseract \
--enable-libtwolame
- 编译安装
# 需要切换到root用户
make -j8 # 时间长
make install
- 将ffmpeg的库文件加入系统
$ sudo -i
$ echo "/opt/ffmpeg/lib" >> /etc/ld.so.conf
$ ldconfig
- 将ffmpeg程序目录加入环境变量
$ echo "export PATH=$PATH:/opt/ffmpeg/bin" >> ~/.profile
$ source ~/.profile
- 测试
$ ffmpeg -i 心中的日月.mp3 -c:a libfdk_aac -profile:a aac_he -b:a 96k 心中的日月.aac