Add tegra lib stubs and remove unused nvjpeg requirement#9
Merged
Conversation
Author
|
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
|
Owner
|
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:) |
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.
Author
|
Hah, I had removed nvjpeg because the stub was empty! Added it back. I tried your So this should be good now |
Stubbing only used functions is brittle as it requires updating the stubs every time a new function is used. Now these stubs are complete enough to be used in any project.
Author
|
Docker build works on latest master with both Jetpack 4.6 and Jetpack 5.0 |
Owner
|
I added several cmake options to make it more convenient to write automated build scripts and accepted stubs into the master branch. :) See readme for details. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.