User:Oldcpu/vdpau

Jump to: navigation, search

openSUSE Video Editing - General Information on AVCHD and VDPAU


The Problem

Purchasers of AVCHD camcorders (ie SD-Card or HardDrive based, not tape based) typically note that their average age PC are not able to smoothly handle the high resolution AVCHD (H.264 encoded) format that these camcorders output. They note the playback of the top 1920x1080 resolutions result in jerky and studdering video playback. Even new dual core CPU equiped PCs struggle with the highest High Definition videos, where mostly only the quad Core CPU's (such as the recent, but expensive Intel i7 CPU) provide a smooth playback of such high definition video formats.

This AVCHD (H.264) decoding playback problem is in contrast to the playback of videos from Tape based camcorders, where the tape based camcorder High Definition video is typically encoded in an MPEG1/2 format. Purportedly MPEG1/2 is easier to play back (decode) on older PCs than the AVCHD (H.264 encoded).

Software Transcode Workaround

The "software" based work around that many PC users implement, is to transcode the raw AVCHD camcorder video to a lower quality resolution/video-format, so that it can be played and edited with a Non Linear Video Editor. With recent ffmpeg updates, ffmpeg can handle the AVCHD format, although the transcoding to the lower quality resolution/format is typically very slow on older PCs. There is development working on going in kdenive to allow editing without having to transcode to a lower resolution, although smooth playback of the edited high quality H.264 encoded files with most PCs is still a problem.


nVidia Pure Video / VDPAU helping playback/decoding

General: For video playback, there is also a hardware solution for users of older PCs, who do not want to (yet) purchase a new PC, and who do not want to reduce the video to a lower resolution to smoothly play back. That solution is to carefully and selectively upgrade one's graphic card and procure software that uses the capabilities of the upgraded card. NVidia offers for MS-Windows users cards with a "Pure Video" capability, where that capability is designed to off load the decoding of selected codecs from the PC's CPU, to the graphic cards GPU, where the microcode in the GPU has been optimized for decoding selective video codecs. In particular, dependent on the Pure Video generation (1st, 2nd, or 3rd), MPEG 1/2, H.264, and VC-1 (wmv variants) are supported for decoding (ie playback). A wiki on Pure Video is here: http://en.wikipedia.org/wiki/NVIDIA_PureVideo. nVidia's Pure Video follows Microsoft's DirectX Video Acceleration (DxVA) API for Windows. Note the nVidia cards that provide Pure Video capabilities are not necessary "game cards" and computer games may or may not play back well on such cards. The reverse is also true. Graphic cards that play games superbly, may or may not necessary play back High Definition Video smoothly.

For example, the recent versions of relatively inexpensive nVidia 8400GS graphic card provide 3rd generation Pure Video Support ( .. typically a higher GPU clock frequency is an indicator whether an 8400 GS card is a 3rd generation Pure Video card). Note that not all video cards from the GeForce 8 series support VDPAU. The GeForce 8800GTS 320/640MB editions and the GeForce 8800GTX cards do not support VDPAU as they are based on an older GPU core and thus are incompatible with the VDPAU implementation. Nvidia has no plans to support VDPAU on these cards.

Linux VDPAU: Commencing last year, nVidia started offering proprietary software graphic drivers for Linux (and FreeBSD and Solaris), with the Linux equivalent of Pure Video (called VDPAU) where Linux applications that use a nVidia card's VDPAU (ie Pure Video) capability will offload the video coding from the CPU to the GPU. This enables older PCs with the appropriate nVidia card and appropriate software to playback High Definition H.264 (or MPEG 1/2 or VC-1) encoded videos smoothly, where previously old PCs would not be able to handle this at all. A wiki on Linux VDPAU is here: http://en.wikipedia.org/wiki/VDPAU

Applications using VDPAU

In terms of Linux applications, there are patches (to take advantage of VDPAU offloading to the GPU) available for Linux applications ffmpeg, xine, mplayer, mythtv,xbmc, and kdenlive (for video playback) and purportedly opensource coders are working on vlc. Most Linux distributions do not yet offer pre-compiled packages of these applications compiled with VDPAU capabilities, and hence for many distributions one may be forced to re-compile all the various applications themselves.

For example, in openSUSE the 3rd party Packman packagers (of rpm packaged applications for openSUSE Linux) have packaged versions of ffmpeg, mplayer and kdenlive that support VDPAU. As of February 2010, the Packman packaged xine (1.1.16) does not provide VDPAU support, but its likely the upcoming Packman packaged version of xine-1.2 (when it is finally released) will provide VDPAU support. The Packman packaged vlc also do not yet support VDPAU.

Setup VDPAU on openSUSE

To setup VDPAU on openSUSE you need:

  • nVidia VDPAU compatible graphic card (ie a Pure Video compatible graphic card)
  • nVidia proprietary driver of version TBD or later
  • openSUSE Linux application built to use VDPAU support (such as ffmpeg, and MPlayer packaged by Packman)

Application hints with VDPAU

This section contains some application specific information to help one confirms vdpau is functioning on one's PC and also some basic commands to play some videos using vdpau.

