Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have a laptop with a discrete Nvidia graphics card .

How can I know if my video player be it mplayer or vlc or totem is using nvidia VDPAU or not? For example, running mplayer2 with the script below, I get this message:

Failed to open VDPAU backend libvdpau_nvidia.so: cannot open shared object file: No such file or directory

But I do have such file in the system:

-rw-r--r-- 1 root root 1800952 2011-11-23 07:39 /usr/lib/nvidia-current/vdpau/libvdpau_nvidia.so.290.10

Script to find out codec for a file:

    #!/bin/bash
#Script to automatically find out which codec a file is using and determine whether or not to use VDPAU.

#if no input display usage
if [ -z "$1" ]; then
    echo usage: $0 /path/to/file
    exit
fi

#remember to change this to the path of your mplayer binary
mplayerlocation=/usr/bin/
cd $mplayerlocation

#kinda a lame way to do it, but bring up mplayer and pipe the output to a temporary file, then read which codec the file is
./mplayer -identify -vo vdpau $1 > /tmp/VIDEOCODEC &
sleep 0.5
killall mplayer
videocodec=`cat /tmp/VIDEOCODEC | grep ID_VIDEO_CODEC | cut -c 16-25`
rm /tmp/VIDEOCODEC

echo "VIDEO CODEC: $videocodec"

if [ $videocodec = "ffh264" ]; then
    codec='h264'
    echo \n Playing $1 with $codec codec \n
    ./mplayer -vo vdpau -vc ffh264vdpau $1

    exit
fi

if [ $videocodec = "ffmpeg2" ]; then
    codec='MPEG2'
    echo \n Playing $1 with $codec codec \n
    ./mplayer -vo vdpau -vc ffmpeg12vdpau $1

    exit
fi

if [ $videocodec = "ffwmv3" ]; then
    codec='WMV3'
    echo \n Playing $1 with $codec codec \n
    ./mplayer -vo vdpau -vc ffwmv3vdpau $1

    exit
fi

#VC1 is not supported on most gpus
#uncomment if it is supported on your gpu
#if [ $videocodec = "ffvc1" ]; then
#   codec='VC1'
#   echo \n Playing $1 with $codec codec \n
#   ./mplayer -vo vdpau -vc ffvc1vdpau $1
#
#   exit
#fi

#if it isnt one of those it is not supported by vdpau
#so we should play without vdpau
./mplayer $1
exit

EDIT: apparently it can't find the library, not even when calling it via bumblebee's v3 optirun, although the library is there:

optirun vdpauinfo 
display: :0.0   screen: 0
Failed to open VDPAU backend libvdpau_nvidia.so: cannot open shared object file: No such file or directory
Error creating VDPAU device: 1
avilella@magneto:~$ locate libvdpau_nvidia.so | xargs ls
/usr/lib/nvidia-current/vdpau/libvdpau_nvidia.so  /usr/lib/nvidia-current/vdpau/libvdpau_nvidia.so.1  /usr/lib/nvidia-current/vdpau/libvdpau_nvidia.so.290.10

EDIT2: I tried again with Ubuntu 12.04 and I still can't get it to work.

share|improve this question
    
For example, for mplayer, I get a: [vdpau] Error when calling vdp_device_create_x11: 1 –  213441265152351 May 30 '11 at 10:47
    
Possibly related: askubuntu.com/questions/100786/… –  Bruno Pereira Feb 6 '12 at 23:32
    
I tried again with Ubuntu 12.04 and I still can't get it to work. –  213441265152351 May 16 '12 at 8:39

4 Answers 4

up vote 9 down vote accepted
+300

To address your question & a bit on enabling gpu decoding with mplayer or vlc.

Mplayer

The easiest way to see if you are getting gpu decoding thru vdpau is to do what you've done - run mplayer from a terminal. Atm what you've shown indicates you're not getting it.

The requisites for mplayer are:

mplayer or mplayer 2

nvidia-current or the nvidia drivers directly from nvidia, the nvidia-current package will do.

libvdpau

Make sure you've meet the above, then run the command you did before, though make sure the video is h.264

