Open madsciencetist opened 1 year ago
Example dockerizable build script:
#!/bin/bash
set -euxo pipefail
INSTALL_PREFIX=/rootfs/usr/local
apt-get -qq install -y --no-install-recommends build-essential clang cmake pkg-config
# Install libnvmpi to enable nvmpi decoders (h264_nvmpi, hevc_nvmpi)
if [ -e /usr/local/cuda-10.2 ]; then
# assume Jetpack 4.X
wget -q https://developer.nvidia.com/embedded/L4T/r32_Release_v5.0/T186/Jetson_Multimedia_API_R32.5.0_aarch64.tbz2 -O jetson_multimedia_api.tbz2
else
# assume Jetpack 5.X
wget -q https://developer.nvidia.com/downloads/embedded/l4t/r35_release_v3.1/release/jetson_multimedia_api_r35.3.1_aarch64.tbz2 -O jetson_multimedia_api.tbz2
fi
tar xaf jetson_multimedia_api.tbz2 -C / && rm jetson_multimedia_api.tbz2
wget -q https://github.com/Keylost/jetson-ffmpeg/archive/refs/heads/master.zip
unzip master.zip && rm master.zip && cd jetson-ffmpeg-master
LD_LIBRARY_PATH=$(pwd)/stubs:$LD_LIBRARY_PATH # tegra multimedia libs aren't available in image, so use stubs for ffmpeg build
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$INSTALL_PREFIX
make -j$(nproc)
make install
cd ../../
# Install nv-codec-headers to enable ffnvcodec filters (scale_cuda)
wget -q https://github.com/FFmpeg/nv-codec-headers/archive/refs/heads/master.zip
unzip master.zip && rm master.zip && cd nv-codec-headers-master
make install
cd ../ && rm -rf nv-codec-headers-master
# Build ffmpeg with nvmpi patch
wget -q https://ffmpeg.org/releases/ffmpeg-6.0.tar.xz
tar xaf ffmpeg-*.tar.xz && rm ffmpeg-*.tar.xz && cd ffmpeg-*
patch -p1 < ../jetson-ffmpeg-master/ffmpeg_patches/ffmpeg6.0_nvmpi.patch
export PKG_CONFIG_PATH=$INSTALL_PREFIX/lib/pkgconfig
# enable Jetson codecs but disable dGPU codecs
./configure --enable-nvmpi --enable-ffnvcodec --enable-cuda-llvm \
--disable-cuvid --disable-nvenc --disable-nvdec \
--enable-shared --disable-static --prefix=$INSTALL_PREFIX \
|| (cat ffbuild/config.log && false)
make -j$(nproc)
make install
cd ../
rm -rf ffmpeg-* jetson-ffmpeg-master /usr/src/jetson_multimedia_api
apt-get purge -y build-essential clang cmake pkg-config
Nvjpeg is needed and here's why: https://forums.developer.nvidia.com/t/a-segfault-occurs-when-creating-nvvideodecoder-inside-a-child-process/189290/11 . It's workaround:)
Hah, I had removed nvjpeg because the stub was empty! Added it back.
I tried your NvFaultEx
, replicated the segfault without nvjpeg and the lack of segfault with it, and then verified that it remains fixed when linking against an empty nvjpeg stub.
So this should be good now
Docker build works on latest master with both Jetpack 4.6 and Jetpack 5.0
NVIDIA does not distribute the jetson multimedia libraries other than on Jetson board images, so the only way to link against these libs is to compile directly on a Jetson, making it difficult to create automated builds or Docker images. This commit adds stubs of those libraries so that nvmpi and ffmpeg can be built without them. The real libraries will still be required at runtime.
Stubs generated using so-stub. They are neither static, rpathed nor installed so that there is no chance of them overriding the real libraries. If someone were to LD_LIBRARY_PATH or manually copy the stubs into an existing library path, the stubbed functions will print an error message and
abort()
when called.