Saturday, January 30, 2016

vaapi and vdpau api's - dvd playback

Using VLC, I recently played a commercial 2 DVD set (720P) on a reliable optical drive. One DVD chapter would not play and the disk appeared to have a small scratch. Before returning it for a refund, I thought I should try something besides VLC to rule-out those random situations where it's a software glitch. The command line version of Mplayer used to be a great equalizer, for example. However, I don't know VAAPI and VDPAU parameters, or say, XvMC. Situation seemed worthy of a trail of crumbs here.


It's important to know one's hardware in this situation. To my understanding, VAAPI is a native Intel API, VDPAU is a native NVidia API.
$ lspci |grep -i vga
01:05.0 VGA compatible controller: Advanced Micro Devices, Inc. [AMD/ATI] RS780MC [Mobility Radeon HD 3100]
And so of course, I get "Radeon", lol. At any rate, both VDPAU and VAAPI pass video encoding to a GPU from a CPU. Each is available to any software (scroll down), though some software is crafted with a preference. There is a lot of information out there that we don't want to use VDPAU as a wrapper, and should pick native VAAPI or VDPAU, not a wrapper accessed through the other. Then configure all software to work on that basis.

settings beyond the API

Besides the API, another playback parameter is setting cache and framedrop flags when running Mplayer. Running VLC, playback was clean, except that it paused on the scratched disc. Using Mplayer, I experienced no pauses, but had tearing or pixellation throughout, aka, a configuration issue.


$ mplayer dvd:// /dev/sr0 -nosound -framedrop
[pixellation, tearing, sync errors]

$ strace mplayer dvd:// /dev/sr0 -nosound -framedrop &> vidfail.txt

$ grep -in "vidp*" vidfail.txt
3136:open("/usr/lib/vdpau/", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
3141:open("/usr/lib/", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
3143:write(2, "Failed to open VDPAU backend lib"..., 105Failed to open VDPAU backend cannot open shared object file: No such file or directory
3145:write(2, "[vdpau] Error when calling vdp_d"..., 52[vdpau] Error when calling vdp_device_create_x11: 1

$ find -name "libvd*"

vaapi checks

VAAPI is less desirable these days, for example according to this post. But we can check to see if it's operational, in case we had MPlayer or VLC configured to use it -- it might explain the fail.
$ vainfo
libva info: VA-API version 0.38.0
libva info: va_getDriverName() returns 0
libva info: Trying to open /usr/lib/dri/
libva info: va_openDriver() returns -1
vaInitialize failed with error code -1 (unknown libva error),exit
In this case, we see that VAAPI is not loading VDPAU, which VAAPI can only use as a wrapper. We know this because r600 is part of VDPAU, typically loaded along with Mesa or GStreamer. It appears the order of loading ins VAAPI, then an attempt to call the VDPAU wrapper. We know this because:
$ vlc --avcodec-hw=/usr/lib/xorg/modules/dri/ video.mp4
VLC media player 2.2.1 Terry Pratchett (Weatherwax) (revision 2.2.1-0-ga425c42)
Failed to open VDPAU backend cannot open shared object file: No such file or directory.
I'm pointing VLC directly at the lib, yet it continues not to "exist". It appears VAAPI is loading but can't find this backend lib, even with a path supplied. This will require additional investigation.

vdpau checks

$ grep -i vdpau ~/.local/share/xorg/Xorg.0.log
[ 34.798] (II) RADEON(0): [DRI2] VDPAU driver: r600
I see the r600 driver is there, and is apparently operational. Not that I care about wrappers, but the reason VAAPI cannot find VDPAU to use as a wrapper, is I probably do not have a line to export the VDPAU variable export VDPAU_DRIVER=r600 in my ~/.bashrc file. Since I know r600 is operational, I merely need to configure VLC and MPLayer to work exclusively with VDPAU, or install gallium.

No comments: