mpv-player / mpv

🎥 Command line video player
https://mpv.io
Other
28.51k stars 2.92k forks source link

Playback always falls back to nvdec-copy when ffnvcodec headers are not installed during build #11004

Closed fulalas closed 1 month ago

fulalas commented 1 year ago

mpv version and platform versions

mpv 0.35.0 ffmpeg 4.4.1 NVIDIA GeForce GTX 1650 SUPER with driver 510.60.02 Porteus 5.0 x64 distro

Reproduction steps

When building mpv against ffmpeg that was compiled with --enable-nvenc, mpv doesn't complain if it doesn't find ffnvcodec headers and the result is that when playing videos it always falls back to nvdec-copy, skipping nvdec.

This issue was mentioned here.

Expected behavior

During configure, if mpv detects that ffmpeg was compiled using --enable-nvenc it should warn if it doesn't find ffnvcodec headers.

Actual behavior

Mpv doesn't inform anything and when playing back videos it always falls back to nvdec-copy.

Log file

Checking for waf version in 1.8.4-2.1.0  : ok 
Checking for program 'cc'                : /usr/bin/cc 
Checking for program 'pkg-config'        : /usr/bin/pkg-config 
Checking for program 'ar'                : /usr/bin/ar 
Checking for program 'rst2html'          : not found 
Checking for program 'rst2man'           : not found 
Checking for program 'rst2pdf'           : not found 
Checking for program 'windres'           : /usr/bin/windres 
Checking for program 'perl'              : /usr/bin/perl 
Checking for 'gcc' (C compiler)          : /usr/bin/cc 
Detected target OS:                      : os-linux 
Checking for compiler flags -std=c11     : yes 
Checking for compiler flags -Werror -Werror=implicit-function-declaration : yes 
Checking for compiler flags -Werror -Wno-error=deprecated-declarations    : yes 
Checking for compiler flags -Werror -Wno-error=unused-function            : yes 
Checking for compiler flags -Werror -Wempty-body                          : yes 
Checking for compiler flags -Werror -Wdisabled-optimization               : yes 
Checking for compiler flags -Werror -Wstrict-prototypes                   : yes 
Checking for compiler flags -Werror -Wno-format-zero-length               : yes 
Checking for compiler flags -Werror -Werror=format-security               : yes 
Checking for compiler flags -Werror -Wno-redundant-decls                  : yes 
Checking for compiler flags -Werror -Wvla                                 : yes 
Checking for compiler flags -Werror -Wno-format-truncation                : yes 
Checking for compiler flags -Werror -Wimplicit-fallthrough                : yes 
Checking for compiler flags -Werror -fno-math-errno                       : yes 
Checking for LGPL (version 2.1 or later) build                            : disabled 
Checking for GPL (version 2 or later) build                               : yes 
Checking for mpv CLI player                                               : yes 
Checking for shared library                                               : yes 
Checking for static library                                               : disabled 
Checking for static build                                                 : disabled 
Checking for whether to include binary compile time                       : yes 
Checking for whether to optimize                                          : yes 
Checking for whether to compile-in debugging information                  : yes 
Checking for unit tests (development only)                                : disabled 
Checking for enable ta leak report by default (development only)          : disabled 
Checking for manpage generation                                           : no (missing RST2MAN) 
Checking for html manual generation                                       : disabled 
Checking for pdf manual generation                                        : disabled 
Checking for dynamic loader                                               : yes 
Checking for C plugins                                                    : yes 
Checking for inline assembly (currently without effect)                   : yes 
Checking for GCC vector instructions                                      : yes 
Checking for generate a clang compilation database                        : disabled 
Checking for static Swift linking                                         : disabled 
Checking for compiler support for noexecstack                             : yes 
Checking for linker support for --nxcompat --no-seh --dynamicbase         : no 
Checking for -lm                                                          : yes 
Checking for MinGW                                                        : os-win32 not found 
Checking for POSIX environment                                            : yes 
Checking for Android environment                                          : no 
Checking for Android Media APIs                                           : android not found 
Checking for tvOS environment                                             : no 
Checking for Android EGL support                                          : android not found 
Checking for development environment                                      : yes 
Checking for macOS Swift build tools                                      : os-darwin not found 
Checking for Universal Windows Platform                                   : disabled 
Checking for win32 desktop APIs                                           : os-win32 not found 
Checking for internal pthread wrapper for win32 (Vista+)                  : posix found 
Checking for POSIX threads                                                : yes 
Checking for pthread runtime debugging wrappers                           : disabled 
Checking for C11 stdatomic.h                                              : yes 
Checking for linking with -lrt                                            : yes 
Checking for iconv                                                        : yes 
Checking for w32/dos paths                                                : os-win32 not found 
Checking for glob() POSIX support                                         : yes 
Checking for glob() win32 replacement                                     : posix found 
Checking for any glob() support                                           : yes 
Checking for vt.h                                                         : yes 
Checking for consio.h                                                     : vt.h found 
Checking for gbm.h                                                        : yes 
Checking for GLIBC API for setting thread name                            : yes 
Checking for OSX API for setting thread name                              : glibc-thread-name found 
Checking for BSD API for setting thread name                              : glibc-thread-name found 
Checking for BSD's fstatfs()                                              : no 
Checking for Linux's fstatfs()                                            : yes 
Checking for Linux's input-event-codes.h                                  : yes 
Checking for Lua                                                          : yes (version found: luadef51) 
Checking for Javascript (MuJS backend)                                    : no ('mujs >= 1.0.0' not found) 
Checking for SSA/ASS support                                              : yes 
Checking for zlib                                                         : yes 
Checking for Bluray support                                               : yes 
Checking for dvdnav support                                               : yes 
Checking for cdda support (libcdio)                                       : yes 
Checking for uchardet support                                             : no ('uchardet' not found) 
Checking for librubberband support                                        : no ('rubberband >= 1.8.0' not found) 
Checking for libzimg support (high quality software scaler)               : no ('zimg >= 2.9' not found) 
Checking for LCMS2 support                                                : yes 
Checking for VapourSynth filter bridge                                    : no ('vapoursynth >= 24 vapoursynth-script >= 23' not found) 
Checking for libarchive wrapper for reading zip files and more            : yes 
Checking for DVB input module                                             : yes 
Checking for SDL2                                                         : disabled 
Checking for SDL2 gamepad input                                           : sdl2 not found 
Checking for JPEG XL support via libavcodec                               : no ('libavcodec >= 59.27.100' not found) 
Checking for new engine support for librubberband                         : no ('rubberband >= 3.0.0' not found) 
Checking for FFmpeg library                                               : yes 
Checking for FFmpeg AVChannelLayout API                                   : no ('libavutil >= 57.24.100' not found) 
Checking for libavdevice                                                  : yes 
Checking for SDL2 audio output                                            : sdl2 not found 
Checking for OSSv4 audio output                                           : no 
Checking for PipeWire audio output                                        : no ('libpipewire-0.3 >= 0.3.19' not found) 
Checking for sndio audio input/output                                     : disabled 
Checking for PulseAudio audio output                                      : yes 
Checking for JACK audio output                                            : no ('jack' not found) 
Checking for OpenAL audio output                                          : disabled 
Checking for OpenSL ES audio output                                       : no 
Checking for ALSA audio output                                            : yes 
Checking for CoreAudio audio output                                       : no 
Checking for AudioUnit output for iOS                                     : no 
Checking for WASAPI audio output                                          : os-win32 not found 
Checking for SDL2 video output                                            : sdl2 not found 
Checking for Cocoa                                                        : no 
Checking for DRM                                                          : yes 
Checking for GBM                                                          : yes 
Checking for wayland-scanner                                              : yes 
Checking for wayland-protocols                                            : yes 
Checking for Wayland                                                      : yes 
Checking for wayland-protocols version 1.24+                              : yes 
Checking for Linux's memfd_create()                                       : yes 
Checking for X11                                                          : yes 
Checking for Xv video output                                              : yes 
Checking for OpenGL Cocoa Backend                                         : cocoa not found 
Checking for OpenGL X11/GLX (deprecated/legacy)                           : disabled 
Checking for Raspberry Pi support                                         : disabled 
Checking for EGL 1.4                                                      : yes 
Checking for OpenGL X11 EGL Backend                                       : yes 
Checking for OpenGL DRM EGL Backend                                       : yes 
Checking for OpenGL Wayland Backend                                       : yes 
Checking for OpenGL Win32 Backend                                         : win32-desktop not found 
Checking for OpenGL/DirectX Interop Backend                               : gl-win32 not found 
Checking for OpenGL ANGLE headers                                         : os-win32 not found 
Checking for OpenGL Win32 ANGLE Library                                   : egl-angle not found 
Checking for OpenGL Win32 ANGLE Backend                                   : egl-angle not found 
Checking for VDPAU acceleration                                           : yes 
Checking for VDPAU with OpenGL/X11                                        : gl-x11 not found 
Checking for VAAPI acceleration                                           : yes 
Checking for VAAPI (X11 support)                                          : yes 
Checking for VAAPI (Wayland support)                                      : yes 
Checking for Wayland dmabuf support                                       : yes 
Checking for VAAPI (DRM/EGL support)                                      : yes 
Checking for VAAPI EGL on X11                                             : yes 
Checking for VAAPI EGL                                                    : yes 
Checking for CACA                                                         : yes 
Checking for JPEG support                                                 : yes 
Checking for Direct3D support                                             : win32-desktop not found 
Checking for libshaderc SPIR-V compiler (shared library)                  : no ('shaderc' not found) 
Checking for libshaderc SPIR-V compiler (static library)                  : no ('shaderc_static' not found) 
Checking for libshaderc SPIR-V compiler                                   : shaderc-shared not found 
Checking for SPIRV-Cross SPIR-V shader converter (shared library)         : no ('spirv-cross-c-shared' not found) 
Checking for SPIRV-Cross SPIR-V shader converter (static library)         : no ('spirv-cross' not found) 
Checking for SPIRV-Cross SPIR-V shader converter                          : spirv-cross-shared not found 
Checking for Direct3D 11 video output                                     : win32-desktop not found 
Checking for iOS OpenGL ES hardware decoding interop support              : no 
Checking for OpenGL without platform-specific code (e.g. for libmpv)      : yes 
Checking for OpenGL context support                                       : yes 
Checking for libplacebo support                                           : no ('libplacebo >= 4.157.0' not found) 
Checking for libplacebo v4.202+, needed for vo_gpu_next                   : libplacebo not found 
Checking for Vulkan context support                                       : libplacebo not found 
Checking for VAAPI libplacebo                                             : libplacebo not found 
Checking for EGL helper functions                                         : yes 
Checking for Sixel                                                        : no ('libsixel >= 1.5' not found) 
Checking for dmabuf GL Interop                                            : yes 
Checking for dmabuf libplacebo interop                                    : vaapi-libplacebo not found 
Checking for drmIsKMS() function                                          : yes 
Checking for libavcodec videotoolbox hwaccel                              : gl-cocoa not found 
Checking for Videotoolbox with OpenGL                                     : gl-cocoa not found 
Checking for D3D11VA hwaccel                                              : os-win32 not found 
Checking for DXVA2 hwaccel                                                : d3d-hwaccel not found 
Checking for OpenGL/DirectX Interop Backend DXVA2 interop                 : gl-dxinterop not found 
Checking for CUDA Headers and dynamic loader                              : no ('ffnvcodec >= 8.2.15.7' not found) 
Checking for CUDA acceleration                                            : ffnvcodec not found 
Checking for CUDA with graphics interop                                   : cuda-hwaccel not found  
Checking for Raspberry Pi MMAL hwaccel                                    : rpi not found 
Checking for w32 executable                                               : os-win32 not found 
Checking for macOS Touch Bar support                                      : cocoa not found 
Checking for macOS 10.11 SDK Features                                     : cocoa not found 
Checking for macOS 10.12.2 SDK Features                                   : cocoa not found 
Checking for macOS 10.14 SDK Features                                     : cocoa not found 
Checking for macOS Media Player support                                   : macos-10-12-2-features not found 
Checking for macOS libmpv backend                                         : cocoa not found 
Writing configuration header:                                             : config.h 
'configure' finished successfully (1.594s)
Dudemanguy commented 1 year ago

