Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 695210 - media-video/ffmpeg - add support for NVIDIA Performance Primitives (NPP, libnpp)
Summary: media-video/ffmpeg - add support for NVIDIA Performance Primitives (NPP, libnpp)
Status: UNCONFIRMED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal with 3 votes (vote)
Assignee: Gentoo Media-video project
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-09-20 18:41 UTC by Soren Harward
Modified: 2022-01-30 23:14 UTC (History)
4 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
ffmpeg-4.2.3-r1.ebuild (ffmpeg-4.2.3-r1.ebuild,18.01 KB, text/plain)
2020-06-25 16:36 UTC, Soren Harward
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Soren Harward 2019-09-20 18:41:24 UTC
ffmpeg includes support for Nvidia's libnpp, which enables various video transformations — particularly resizing — to be performed on the GPU.  This is necessary for efficiently processing video streams decoded/encoded/transcoded on Nvidia GPUs.

libnpp support is enabled using --enable-libnpp in ffmpeg's ./configure .  The Gentoo ffmpeg packages do not provide a way to enable this flag.

libnpp is provided by dev-util/nvidia-cuda-toolkit

Reproducible: Always




I can see three possible ways to implement this, in increasing order of preference:

#1: Add an "npp" USE flag to ffmpeg that adds a dependency on dev-util/nvidia-cuda-toolkit
#2: Add the "cuda" USE flag to ffmpeg, and have it do the same as #1
#3: Modify how the existing video_cards_nvidia USE flag operates in the ffmpeg packages to require dev-util/nvidia-cuda-toolkit, and to add --enable-libnpp to the ./configure command

IMO, #3 is the sanest option, because I can't imagine a circumstance when someone would want to add nvidia hardware decode/encode/transcode support to ffmpeg, but not want hardware-accelerated video transform filters.
Comment 1 Soren Harward 2020-06-25 16:36:38 UTC
Created attachment 646416 [details]
ffmpeg-4.2.3-r1.ebuild

Ebuild that enables NPP support for 4.2.3.

The added include and linking directives at lines 470 and 471 seem kind of ugly to me, but I couldn't get the configuration script to complete without them.

The ffmpeg build process has to be able to find the NPP headers and libraries, which aren't installed by default in a location that GCC looks for them.  And of course CUDA doesn't use pkgconfig, and ffmpeg rolls its own configuration script instead of using autoconf.  There's probably a better, more ebuild-ish way of determining where the headers and libraries are, and passing the appropriate directives on to the ffmpeg configuration script, but I don't know what it is.

At any rate, ffmpeg compiles and runs with the NPP filters using this ebuild.
Comment 2 Gregory Beauregard 2020-10-12 23:04:15 UTC
What's the status on this? Are there things I can improve with the suggested ebuild changed to get the changes in the main repo?

We don't have the cuda scaler either; right now we need external ffmpeg to keep transcodes entirely in GPU on Gentoo.
Comment 3 Iade Gesso 2021-06-10 18:59:47 UTC
Hi!
I tried to port your ebuild to FFMPEG 4.4, but I'm in a multilib environment... I get this error every time:

