2024-10-19 11:31:30 +08:00
|
|
|
|
# 基于Ubuntu源码编译ffmpeg
|
2024-10-28 17:24:18 +08:00
|
|
|
|
## 编译SDL2(可选)
|
2024-10-19 11:31:30 +08:00
|
|
|
|
```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
|
2024-10-28 17:24:18 +08:00
|
|
|
|
./configure --enable-shared --enable-gpl --enable-sdl2 --enable-libx264 --enable-libx265 --enable-nvdec --enable-nvenc --enable-cuda --enable-cuvid
|
|
|
|
|
# 其中 --enable-gpl --enable-libx264 --enable-libx265 必不可少 --enable-sdl2 是ffmpeg播放器需要的
|
|
|
|
|
# 由于需要硬件英伟达显卡加速编解码 --enable-nvdec --enable-nvenc --enable-cuda --enable-cuvid
|
|
|
|
|
# --enable-shared 使make install时,将动态库也正确安装,否则运行ffmpeg时,会显示缺少动态库
|
|
|
|
|
|
2024-10-19 11:31:30 +08:00
|
|
|
|
make
|
|
|
|
|
sudo make install
|
2024-10-28 17:24:18 +08:00
|
|
|
|
# 安装完后,确保安装目录,确保已经配置好动态库搜索的路径,
|
|
|
|
|
```
|
2024-10-19 11:31:30 +08:00
|
|
|
|
如果需要硬件英伟达显卡加速编解码,需要安装相关依赖
|
|
|
|
|
```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
|
2024-10-28 17:24:18 +08:00
|
|
|
|
```
|