Ex. of terminal output, removed irrelevant lines

$ mplayer  -vo vdpau -vc ffh264vdpau /home/doug/Videos/sintel.mp4 
MPlayer2 UNKNOWN (C) 2000-2011 MPlayer Team
Playing /home/doug/Videos/sintel.mp4.
Detected file format: QuickTime/MPEG-4/Motion JPEG 2000 format (libavformat)
[lavf] stream 0: video (h264), -vid 0
[lavf] stream 1: audio (aac), -aid 0, -alang und
VIDEO:  [H264]  1280x546  24bpp  24.000 fps  1597.2 kbps (195.0 kbyte/s)
==========================================================================
Forced video codec: ffh264vdpau
Opening video decoder: [ffmpeg] FFmpeg's libavcodec codec family
Selected video codec: [ffh264vdpau] vfm: ffmpeg (FFmpeg H.264 (VDPAU))
VO: [vdpau] 1280x546 => 1280x546 H.264 VDPAU acceleration 
[vdpau] Got display refresh rate 59.991 Hz.

If you do support/get vdpau thru mplayer you can set a vc= line in ~/.mplayer/config to auto check & use the appropriate ffvdpau* decoder for supported codecs

Another way to check is to use vdpauinfo. The package is only available in 12.04 but can be installed in 11.10. To do so go here, download & install with gdebi, though software center may install for you if you wish to try

http://packages.ubuntu.com/precise/vdpauinfo

To use open a terminal & run vdpauinfo

Ex. of some of the output of vdpauinfo on a laptop with basic vdpau support

$ vdpauinfo
display: :0   screen: 0
API version: 1
Information string: NVIDIA VDPAU Driver Shared Library  280.13  Wed Jul 27 17:18:15 PDT 2011

Video surface:

name   width height types
 -------------------------------------------
420     4096  4096  NV12 YV12 
422     4096  4096  UYVY YUYV 

Decoder capabilities:

name               level macbs width height
-------------------------------------------
MPEG1                 0  8192  2048  2048
MPEG2_SIMPLE          3  8192  2048  2048
MPEG2_MAIN            3  8192  2048  2048
H264_MAIN            41  8192  2048  2048
H264_HIGH            41  8192  2048  2048
VC1_SIMPLE            1  8190  2048  2048
VC1_MAIN              2  8190  2048  2048
VC1_ADVANCED          4  8190  2048  2048

Vlc

If you have nvidia hardware & can't or don't have vdpau support then don't bother with vlc which uses vaapi & is tricker to enable. Additionally the performance of vaapi on nvidia is very much hardware dependent. I've enabled here but don't use, ffmpeg multi-thread is better with my hardware in vlc.

This is just the basics of getting vaapi & enabling in vlc. For specifics you'd need to search & or ask how .

The requisites for vlc are:

vlc & ffmpeg shared libs that have vaapi support, 11.10 is good there.

libva1, also install libva-x11-1 vainfo

vdpau-va-driver

Your biggest issue may be that ubuntu's versions of libva* & vdpau-va-driver aren't new enough, you'll need to get further advice there. In 12.04 they are adequate

Running vainfo in a terminal should tell you where you stand

Ex. here of vainfo

$ vainfo
libva: libva version 0.32.0
Xlib:  extension "XFree86-DRI" missing on display ":0.0".
libva: va_getDriverName() returns 0
libva: Trying to open /usr/lib/dri/nvidia_drv_video.so
libva: va_openDriver() returns 0
vainfo: VA API version: 0.32
vainfo: Driver version: Splitted-Desktop Systems VDPAU backend for VA-API - 0.7.3
vainfo: Supported profile and entrypoints
  VAProfileMPEG2Simple            : VAEntrypointVLD
  VAProfileMPEG2Main              : VAEntrypointVLD
  VAProfileH264Main               : VAEntrypointVLD
  VAProfileH264High               : VAEntrypointVLD
  VAProfileVC1Simple              : VAEntrypointVLD
  VAProfileVC1Main                : VAEntrypointVLD
  VAProfileVC1Advanced            : VAEntrypointVLD

