docs/build_ffmpeg.md
2024-10-19 11:31:30 +08:00

74 lines
3.2 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 基于Ubuntu源码编译ffmpeg
## 编译SDL2
```shell
https://github.com/libsdl-org/SDL/releases/tag/release-2.30.8 # 下载源码
cd sdl/source/folder
./configure --prefix=/usr/local
make
sudo make install
```
## 安装ffmpeg依赖
1. 安装包管理工具 aptitude
aptitude 与 apt-get一样是 Debian 系中功能极其强大的包管理工具。 与 apt-get 不同的是aptitude 在处理依赖问题上更佳一些,当 aptitude 在删除一个包时,会同时删除本身所依赖的包。
```shell
sudo apt install aptitude
```
2. 安装 yasm、nasm
yasm、nasm 是两个汇编器,编译 FFmpeg 需要用到。
安装命令:
```shell
sudo aptitude install yasm nasm
```
3. 其他依赖
FFmpeg 的安装依赖许多库(如,音频编码库,音频解码库,视频编解码库等),这里不介绍每个库的具体作用,按照命令安装即可。
```shell
sudo apt-get install libgmp3-dev
sudo apt install pkg-config
sudo apt install gnutls-bin
sudo aptitude install libaom-dev
sudo aptitude install libass-dev
sudo aptitude install libbluray-dev
sudo aptitude install libfdk-aac-dev
sudo aptitude install libmp3lame-dev
sudo aptitude install libopencore-amrnb-dev
sudo aptitude install libopencore-amrwb-dev
sudo aptitude install libopenmpt-dev
sudo aptitude install libopus-dev
sudo aptitude install libshine-dev
sudo aptitude install libsnappy-dev
sudo aptitude install libsoxr-dev
sudo aptitude install libspeex-dev
sudo aptitude install libtheora-dev
sudo aptitude install libtwolame-dev
sudo aptitude install libvo-amrwbenc-dev
sudo aptitude install llibvpx-dev
sudo aptitude install libwavpack-dev
sudo aptitude install libwebp-dev
sudo aptitude install libx264-dev
sudo aptitude install libx265-dev
sudo aptitude install libxvidcore-dev
sudo aptitude install liblzma-dev
```
## 编译ffmpeg
1. 从官网下载源码
2. 进入根目录编译
```shell
./configure --enable-shared --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-iconv --enable-libass --enable-libbluray --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame
--enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-lzma --enable-zlib --enable-gmp
--enable-libvorbis --enable-libvo-amrwbenc --enable-libspeex --enable-libxvid
--enable-libaom --enable-libopenmpt --enable-libfdk-aac
--enable-nonfree --enable-nvdec --enable-cuda --enable-cuvid --prefix=/usr/local
# 其中 --enable-gpl --enable-libx264 --enable-libx265 --enable-sdl2 必不可少
# 由于需要硬件英伟达显卡加速编解码 -enable-nvdec --enable-cuda --enable-cuvid
# 其他的要是编译不过,就把他删除掉
make
sudo make install
```
如果需要硬件英伟达显卡加速编解码,需要安装相关依赖
```shell
sudo apt install libdssialsacompat-dev
git clone https://git.videolan.org/git/ffmpeg/nv-codec-headers.git
cd nv-codec-headers
make
sudo make install
```