Sure making the check fail in waf and meson if the headers are not installed is easy enough. Although does anyone actually know why the headers need to be there? Seems unintuitive for me.

philipl commented 1 year ago

What's the bug? hwdec=nvdec requires those headers because the interop uses cuda directly. hwdec=nvdec-copy does not. It only requires FFmpeg to have been built with nvdec support. So if you want nvdec, you build with headers. We use the headers if they are present automatically.

philipl commented 1 year ago

Also, your waf output says it found the headers:

Checking for CUDA Headers and dynamic loader                              : yes 
Checking for CUDA acceleration                                            : yes 
Checking for CUDA with graphics interop                                   : yes 

What we would expect to happen is that the if the headers are missing, it will fail the first check and then it will not compile in nvdec support and if you try to use --hwdec=nvdec, it will fail as an unrecognised choice.

fulalas commented 1 year ago

@philipl, you're right. I pasted the output when the headers were installed. It's fixed now.

I'm just wondering if we could better inform that when missing ffnvcodec headers mpv will always fallback to nvdec-copy (when a nvidia card is presented). It took me a long time to find out that and it's not just me (e.g. https://github.com/mpv-player/mpv/issues/10839). Maybe an entry like this:

Checking for nvdec acceleration : nvdec-hwaccel not found

philipl commented 1 year ago

It's because the options are not named with nvdec, but they are there. If you want to fail if you can't build with nvdec support, you would pass -Dcuda-interop=enabled to meson and it would fail without headers.

kasper93 commented 1 month ago

Works as expected. No headers, no nvdec.