emerge -q ffmpeg
>>> Verifying ebuild manifests
>>> Emerging (1 of 1) media-video/ffmpeg-4.4-r901::HowlOverlay
>>> Failed to emerge media-video/ffmpeg-4.4-r901, Log file:
>>>  '/tmp/portage/media-video/ffmpeg-4.4-r901/temp/build.log'
 * Package:    media-video/ffmpeg-4.4-r901
 * Repository: HowlOverlay
 * USE:        X abi_x86_32 abi_x86_64 alsa amd64 amr amrenc bluray bs2b bzip2 cdio chromaprint chromium cpu_flags_x86_aes cpu_flags_x86_avx cpu_flags_x86_avx2 cpu_flags_x86_fma3 cpu_flags_x86_fma4 cpu_flags_x86_mmx cpu_flags_x86_mmxext cpu_flags_x86_sse cpu_flags_x86_sse2 cpu_flags_x86_sse3 cpu_flags_x86_sse4_1 cpu_flags_x86_sse4_2 cpu_flags_x86_ssse3 cpudetection cuda dav1d elibc_glibc encode fdk fftools_aviocat fftools_cws2fws fftools_ffescape fftools_ffeval fftools_ffhash fftools_fourcc2pixfmt fftools_graph2dot fftools_ismindex fftools_pktdumper fftools_qt-faststart fftools_sidxindex fftools_trasher fontconfig frei0r fribidi gcrypt gme gmp gnutls gpl gsm iconv iec61883 ieee1394 jack jpeg2k kernel_linux kvazaar ladspa libaom libass libcaca libdrm libilbc libnpp librtmp libsoxr libtesseract libv4l libxml2 lzma modplug mp3 network openal opencl opengl openh264 openssl opus oss pic postproc pulseaudio rubberband samba sdl snappy speex ssh svg theora threads truetype twolame userland_GNU v4l vaapi vdpau video_cards_nvidia vidstab vorbis vpx vulkan webp x264 x265 xvid zeromq zimg zlib zvbi
 * FEATURES:   network-sandbox preserve-libs sandbox userpriv usersandbox
 * Applying chromium-r1.patch ...
 [ ok ]
 * abi_x86_32.x86: running multilib-minimal_abi_src_configure
/tmp/portage/media-video/ffmpeg-4.4-r901/work/ffmpeg-4.4/configure --prefix=/usr --libdir=/usr/lib --shlibdir=/usr/lib --docdir=/usr/share/doc/ffmpeg-4.4-r901/html --mandir=/usr/share/man --enable-shared --cc=x86_64-pc-linux-gnu-gcc -m32 --cxx=x86_64-pc-linux-gnu-g++ -m32 --ar=x86_64-pc-linux-gnu-ar --nm=x86_64-pc-linux-gnu-nm --ranlib=x86_64-pc-linux-gnu-ranlib --pkg-config=x86_64-pc-linux-gnu-pkg-config --optflags=-O2 -pipe -march=native -msse4 -msse4.1 -msse4.2 -mcx16 -fomit-frame-pointer -mfpmath=sse -msahf -w --extra-libs= --disable-static --enable-avfilter --enable-avresample --disable-stripping --disable-optimizations --disable-libcelt --enable-nonfree --enable-version3 --enable-version3 --disable-indev=sndio --disable-outdev=sndio --enable-version3 --enable-version3 --enable-nonfree --enable-bzlib --enable-runtime-cpudetect --disable-debug --enable-gcrypt --enable-gnutls --enable-gmp --enable-gpl --disable-hardcoded-tables --enable-iconv --enable-libxml2 --enable-lzma --enable-network --enable-opencl --enable-openssl --enable-postproc --enable-libsmbclient --enable-ffplay --enable-sdl2 --enable-vaapi --enable-vdpau --enable-vulkan --enable-xlib --enable-libxcb --enable-libxcb-shm --enable-libxcb-xfixes --enable-zlib --enable-libcdio --enable-libiec61883 --enable-libdc1394 --enable-libcaca --enable-openal --enable-opengl --enable-libv4l2 --enable-libpulse --enable-libdrm --enable-libjack --enable-libopencore-amrwb --enable-libopencore-amrnb --disable-libcodec2 --enable-libdav1d --enable-libfdk-aac --enable-libopenjpeg --enable-libbluray --enable-libgme --enable-libgsm --disable-libaribb24 --disable-mmal --enable-libmodplug --enable-libopus --enable-libilbc --enable-librtmp --enable-libssh --enable-libspeex --disable-libsrt --enable-librsvg --enable-ffnvcodec --enable-libvorbis --enable-libvpx --enable-libzvbi --disable-appkit --enable-libbs2b --enable-chromaprint --enable-cuda-llvm --disable-libflite --enable-frei0r --enable-libfribidi --enable-fontconfig --enable-ladspa --enable-libass --enable-libtesseract --disable-lv2 --enable-libfreetype --enable-libvidstab --enable-librubberband --enable-libzmq --enable-libzimg --enable-libsoxr --enable-pthreads --enable-libvo-amrwbenc --enable-libmp3lame --enable-libkvazaar --enable-libaom --enable-libnpp --enable-libopenh264 --disable-librav1e --enable-libsnappy --enable-libtheora --enable-libtwolame --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --disable-gnutls --disable-librav1e --disable-libzmq --disable-armv5te --disable-armv6 --disable-armv6t2 --disable-neon --disable-vfp --disable-vfpv3 --disable-armv8 --disable-mipsdsp --disable-mipsdspr2 --disable-mipsfpu --disable-altivec --disable-vsx --disable-power8 --disable-amd3dnow --disable-amd3dnowext --disable-xop --enable-pic --disable-asm --cpu=host --enable-lto --disable-doc --disable-htmlpages --disable-manpages
ERROR: libnpp not found

If you think configure made a mistake, make sure you are using the latest
version from Git.  If the latest version fails, report the problem to the
ffmpeg-user@ffmpeg.org mailing list or IRC #ffmpeg on irc.freenode.net.
Include the log file "ffbuild/config.log" produced by configure as this will help
solve the problem.
 * ERROR: media-video/ffmpeg-4.4-r901::HowlOverlay failed (configure phase):
 *   (no error message)
 * 
 * Call stack:
 *     ebuild.sh, line  127:  Called src_configure
 *   environment, line 2667:  Called multilib-minimal_src_configure
 *   environment, line 1872:  Called multilib_foreach_abi 'multilib-minimal_abi_src_configure'
 *   environment, line 2125:  Called multibuild_foreach_variant '_multilib_multibuild_wrapper' 'multilib-minimal_abi_src_configure'
 *   environment, line 1802:  Called _multibuild_run '_multilib_multibuild_wrapper' 'multilib-minimal_abi_src_configure'
 *   environment, line 1800:  Called _multilib_multibuild_wrapper 'multilib-minimal_abi_src_configure'
 *   environment, line  818:  Called multilib-minimal_abi_src_configure
 *   environment, line 1866:  Called multilib_src_configure
 *   environment, line 2439:  Called die
 * The specific snippet of code:
 *       "${@}" || die;
 * 
 * If you need support, post the output of `emerge --info '=media-video/ffmpeg-4.4-r901::HowlOverlay'`,
 * the complete build log and the output of `emerge -pqv '=media-video/ffmpeg-4.4-r901::HowlOverlay'`.
 * The complete build log is located at '/tmp/portage/media-video/ffmpeg-4.4-r901/temp/build.log'.
 * The ebuild environment file is located at '/tmp/portage/media-video/ffmpeg-4.4-r901/temp/environment'.
 * Working directory: '/tmp/portage/media-video/ffmpeg-4.4-r901/work/ffmpeg-4.4-abi_x86_32.x86'
 * S: '/tmp/portage/media-video/ffmpeg-4.4-r901/work/ffmpeg-4.4'
Comment 4 Soren Harward 2021-06-11 14:17:37 UTC
(In reply to Iade Gesso from comment #3)
> Hi!
> I tried to port your ebuild to FFMPEG 4.4, but I'm in a multilib
> environment... I get this error every time:

[...] 

> ERROR: libnpp not found

Does the library /opt/cuda/targets/x86_64-linux/lib/libnppc.so exist on your machine? If not, you'll need to install dev-util/nvidia-cuda-toolkit, or tweak the ebuild to point to the right location.
Comment 5 Iade Gesso 2022-01-30 23:14:37 UTC
(In reply to Soren Harward from comment #4)
> (In reply to Iade Gesso from comment #3)
> > Hi!
> > I tried to port your ebuild to FFMPEG 4.4, but I'm in a multilib
> > environment... I get this error every time:
> 
> [...] 
> 
> > ERROR: libnpp not found
> 
> Does the library /opt/cuda/targets/x86_64-linux/lib/libnppc.so exist on your
> machine? If not, you'll need to install dev-util/nvidia-cuda-toolkit, or
> tweak the ebuild to point to the right location.

Sorry for late reply.
Now I'm on nvidia-cuda-toolkit 11.6.0, and the patched ebuild still doesn't find the libnpp library but in my system /opt/cuda/targets/x86_64-linux/lib/libnppc.so exists... but only now I see that since I'm in a multilib install the error is just for the x86 ABI and it is generated by abi_x86_32.x86: running multilib-minimal_abi_src_configure


Iade