Packman nvidia-vdpau-devel

If one has the Packman packaged nvidia-vdpau-devel installed http://packman.links2linux.de/package/nvidia-vdpau-devel then run "./vdpinfo" and one should get something like:

 display: :0   screen: 0                                                
 API version: 0                                                         
 Information string: Unknown                                            
 
 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 
 .... etc .......

ffmpeg check of VDPAU

To confirm ffmpeg you are using supports vdpau, type the following in a terminal or konsole:

 ffmpeg -formats | grep vdpau

and you should get something like:

 FFmpeg version 0.5, Copyright (c) 2000-2009 Fabrice Bellard, et al.
   configuration: --shlibdir=/usr/lib --prefix=/usr --mandir=/usr/share/man --libdir=/usr/lib --enable-shared
     --enable-libmp3lame --enable-libvorbis --enable-libtheora --enable-libspeex --enable-libfaad 
     --enable-libfaac --enable-libxvid --enable-swscale --enable-postproc --enable-gpl 
     --enable-vhook --enable-x11grab --enable-libschroedinger --enable-libdirac --enable-libgsm 
     --enable-libx264 --enable-libamr-nb --enable-libamr-wb --enable-libdc1394 --enable-nonfree 
     --enable-pthreads --enable-vdpau
   libavutil     49.15. 0 / 49.15. 0
   libavcodec    52.20. 0 / 52.20. 0
   libavformat   52.31. 0 / 52.31. 0
   libavdevice   52. 1. 0 / 52. 1. 0
   libswscale     0. 7. 1 /  0. 7. 1
   libpostproc   51. 2. 0 / 51. 2. 0
   built on Mar 10 2009 22:17:30, gcc: 4.3.2 [gcc-4_3-branch revision 141291]
  D V D  h264_vdpau      H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 (VDPAU acceleration)
  D V DT mpeg1video_vdpau MPEG-1 video (VDPAU acceleration)
  D V DT mpegvideo_vdpau MPEG-1/2 video (VDPAU acceleration)
  D V D  vc1_vdpau       SMPTE VC-1 VDPAU
  D V D  wmv3_vdpau      Windows Media Video 9 VDPAU


MPlayer commands to use VDPAU

If MPlayer is built with VDPAU support, then the command to play a H.264 , or MPEG1/2 or VC-1 encodec video is:

 mplayer -vo vdpau -vc <codec> <video-file-name>

Where <codec> can be either:

 ffmpeg12vdpau
 ffh264vdpau
 ffwmv3vdpau
 ffvc1vdpau

For example, for an H.264 encoded video:

 mplayer -vo vdpau -vc ffh264vdpau my-h264-video.avi

For example, for an MPEG2 encoded vodeo:

 mplayer -vo vdpau -vc ffmpeg12vdpau my-mpeg2-video.mpg

For example, for a wmv3 encoded video:

 mplayer -vo vdpau -vc ffwmv3vdpau my-wmv3-video.wmv

For example, for a VC1 encoded video:

 mplayer -vo vdpau -vc ffvc1vdpau my-wmv-video.wmv

MPlayer VDPAU available deinterlacing options

There are also available some MPlayer de-interlacing options. These can be specified by use of deint in the mplayer command, where

 deint=<0−4>

Chooses the deinterlacer (default: 0). All modes > 0 respect −field−dominance. NOTE: Values > 2 delay the video output by one frame.

 0 - No deinterlacing.
 
 1 - Show only first field, similar to −vf field.
 
 2 - Bob deinterlacing, similar to −vf tfields=1.
 
 3 - Motion adaptive temporal deinterlacing. May lead to A/V desync with slow video hardware 
     and/or high resolution. This is the default if "D" is used to enable deinterlacing.
 
 4 - Motion adaptive temporal deinterlacing with edge-guided spatial interpolation. Needs fast video hardware.

An example of the syntax could be:

 mplayer -vo vdpau:deint=4 -vc ffmpeg12vdpau my-mpeg2-video.mpg

Troubleshooting VDPAU

Some users have experienced "tearing" or a horizontal line sometime in the video picture typically observed in fast camera movements. This may also manifest itself as choppy video. One possible solution to that is to add the following to one's /etc/X11/xorg.conf file:

 Section "Extensions"
      Option "Composite" "Disable"
 EndSection

and then restart X window.

Known VDPAU Limitations (as of April-2009) :

  • 1. Playing some video streams may cause GPU errors and/or hang or crash the system.
  • 2. The skip forward/backward features are not robust yet and can cause application or system hangs/crashes.
  • 3. MPlayer OSD or Composite Picture is currently not supported.
  • 4. Problems have been observed when building MPlayer with these patches using gcc-4.3.2 (openSUSE-11.1 uses gcc-4.3.3)
  • 5. The ffh264vdpau decoder in MPlayer is still considered sub-optimal compared to the other vdpau decoders like ffmpeg12vdpau, ffvc1vdpau and ffwmv3vdpau. As of this writing, work is being done to optimize it.

Links