Bug 31116

Summary: Enable nvenc support in ffmpeg
Product: Mageia Reporter: Oleg Bosis <olelukoie>
Component: RPM PackagesAssignee: Stig-Ørjan Smelror <smelror>
Status: NEW --- QA Contact:
Severity: enhancement    
Priority: Normal    
Version: 8   
Target Milestone: Mageia 9   
Hardware: x86_64   
OS: Linux   
Whiteboard: MGA9TOO
Source RPM: ffmpeg-4.3.5-1.mga8 CVE:
Status comment:
Attachments: Add options to build nvenc

Description Oleg Bosis 2022-11-13 19:15:05 CET
Description of problem:
I sometimes use OBS Studio to record my desktop and I've noticed that OBS Studio installed from flatpak allows me to use nvenc-enabled codecs to record videos while the version from MGA8 repo doesn't.

OBS Studio uses ffmpeg (among other external encodes) to encode videos and it appeared that mageia's ffmpeg package doesn't have nvenc enabled.

Everything that is needed to enable nvenc in ffmpeg is already in mga repo, it just needs to be enabled in ffmpeg:

1. Add two BRs: clang and nv-codec-headers
2. Add three configure options: --enable-nonfree --enable-cuda-llvm --enable-nvenc

Version-Release number of selected component (if applicable):
ffmpeg-4.3.5-1.mga8

How reproducible:
Always

Steps to Reproduce:
1. Run OBS Studio
2. Open Settings->Output->Recording tab
3. Select "Custom output (FFmpeg)" in "Type" list
4. Select  some universal containter (I use matroska) in"Container format" list
5. Open "Video encoder" list and try to find any codec with nvenc in its name. You should see "h264_nvenc (libx264)" (and maybe a couple of other ones) if nvenc is enabled in ffmpeg and you won't see it if nvenc is disabled.

Way to check:

$ffmpeg -hide_banner -encoders | grep nv

If the output is empty then nvenc is not enabled. If it is enabled then the output should look like the following:

 V..... h264_nvenc           NVIDIA NVENC H.264 encoder (codec h264)
 V..... nvenc                NVIDIA NVENC H.264 encoder (codec h264)
 V..... nvenc_h264           NVIDIA NVENC H.264 encoder (codec h264)
 V..... nvenc_hevc           NVIDIA NVENC hevc encoder (codec hevc)
 V..... hevc_nvenc           NVIDIA NVENC hevc encoder (codec hevc)
Comment 1 David Walser 2022-11-14 19:06:11 CET
We can't have packages that are both nonfree and tainted, and not everyone has an NVIDIA card.  This is probably not something we can do in our packages.
Comment 2 Oleg Bosis 2022-11-14 20:17:02 CET
(In reply to David Walser from comment #1)
> We can't have packages that are both nonfree and tainted, and not everyone
> has an NVIDIA card.  This is probably not something we can do in our
> packages.

Then you should also remove nv-codec-headers package as it doesn't work with nouveau driver and requires cuda-enbled nvidia drivers. And BTW why this package was put into core repository instead of non-free one?

On the other hand there is no need to add any new "requires" for nvenc. This codec just reports there is no supported hardware on any non-nvenc-supporting videocard (tested with GF 1030 that lacks nvenc support).
Comment 3 Lewis Smith 2022-11-20 14:47:25 CET
> Then you should also remove nv-codec-headers package as it doesn't work
> with nouveau driver and requires cuda-enbled nvidia drivers. And BTW why
> this package was put into core repository instead of non-free one?
nv-codec-headers-11.0.10.0-3.mga8.src.rpm
Summary     : FFmpeg version of Nvidia Codec SDK headers
Description :
FFmpeg version of headers required to interface with Nvidias codec APIs.

Last question seems legitimate (cure v non-free).
The original request also looks reasonable, but the technicalities raised by DavidW probably need discussion (dev ML) before deciding. If this M8 request does get honoured, it should be carried forward to Cauldron also.

Assigning to Stig who nurses ffmpeg.

Assignee: bugsquad => smelror
Target Milestone: --- => Mageia 9
Whiteboard: (none) => MGA9TOO

Comment 4 Oleg Bosis 2023-05-06 13:34:40 CEST
Created attachment 13807 [details]
Add options to build nvenc

As far as there is no any decision was made until now I've made a patch to ease custom build of ffmpeg (patch against current cauldron ffmpeg version 5.1.3).

The approach is the same as for fdkaac and also adds _with_nonfree build option to enable both fdkaac and nvenc at once.

I'm not sure about BR on Vulkan: shouldn't it be enabled globally and unconditionally? There are several video filters with Vulkan variants (say vf_scale_vulkan.c or vf_overlay_vulkan.c) that seem to be neither tainted nor non-free ones and should work with any Vulkan-enabled hardware.