Nvidia vdpau with mplayer

Hello,

Trying to play a video with VDPAU support. I have a RTX 2080 card. Currently trying mplayer, but so far without success.

I followed these instructions: Nvidia - NixOS Wiki

vdpauinfo reports valid data:

$ vdpauinfo
display: :0   screen: 0
API version: 1
Information string: NVIDIA VDPAU Driver Shared Library  545.29.02  Thu Oct 26 20:50:07 UTC 2023

Video surface:

name   width height types
-------------------------------------------
420     8192  8192  NV12 YV12
422     8192  8192  UYVY YUYV
444     8192  8192  NV24 YV24
420_16  8192  8192  P010 P016
422_16  8192  8192  UYVY YUYV
444_16  8192  8192  Y_U_V_444_16

Decoder capabilities:

name                        level macbs width height
----------------------------------------------------
MPEG1                           0 65536  4096  4096
MPEG2_SIMPLE                    3 65536  4096  4096
MPEG2_MAIN                      3 65536  4096  4096
H264_BASELINE                  51 65536  4096  4096
H264_MAIN                      51 65536  4096  4096
H264_HIGH                      51 65536  4096  4096
VC1_SIMPLE                      1  8190  2048  2048
VC1_MAIN                        2  8190  2048  2048
VC1_ADVANCED                    4  8190  2048  2048
MPEG4_PART2_SP                  3  8192  2048  2048
MPEG4_PART2_ASP                 5  8192  2048  2048
DIVX4_QMOBILE                   0  8192  2048  2048
DIVX4_MOBILE                    0  8192  2048  2048
DIVX4_HOME_THEATER              0  8192  2048  2048
DIVX4_HD_1080P                  0  8192  2048  2048
DIVX5_QMOBILE                   0  8192  2048  2048
DIVX5_MOBILE                    0  8192  2048  2048
DIVX5_HOME_THEATER              0  8192  2048  2048
DIVX5_HD_1080P                  0  8192  2048  2048
H264_CONSTRAINED_BASELINE      51 65536  4096  4096
H264_EXTENDED                  51 65536  4096  4096
H264_PROGRESSIVE_HIGH          51 65536  4096  4096
H264_CONSTRAINED_HIGH          51 65536  4096  4096
H264_HIGH_444_PREDICTIVE       51 65536  4096  4096
VP9_PROFILE_0                   1 262144  8192  8192
VP9_PROFILE_1                  --- not supported ---
VP9_PROFILE_2                   1 262144  8192  8192
VP9_PROFILE_3                  --- not supported ---
HEVC_MAIN                      153 262144  8192  8192
HEVC_MAIN_10                   153 262144  8192  8192
HEVC_MAIN_STILL                --- not supported ---
HEVC_MAIN_12                   153 262144  8192  8192
HEVC_MAIN_444                  153 262144  8192  8192
HEVC_MAIN_444_10               153 262144  8192  8192
HEVC_MAIN_444_12               153 262144  8192  8192
AV1_MAIN                       --- not supported ---
AV1_HIGH                       --- not supported ---
AV1_PROFESSIONAL               --- not supported ---

Output surface:

name              width height nat types
----------------------------------------------------
B8G8R8A8         32768 32768    y  Y8U8V8A8 V8U8Y8A8 A4I4 I4A4 A8I8 I8A8
R10G10B10A2      32768 32768    y  Y8U8V8A8 V8U8Y8A8 A4I4 I4A4 A8I8 I8A8

Bitmap surface:

name              width height
------------------------------
B8G8R8A8         32768 32768
R8G8B8A8         32768 32768
R10G10B10A2      32768 32768
B10G10R10A2      32768 32768
A8               32768 32768

Video mixer:

feature name                    sup
------------------------------------
DEINTERLACE_TEMPORAL             y
DEINTERLACE_TEMPORAL_SPATIAL     y
INVERSE_TELECINE                 y
NOISE_REDUCTION                  y
SHARPNESS                        y
LUMA_KEY                         y
HIGH QUALITY SCALING - L1        y
HIGH QUALITY SCALING - L2        -
HIGH QUALITY SCALING - L3        -
HIGH QUALITY SCALING - L4        -
HIGH QUALITY SCALING - L5        -
HIGH QUALITY SCALING - L6        -
HIGH QUALITY SCALING - L7        -
HIGH QUALITY SCALING - L8        -
HIGH QUALITY SCALING - L9        -

parameter name                  sup      min      max
-----------------------------------------------------
VIDEO_SURFACE_WIDTH              y         1     8192
VIDEO_SURFACE_HEIGHT             y         1     8192
CHROMA_TYPE                      y
LAYERS                           y         0        4

attribute name                  sup      min      max
-----------------------------------------------------
BACKGROUND_COLOR                 y
CSC_MATRIX                       y
NOISE_REDUCTION_LEVEL            y      0.00     1.00
SHARPNESS_LEVEL                  y     -1.00     1.00
LUMA_KEY_MIN_LUMA                y
LUMA_KEY_MAX_LUMA                y

But mplayer mplayer -vo vdpau says Error opening/initializing the selected video_out (-vo) device..

Trying mpv. At first glance, appears to be better. But: mpv -vo xv 2Y4A6239.MP4 seems to use just as much CPU (around 70%-80%) as mpv -vo gpu 2Y4A6239.MP4.

(note: mpv recommends gpu over vdpau)

So not really convinced it is working.

Have you tried other options?

According to the hwdec section of the mpv docs:

nvdec and nvdec-copy are the newest, and recommended method to do hardware decoding on Nvidia GPUs.

Also in the video-output-drivers section on vdpau:

vdpau (X11 only)

Uses the VDPAU interface to display and optionally also decode video. Hardware decoding is used with --hwdec=vdpau. Note that there is absolutely no reason to use this, other than compatibility. We strongly recommend that you use --vo=gpu with --hwdec=nvdec instead.

To check if hardware decoding is working and which one is being used, just press i:

i and I
Show/toggle an overlay displaying statistics about the currently playing file such as codec, framerate, number of dropped frames and so on. See STATS for more information.

You’ll see a Video entry and HW: <codec name> besides it if everything is working fine.

PS: You can put multiple codecs to fall back to when one can’t be used, for example:
hwdec=nvdec,nvdec-copy,vaapi,vaapi-copy,auto

1 Like

Oh, I completely missed the --hwdec option. Looks like with mpv -vo gpu --hwdec=nvdec 2Y4A6395.MP4 I can now play 8k video. Wow. (although I only have 4k monitors…)

To check if hardware decoding is working and which one is being used, just press i:

That is good to now. Although on my system it displays as (hwdec: nvdec).

PS: You can put multiple codecs to fall back to when one can’t be used, for example:
hwdec=nvdec,nvdec-copy,vaapi,vaapi-copy,auto

That is also really good to know.

Thanks for your help. I really thought I had some sort of low level nvidia driver issue, seems I just wasn’t using the correct command line arguments.

1 Like

Glad I could help.

As a bonus, you can also set these options in ~/.config/mpv/mpv.conf and you won’t have to retype them from the command line:

# mpv.conf
vo=gpu
hwdec=nvdec,nvdec-copy,vaapi,vaapi-copy,auto
hwdec-codecs=h264,vc1,hevc,av1

You can also explicitly specify which codecs you want to have hardware decoding with hwdec-codecs.

There are a lot of things that you can do with mpv, and that’s why I like it so much. It’s minimal, performant and really extensible.

If you’re new to mpv and you’d like to know more, you can read this post which has a nice overview and links to some useful resources.

1 Like