0 设备和docker信息
设备为NVIDIA Jetson Xavier NX,jetpack版本为 5.1.1 [L4T 35.3.1]
使用的docker镜像为nvcr.io/nvidia/l4t-ml:r35.2.1-py3,详见https://catalog.ngc.nvidia.com/orgs/nvidia/containers/l4t-ml
使用下列命令拉取镜像:
bash
sudo docker pull nvcr.io/nvidia/l4t-ml:r35.2.1-py3
使用下列命令启动镜像:
bash
sudo docker run --runtime nvidia -it nvcr.io/nvidia/l4t-ml:r35.2.1-py3
1. 编译x264、x265
APT安装
bash
apt update
apt install libx264-dev libx265-dev
或者按照下面的步骤从源码编译
x264
bash
git clone https://code.videolan.org/videolan/x264.git
cd x264
./configure --prefix=/usr/local --enable-pic --enable-shared
make -j6
make install
x265
bash
git clone https://github.com/videolan/x265.git
cd x265/build/linux
./make-Makefiles.bash
make -j6
make install
2. nvmpi硬解支持
bash
git clone https://github.com/Keylost/jetson-ffmpeg.git
cd jetson-ffmpeg
mkdir build
cd build
cmake ..
make -j6
make install
ldconfig
3. cuda cuvid硬解支持
bash
git clone https://github.com/FFmpeg/nv-codec-headers.git
cd nv-codec-headers
make install
4. 一些依赖
此镜像中缺少pkg-config,会使得ffmpeg的configure过程报错"ERROR: XXXX not found using pkg-config"。
bash
apt update
apt install libnuma-dev pkg-config
5. 编译ffmpeg
bash
git clone git://source.ffmpeg.org/ffmpeg.git -b release/6.0 --depth=1
cd ffmpeg
wget -O ffmpeg_nvmpi.patch https://github.com/Keylost/jetson-ffmpeg/raw/master/ffmpeg_patches/ffmpeg6.0_nvmpi.patch
git apply ffmpeg_nvmpi.patch
./configure --enable-static --enable-shared --enable-nvmpi --enable-gpl --enable-cuda --enable-cuvid --enable-libx264 --enable-libx265 --prefix=/usr/local/ffmpeg
make -j6
make install
添加环境变量
bash
export FFMPEG_HOME=/usr/local/ffmpeg
export PATH=$FFMPEG_HOME/bin:$PATH
可以将上述环境变量写入 ~/.bashrc
6. 验证
bash
ffmpeg -codecs
如果出现
libavdevice.so.58: cannot open shared object file: No such file or directory
或者
ffmpeg: symbol lookup error: ffmpeg: undefined symbol: avio_protocol_get_class, version LIBAVFORMAT_58
新建下面的文件
bash
vim /etc/ld.so.conf.d/ffmpeg.conf
在ffmpeg.conf 文件中写入
bash
/usr/local/ffmpeg/lib
然后
bash
ldconfig