To enable gpu decoding in vlc thru vaapi & ffmpeg, two ways

From a terminal, no need to set in preferences

vlc --ffmpeg-hw /path/to/supported/video/name

To set in vlc's gui, the prior posts are incorrect as to how, actual way is shown in screen

Tools > Preferences > Input/Codecs > check the box, reading up on "Skip H.264 in-loop deblocking filter" may prove worthwhile

enter image description here

Ex. from terminal of vlc gpu decoding thru vaapi, using the repo vlc in 12.04 though 1.2/1.3/2.0 are preferred versions, a ppa for 2.0 should be available if desired

vlc --ffmpeg-hw '/home/doug/Videos/sintel.mp4' 
VLC media player 1.1.13 The Luggage (revision exported)
clipped .....

libva: libva version 0.32.0
Xlib:  extension "XFree86-DRI" missing on display ":1".
libva: va_getDriverName() returns 0
libva: Trying to open /usr/lib/dri/nvidia_drv_video.so
libva: va_openDriver() returns 0
[0x863468c] avcodec decoder: Using VA API version 0.32 for hardware decoding.
share|improve this answer
    
Not even when calling it through bumblebee's optirun, can't find the library, although it's there: optirun vdpauinfo display: :0.0 screen: 0 Failed to open VDPAU backend libvdpau_nvidia.so: cannot open shared object file: No such file or directory Error creating VDPAU device: 1 avilella@magneto:~$ locate libvdpau_nvidia.so | xargs ls /usr/lib/nvidia-current/vdpau/libvdpau_nvidia.so /usr/lib/nvidia-current/vdpau/libvdpau_nvidia.so.1 /usr/lib/nvidia-current/vdpau/libvdpau_nvidia.so.290.10 –  213441265152351 Feb 3 '12 at 2:59
2  
If, as it now appears, you have a hybrid/optimus video hardware then you'll need to research how to allow gpu decoding thru the nvidia chip. Myself have never owned such hardware, a question specific to that issue may garner some attention from those who do & are facing or hopefully 'fixed' this problem –  doug Feb 3 '12 at 5:21
    
this question has some info on hybrid, likely others askubuntu.com/questions/100786/… –  doug Feb 8 '12 at 0:10

You can do it by checking the cpu usage of the playing process in for instance top. If vdpau offloading is in effect, the cpu usage should be low. On the other hand, decoding on the cpu will result in high cpu load.

share|improve this answer

VLC , By default uses the hardware acceleration of the platform if it's available.You can verify by going to player's Tools->Preferences->Video->Accelerated Video Output(Overlay) and see if it's ticked.

So you should check whether the drivers for Nvidia graphics card is installed properly ,which you can by using the System->Administration->Additional Drivers.

share|improve this answer
    
For vlc, Tools->Preferences->Video->Accelerated Video Output(Overlay) is ticked, but it behaves as when I run it with mplayer, so I am guessing it's not working either. –  213441265152351 May 30 '11 at 10:53

To check I would play an HD movie, Download a trailer from the apple/iTunes movie trailer website. on VLC got to Tools->Preferences->Video->Accelerated Video Output(Overlay) and disable it. Open The System monitor and go to the "Processes" tab and find VLC on the list.

Start the trailer or movie you have and look at how high the VLC process is using CPU. Now stop the movie on VLC and go to Tools->Preferences->Video->Accelerated Video Output(Overlay) then "Enable" the Hardware acceleration and Save your settings. It may be necessary to close then restart VLC for the changes to take effect. I would restart it to be safe.

Once VLC is restarted with the hardware overlay enabled. Play the same movie/trailer as before and see if the CPU Resources are lower on the System Monitor panel.

If they are significantly lower that means it is working.

in my case VLC went from using 60-70% CPU to only 20-30%. I noticed that MPlayer used even less. it went from 60-70% to under 5% with Hardware acceleration.

Your results will vary but if Hardware acceleration is working properly you should see a pretty significant decease on CPU usage on that specific process under the System Monitor.

From what I understand Video Hardware acceleration is not compatible with all video formats and it depends on your GPU as far as which formats it can decode.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.