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.
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.
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.
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'
(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.
(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
Do you foresee any update on this one? I am trying to utilize CUDA for video transcoding on my server and ffmpeg configuration is a bit of a pain ;)
The bug has been closed via the following commit(s): https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=00eddc65d7bd9ecaa9973fd46e544bbbfe5c9479 commit 00eddc65d7bd9ecaa9973fd46e544bbbfe5c9479 Author: Ionen Wolkens <ionen@gentoo.org> AuthorDate: 2025-03-07 13:02:23 +0000 Commit: Ionen Wolkens <ionen@gentoo.org> CommitDate: 2025-03-11 09:03:17 +0000 media-video/ffmpeg: rewrite live ebuild This does not list all changes compared to original due to being essentially a rewrite (not much sense in looking at the diff given almost no lines in common), but to list or explain notable ones: * Cleanup a lot of obsolete logic, like mirror://gentoo snapshots, SCM type, <openssl-3 handling, etc... * Re-arrange IUSE=soc handling to drop the IUSE when FFMPEG_SOC_PATCH is empty until maintainer of the patch has time to look at that (easier to bump without it and removes the need to mask in 9999) * Drop some IUSE, ffmpeg has a bit too many often confusing users and, while debatable, some are not really useful to control bare at most for expert user that could use EXTRA_ECONF if *really* wanted: - debug (disabled): does very little beside override users' -g*, albeit if want nasm debug symbols will need to set X86ASMFLAGS. - encode (enabled): debated keeping it for disabling encoders without their own USE for bit of size/build time reduction despite no dependencies, but feel it is not really worth it as it complicates the ebuild and can break expectations for a lot of revdeps (many likely lack the [encode] that they need) -- removal also handles bug #770439 - fftools_* (disabled): almost no distros install these, many have rather generic names, we were missing installing new ones, upstream ffmpeg does not even have an install target for them, and a global USE_EXPAND for this feels wasteful (*could* consider adding a all-in-one IUSE=tools if some are wanted by users anyway but let us try without and see if anyone complains) - glslang (disabled): redundant with USE=shaderc and is a pain to use directly given glslang often breaks things, esp. worse for packages with a slow release cycle and old LTS versions like ffmpeg (bug #918989, bug #920283, bug #922333, bug #922433) -- upstream also seems to favour shaderc: "libshaderc and libglslang are mutually exclusive, if in doubt, disable libglslang" (from ./configure) - harcoded-tables (disabled): off by default upstream and listed as a "experts only" option that seemingly provide little gains for a notable size increase, do not believe it is worth exposing as a USE - iconv (enabled): virtual/libiconv is essentially free anywhere but prefix and disabling iconv can be rather broken for a few things - network (enabled): no dependencies, fairly small, and many revdeps likely expect it to be enabled and just missing the [network] (tempting to do the same with USE=postproc but it would still be conditional through USE=gpl and be more confusing, and then forcing GPL also has its own issues) - oss (auto): does not have a dedicated option and just checks linux-headers and is very small, hardly anyone need this but that argument could be applied to a *ton* of in/outdevs, filters, de/encoders, and such and we would never see the end of it - pic (enabled): makes little sense not to enable nowadays and handles bug #903754 + bug #916067 -- USE had the secondary effect of disabling x86-32 asm which still doing given it is difficult to support either way due to textrels and >=binutils-2.41's enforcing (bug #916067, bug #920808), and it is possibly broken for older hardware (bug #733556) -- as a minor bonus, this should also let LTO work with abi_x86_32 (bug #654118) - static-libs (disabled): cannot think of much of a use for this esp. given how massive these libraries are and it would still require to link with all its shared-only dependencies - test (irrelevant): tests are not gone but there is no dependencies (bc and wget are not needed) nor REQUIRED_USE to handle anymore, thus USE is useless - threads (auto): no real sense in disabling (bug #868471), and leaving it auto let ffmpeg figure out the right implementation to use which in most cases means default --enable-pthreads - cpu_flags_* + cpudetection (enabled): tentatively anyway, just let ffmpeg do its thing normally -- simplifies the ebuild a lot, "should" fix bug #915384, and also handles whatever ebuild was doing wrong wrt bug #752507 + bug #778035 (one minor "issue" however is that all these flags being removed will leave users confused as to what happened, if reading this and worried about optimizations.. then no they are *not* disabled, and it is fine for other machines thanks to detection at runtime) * New IUSE: - openmpt: requested in bug #921313 - npp: requested in bug #695210 -- note have not tested the arm64 (sbsa) support, but it should work in theory as cuda toolkit does install npp prebuilt arm64 libraries - rabbitmq: trivial, may as well add support (meant to add more but others did not fare as well and will leave for later rather than during big changes, kept some minor notes in the ebuild about things still not supported) * Renamed IUSE: - mp3->lame: this is only for encoding but it made it "sound" needed for decoding (not the only case like this but this one felt too generic), may surprise those that had it actually enabled for encoding - libxml2->xml and libdrm->drm: given newly enabling these by default (see below), it's a good occasion to rename to the more commonly used USE without causing issues - libv4l->v4l: to be precise IUSE=v4l was removed and it gained the meaning that IUSE=libv4l had -- old v4l is always enabled (if linux) due to the hard dependency on linux-headers (see below) -- given the old REQUIRED_USE with libv4l? ( v4l ), all users of libv4l will have the new USE enabled already - libdvdnav+libdvdread->dvd(combined): similar to mpv, simpler for users when they just want dvds to work than worry about each library (dvd support is new in ffmpeg-7, so this only ever been masked) * Enable a few extra IUSE by default that, while not everyone needs, are useful and have dependencies that many users will already have. - libass,truetype,fontconfig: for proper text/subtitles drawing (kdenlive also wants [libass]), albeit video players tend to have their own handling (that pull the same depdencies) - drm: used in various pieces of code and little reason to disable when mesa depends on libdrm either way - xml: needed for DASH-type streams, notably used by youtube, and about everyone has libxml2 (one downside of new defaults is MULTILIB_USEDEP, users that only selectively enable abi_x86_32 rather than globally may be faced with conflicts when updating) * Always depend on linux-headers if linux, not *required* (except for v4l) but this prevents a lot of automagic and going through alternate code paths if missing (also go with >=6 which is needed for v4l2m2m and I believe also USE=soc for v4l2request) * Add missing vulkan-headers dependency wrt bug #865201, and also opencl-headers wrt bug #941506 (not 100% sure that this is what happened for the latter, but given binhost is setup it is likely). * Bump nv-codec-headers min req to 12.1.14.0, while not *required* it spares us for setting up ranges and 11.x is due for cleanup. * Add missing x11-base/xorg-proto wrt bug #934196 -- technically was longer an issue given libX11 RDEPENDs on it "now", but would still rather keep these for now. * Depend on >=librsvg-2.52 wrt bug #918613, USE=svg is not essential for arches without rust and upstream bug been went 1.5 years without activity. * Update REQUIRED_USE a bit, cuda does not *need* nvenc (just get one filter in less), libplacebo does nothing without sdl(ffplay) or vulkan, and few others like these (likely still missing some). * Drop musl HAVE_POSIX_IOCTL workaround, this is automatically set by ./configure since ffmpeg-7.1. However, note that there is another related issue with libv4l (not v4l) that is not fixed (bug #911499). * No longer ignore ffmpeg-spec-disposition test, fixed in 7.1.1. * Fix verify-sig paths on prefix wrt bug #947253 (untested) * No longer pass e.g. --disable-indev=alsa when already doing --disable-alsa, ./configure seem to figure this out just fine. * No longer pass --cpu, this expects the -march=<exact> reported by the compiler or probes compiler with =native if =host), however it does not account for -mno-* both passed or implied by =native and could enable things it shouldn't. Furthermore, it adds -march=<exact> after the users' -march=native (which is more correct, can enable or disable additional features). This option only seem like trouble and likely does not get tested much. Removing also handles bug #830165 albeit ffmpeg-chromium is still affected. * Replace EXTRA_FFMPEG_CONF by EXTRA_ECONF, while it is not using econf nor autoconf, the latter is more widely known while the former needs users to look at the ebuild -- also die if old variable is set so users know about this change. * Skip installing doc/*.txt, that seems mostly oriented at ffmpeg devs, and feels noisy in the docdir, but do keep doc/APIChanges * Replace all *GPL* by the + version given ./configure always output with "or later" when listing the final license. * Maybe not best way to go about this, but when doing incompatible --enable-gpl --enable-nonfree, on top of the RESTRICT="bindist" also add "all-rights-reserved" so a typical freedom ACCEPT_LICENSE can block it. * Rearrange chromium patch a bit to need less ebuild logic, and make it unused for ffmpeg-compat. * Drop EGIT_MIN_CLONE_TYPE, shallow clones seem fine now? If not, could consider just using the official github mirror by default. List of closed bugs may not be complete, plans are to recheck still-open bugs after this is merged. Bug: https://bugs.gentoo.org/830165 Closes: https://bugs.gentoo.org/654118 Closes: https://bugs.gentoo.org/695210 Closes: https://bugs.gentoo.org/733556 Closes: https://bugs.gentoo.org/752507 Closes: https://bugs.gentoo.org/770439 Closes: https://bugs.gentoo.org/778035 Closes: https://bugs.gentoo.org/865201 Closes: https://bugs.gentoo.org/868471 Closes: https://bugs.gentoo.org/903754 Closes: https://bugs.gentoo.org/915384 Closes: https://bugs.gentoo.org/916067 Closes: https://bugs.gentoo.org/918613 Closes: https://bugs.gentoo.org/918989 Closes: https://bugs.gentoo.org/920283 Closes: https://bugs.gentoo.org/920808 Closes: https://bugs.gentoo.org/921313 Closes: https://bugs.gentoo.org/922333 Closes: https://bugs.gentoo.org/922433 Closes: https://bugs.gentoo.org/934196 Closes: https://bugs.gentoo.org/941506 Closes: https://bugs.gentoo.org/947253 Signed-off-by: Ionen Wolkens <ionen@gentoo.org> media-video/ffmpeg/ffmpeg-9999.ebuild | 1014 +++++++++++++--------------- media-video/ffmpeg/files/chromium-r3.patch | 53 ++ media-video/ffmpeg/metadata.xml | 8 + 3 files changed, 538 insertions(+), 537 deletions(-)