VDPAU and MythTV 0.21 

Filed under: Digital TV, FreeView, myPVR, MythTV, NZ MythTV, vdpau on Wednesday, March 11th, 2009 by steve | Comments Off

Finally had time to try out VDPAU in combination with MythTV. The MythTV team have implemented VDPAU support in yet to be released 0.22, but I want to try the backport to 0.21 developed by Jean-Yves Avenard.

Test Setup

Rather than using a laptop I moved onto one of the myPVR test environments, with the addition of a VDPAU capable PCIe card.

  • Asus M2NPV-VM Motherboard
  • AMD Athlon X2 6000+
  • 2GB Ram
  • Asus 8400 GS PCIe card with 512MB Ram
  • Ubuntu 8.10
  • Nvidia 180.37 Video driver
  • Hauppage HVR 900 digital tuner
  • freeview|HD terrestrial signal

MythTV Install

Before I could use Jean’s Ubuntu packages I needed to

  • upgrade the myPVR test environment from Ubuntu 8.04 to 8.10.
  • remove Ubuntu supplied NVidia drivers.
  • Install NVidia 180.37 binary driver
  • Add Jean-Yves’s Ubuntu repository.

I created a file /etc/apt/sources.list.d/jean.list

deb http://www.avenard.org/files/ubuntu-repos release/

and then upgraded mythtv, mythtv-backend, mythtv-frontend.

Configuring MythTV

Before using VDPAU under MythTV we need to defined a display profile for TV that specifies VDPAU for both. The MythTV Wiki has a reference on configuring VDPAU

I didn’t need to re-scan for any channels as they were already loaded from previous testing of ffmpeg’s software based decoder.

Playback testing

Here in New Zealand our freeview|HD service currently broadcasts in three different resolutions

  • 576i H.264 video with HE-AAC Audio
  • 720p H.264 video with HE-AAC Audio
  • 1080i H.264 video with HE-AAC and AC3 Audio.

With all of the formats there was minimal CPU utilisation, but quite a high degree of video tearing on the HD Channels. First i disabled the Composite extension by adding the following to my /etc/init.d/xorg.conf

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

Then I tried various de-interlacers. I found good performance with Temporal 2x good, but Advanced 2x caused the playback of 1080i video to get very jerky.

Issues

There is still a little bit of tearing from time to time with H.264 playback when compared with the older MPEG2 based freeview service.

There are some stability issues, especially with LiveTV. The frontend will either exit from TV playback with an error, or crash.

Quite often I can have the front end produce a series of audio sync errors and the playback becomes very erratic. Usually the frontend will report

NVP: Video is 3.12705 frames behind audio (too slow), dropping frame to catch up.

Our other audio related errors like this

2009-03-11 21:51:57.506 Video sync method can't support double framerate (refresh rate too low for bob deint)
2009-03-11 21:51:57.507 Video timing method: USleep with busy wait
2009-03-11 21:51:57.890 Audio -83 ms behind video but already 75 video frames queued. AV-Sync might be broken.
2009-03-11 21:51:57.910 Audio -63 ms behind video but already 75 video frames queued. AV-Sync might be broken.
2009-03-11 21:51:57.933 Audio -43 ms behind video but already 75 video frames queued. AV-Sync might be broken.
2009-03-11 21:51:57.985 Audio -99 ms behind video but already 75 video frames queued. AV-Sync might be broken.
2009-03-11 21:51:57.995 Audio -86 ms behind video but already 75 video frames queued. AV-Sync might be broken.
2009-03-11 21:51:58.015 Audio -66 ms behind video but already 75 video frames queued. AV-Sync might be broken.
2009-03-11 21:51:58.026 Audio -46 ms behind video but already 75 video frames queued. AV-Sync might be broken.
2009-03-11 21:51:58.223 NVP: prebuffering pause
GetBootInfo ResidentProgram is not implemented
2009-03-11 21:51:58.251 Audio -87 ms behind video but already 75 video frames queued. AV-Sync might be broken.
2009-03-11 21:51:58.267 Audio -67 ms behind video but already 75 video frames queued. AV-Sync might be broken.
2009-03-11 21:51:58.289 Audio -55 ms behind video but already 75 video frames queued. AV-Sync might be broken.
2009-03-11 21:51:58.299 Audio -35 ms behind video but already 75 video frames queued. AV-Sync might be broken.
2009-03-11 21:51:58.315 Audio -15 ms behind video but already 75 video frames queued. AV-Sync might be broken.
2009-03-11 21:51:58.326 Audio 5 ms behind video but already 75 video frames queued. AV-Sync might be broken.
2009-03-11 21:51:58.354 NVP: prebuffering pause
2009-03-11 21:51:58.520 Audio -98 ms behind video but already 75 video frames queued. AV-Sync might be broken.
2009-03-11 21:51:58.550 Audio -78 ms behind video but already 75 video frames queued. AV-Sync might be broken.
2009-03-11 21:51:58.571 Audio -58 ms behind video but already 75 video frames queued. AV-Sync might be broken.

or this

2009-03-11 21:56:37.977 NVP: prebuffering pause
2009-03-11 21:56:38.047 WriteAudio: buffer underrun
2009-03-11 21:56:38.590 NVP: prebuffering pause
2009-03-11 21:56:38.885 NVP: prebuffering pause
2009-03-11 21:56:39.557 NVP: prebuffering pause
GetBootInfo ResidentProgram is not implemented
2009-03-11 21:56:40.467 NVP: prebuffering pause
2009-03-11 21:56:40.769 NVP: prebuffering pause
2009-03-11 21:56:42.067 NVP: prebuffering pause
2009-03-11 21:56:42.953 NVP: prebuffering pause
2009-03-11 21:56:43.102 NVP: prebuffering pause
2009-03-11 21:56:43.851 NVP: prebuffering pause
2009-03-11 21:56:44.511 NVP: prebuffering pause
2009-03-11 21:56:44.594 NVP: prebuffering pause
2009-03-11 21:56:45.030 NVP: prebuffering pause
2009-03-11 21:56:45.924 NVP: prebuffering pause
2009-03-11 21:56:46.443 WriteAudio: buffer underrun
2009-03-11 21:56:46.807 NVP: prebuffering pause
2009-03-11 21:56:47.837 NVP: prebuffering pause
2009-03-11 21:56:49.232 NVP: prebuffering pause
2009-03-11 21:56:49.234 WriteAudio: buffer underrun
2009-03-11 21:56:49.438 NVP: Prebuffer wait timed out 10 times.
2009-03-11 21:56:50.069 NVP: prebuffering pause

I’ve managed to produce these errors with both 720p and 1080i content, and now have some samples on disk for further testing.

Conclusion

Sadly the same as my initial VDPA testing report, great steps forward but not WAF proof yet if you want HD playback. In the space of a couple of hours testing I managed to crash the front end over a dozen times. Ok most of these were during LiveTV channel changing, but some were down to fast forwarding material. Less issues with the 576i content compared with the 1080i content, but still far from stable.

Next up is the fact that the video tearing is too much, especially on a large screen. I’d rather have the slightly lower quality MPEG2 based freeview service than suffer the video tearing.

Here is hoping that future updates from NVidia remove some of these issues, while the numerous testers of VDPAU + MythTV here in NZ and elsewhere in the world can resolve any other problems.

Initial VDPAU Testing 

Filed under: Digital TV, FreeView, h264, vdpau on Wednesday, February 11th, 2009 by steve | Comments Off

Well it is finally time to test NVidia’s VDPAU support under Linux.

Test Setup

  • Dell Inspiron 1420 Laptop
    • NVidia GeForce 8400M GS 128MB Video
    • Intel Core 2 Duo T7500  @ 2.20GHz
    • 3GB Ram
  • Ubuntu 8.10
  • Nvidia 180.25 Video driver
  • Compiz disabled
  • CPU locked in performance mode of 2.2 GHz
  • mplayer-vdpau-3402051
  • Hauppage HVR 900 digital tuner
  • freeview|HD terrestrial signal

Channel Playback Comparison

Stats were collected via vmstat and the following commands were used to initiate DVB tuning and plaback

mplayer -vc ffh264 -vo xv -mc 2 dvb://CHANNEL

mplayer -vc ffh264vdpau -mc 2 dvb://CHANNEL

We specify -mc 2 so that interlaced video has a chance to synchronise correctly.

Channel Format Software VDPAU
TV One 720p 27-35 % 3 %
TV 2 720p 20-35 % 3 %
TV 3 1080i 50+ % N/A
C4 576i 9-16 % 3 %
Maori 576i 7-11 % 3 %
freeview|HD 720p 27-35 % 3 %

The percentages above are based off a dual core CPU. When decoding in software ffmpeg only uses a single core so we are actually doing over 100% of a CPU

Outstanding Issues

My attempts to play TV3 with VDPAU resulting in the following error message

VO: [vdpau] 1920x1080 => 1920x1080 H.264 HIGH VDPAU acceleration
[ASPECT] Warning: No suitable new res found!
[ASPECT] Warning: No suitable new res found!
[ASPECT] Warning: No suitable new res found!
Error 23 at libvo/vo_vdpau.c:736

There is a good chance this is because the laptop only has 128MB of video ram and NVidia recomment 512MB for 1080 HD sized frames.

The higher software CPU load on C4 compared with other 576i channels is likely due to the much higher bitrate on C4.

Stability wise most of the crashes were because of the HE-AAC/FAAD audio support in MPlayer, although there were some video related crashes. Typically if I changed channel sometimes it would crash when it tried to lock onto the new audio or video stream.

Mostly the video quality with VDPAU was good, but there was some obvious video tearing on playback that I didn’t see with the ffmpeg decoder.

Conclusion

Great strides forward but sadly not ready for primetime. The WAF around my own myPVR would drop dramatically if I switched to freeview|HD and VDPAU due to the stability and video tearing issues.

Still well worth keeping my eye on future releases, and nice to have a laptop that can play most of freeview|HD without stressing the CPU.

Hauppauge HVR 900 tuner and Ubuntu 8.10 

Filed under: Digital TV, DVB Drivers, em28xx on Sunday, November 16th, 2008 by steve | Comments Off

Ubuntu 8.10, aka Intrepid Ibex, has been out for several weeks now, and I’ve been testing the HVR 900 tuner since the later alpha releases starting some months ago. Now we have a final OS release just how well does this tuner work?

First of all I’m using a vanilla HVR 900, watch out for those pesky HVR-900H versions that are knocking around. There is some work underway to get the newest versions of the Em2880 driver merged into the mainline kernel, but it appears that the em28xx.ko module that ships with Intrepid works with my tuner with no patching required. Your own mileage might vary.

There is one gotcha, Ubuntu doesn’t ship with the required firmware. This is relatively simple to acquire, and should be installed prior to plugging in your tuner.

sudo bash
cd /tmp
wget -c http://www.steventoth.net/linux/xc5000/HVR-12×0-14×0-17x0_1_25_25271_WHQL.zip
apt-get install unzip
unzip -x HVR-12×0-14×0-17x0_1_25_25271_WHQL.zip
cd Driver85
perl /usr/src/linux-headers-`uname -r`/Documentation/video4linux/extract_xc3028.pl
cp xc3028-v27.fw /lib/firmware/

It is worth checking the md5sum on the firmware file

md5sum /lib/firmware/xc3028-v27.fw
293dc5e915d9a0f74a368f8a2ce3cc10  /lib/firmware/xc3028-v27.fw

Then plugin in your tuner and you should see the driver and firmware load

[  124.557552] firmware: requesting xc3028-v27.fw
[  124.618386] xc2028 0-0061: Loading 80 firmware images from xc3028-v27.fw, type: xc2028 firmware, ver 2.7

I haven’t tried stress testing this driver for an extended period, but I can tune to both analogue and DVB-T as shown in my previous HVR 900 articles.

NVidia announces support for H.264 and VC1 decode on Linux 

Filed under: h264, News, vdpau on Sunday, November 16th, 2008 by steve | Comments Off

NVidia have announce a new API for hardware accelerated decode of video on Linux and Unix called VDPAU. This is awesome news for the Linux MythTV and Video community as the partial subset of NVidia’s PureVideo functionality provides a dramatic drop in CPU usage when handling complex video codecs like H.264 and VC1.

Linux and Unix news site Phoronix was amongst the first to break the announcement, and has already benchmarked the new api showing some quite startling results when compared with existing software based decoders.

The current API documentation is here:

ftp://download.nvidia.com/XFree86/vdpau/doxygen/html/index.html

Some highlights of VDPAU:

  • Defines an API for GPU-accelerated decode of MPEG-1, MPEG-2, H.264, and VC-1 bitstreams.
  • Defines an API for post-processing of decoded video, including temporal and spatial deinterlacing, inverse telecine, and noise reduction.
  • Defines an API for timestamp-based presentation of final video frames.
  • Defines an API for compositing sub-picture, on-screen display, and other UI elements.

Sadly this new API doesn’t support some of the older 6xxx and 7xxx series graphics cards, and VC1 support will require a 9xxx or newer card. The code is still relatively new so don’t expect it to be part of your favourite distribution for a while.

This announcement now means that all of the three major graphics chipset companies, Intel, AMD and NVidia, have all announced methods to hardware accelerate complex video codecs like H.264. We can only hope that freedesktop.org manages to come up with unified API, such as VAAPI, that works across all chipsets.

Hauppauge HVR 900 tuner and Ubuntu Hardy 

Filed under: Digital TV, DVB Drivers, em28xx, h264 on Sunday, June 8th, 2008 by steve | Comments Off

This is a follow up on my previous attempts to get the Em2880 based Hauppauge HVR-900 USB tuner working.

First a word of warning. There appears to be a new model of the HVR-900 labeled the HVR-900H. This is a new hardware revision and uses a totally different chipset, and as such won’t work with the Em2880 drivers. Work is believed to be underway on a driver, but it would be worth checking the linux-dvb mailinglist.

Updated useful reference docs for the empia driver can now be found here -

Whilst my previous posts have focused on building from source, Markus has now released a kernel package for Ubuntu Hardy kernel version 2.6.24-16, which can be made to work on later kernels providing you remove any conflicting kernel modules.

These tips should work for all supported em28xx based cards under Ubuntu Hardy and Mythbuntu 8.04.

  1. Install appropriate firmware for your device.
  2. Download and install the pre-built driver package.
  3. Copy the modules to your current kernel and clean up any conflicting modules by running the following script as root -
    # First backup the existing kernel modules
    
    cd /lib/modules
    
    tar -zcf `uname -r`.orig.modules.tgz `uname -r`# Then copy over the empia driver from 2.6.24-16-generic
    
    cp -a /lib/modules/2.6.24-16-generic/empia `uname -r`
    
    # Then delete any conflicting packages
    
    cd `uname -r`/kernel
    
    ls ../empia/ | while read i; do find . -name $i -exec rm -f {} \; ; done
    
    # Them make sure our modules will load correctly
    
    depmod -a

    On the recently released 2.6.24-18 kernel the script will remove the following conflicting packages from the Ubuntu kernel install.

    ./drivers/media/video/em28xx/em28xx.ko
    
    ./drivers/media/dvb/frontends/qt1010.ko
    
    ./drivers/media/video/tvp5150.ko
    
    ./drivers/media/dvb/frontends/zl10353.ko
  4. Plug in your device and check the kernel messages are similar to the following
    [ 330.299346] Linux video capture interface: v2.00
    
    [ 330.304618] em28xx v4l2 driver version 0.0.1 loaded
    
    [ 330.304829] em28xx new video device (2040:6500): interface 0, class 255
    
    [ 330.304833] em28xx: device is attached to a USB 2.0 bus
    
    [ 330.305238] em28xx #0: Alternate settings: 8
    
    [ 330.305240] em28xx #0: Alternate setting 0, max size= 0
    
    [ 330.305242] em28xx #0: Alternate setting 1, max size= 0
    
    [ 330.305244] em28xx #0: Alternate setting 2, max size= 1448
    
    [ 330.305246] em28xx #0: Alternate setting 3, max size= 2048
    
    [ 330.305248] em28xx #0: Alternate setting 4, max size= 2304
    
    [ 330.305250] em28xx #0: Alternate setting 5, max size= 2580
    
    [ 330.305251] em28xx #0: Alternate setting 6, max size= 2892
    
    [ 330.305253] em28xx #0: Alternate setting 7, max size= 3072
    
    [ 330.348854] i2c-adapter i2c-2: SMBus Quick command not supported, can't probe for chips
    
    [ 330.537728] trying to set disabled gpio? (00)
    
    [ 330.539442] tuner 6-0061: chip found @ 0xc2 (em28xx #0)
    
    [ 330.539645] attach inform (default): detected I2C address c2
    
    [ 330.542825] attach_inform: tvp5150 detected.
    
    [ 330.543509] attach_inform: eeprom detected.
    
    [ 330.558049] em28xx #0: i2c eeprom 00: 1a eb 67 95 40 20 00 65 50 12 5c 03 82 1e 6a 18
    
    [ 330.558056] em28xx #0: i2c eeprom 10: 00 00 24 57 66 07 00 00 60 00 00 00 02 00 00 00
    
    [ 330.558062] em28xx #0: i2c eeprom 20: 46 00 01 00 f0 10 02 00 b8 00 00 00 5b 00 00 00
    
    [ 330.558068] em28xx #0: i2c eeprom 30: 00 00 20 40 20 6e 02 20 10 01 01 01 00 00 00 00
    
    [ 330.558074] em28xx #0: i2c eeprom 40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    
    [ 330.558080] em28xx #0: i2c eeprom 50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    
    [ 330.558085] em28xx #0: i2c eeprom 60: 00 00 00 00 00 00 00 00 00 00 18 03 34 00 30 00
    
    [ 330.558091] em28xx #0: i2c eeprom 70: 32 00 36 00 39 00 30 00 39 00 39 00 39 00 30 00
    
    [ 330.558097] em28xx #0: i2c eeprom 80: 00 00 1e 03 57 00 69 00 6e 00 54 00 56 00 20 00
    
    [ 330.558103] em28xx #0: i2c eeprom 90: 48 00 56 00 52 00 2d 00 39 00 30 00 30 00 00 00
    
    [ 330.558108] em28xx #0: i2c eeprom a0: 84 12 00 00 05 50 1a 7f d4 78 23 f0 fd d0 18 85
    
    [ 330.558114] em28xx #0: i2c eeprom b0: ff 00 00 00 04 84 0a 00 01 01 20 77 00 40 26 c5
    
    [ 330.558120] em28xx #0: i2c eeprom c0: 05 f0 74 02 01 00 01 79 78 00 00 00 00 00 00 00
    
    [ 330.558126] em28xx #0: i2c eeprom d0: 84 12 00 00 05 50 1a 7f d4 78 23 f0 fd d0 18 85
    
    [ 330.558132] em28xx #0: i2c eeprom e0: ff 00 00 00 04 84 0a 00 01 01 20 77 00 40 26 c5
    
    [ 330.558138] em28xx #0: i2c eeprom f0: 05 f0 74 02 01 00 01 79 78 00 00 00 00 00 00 00
    
    [ 330.558144] EEPROM ID= 0x9567eb1a
    
    [ 330.558145] Vendor/Product ID= 2040:6500
    
    [ 330.558147] AC97 audio (5 sample rates)
    
    [ 330.558148] 500mA max power
    
    [ 330.558149] Table at 0x24, strings=0x1e82, 0x186a, 0x0000
    
    [ 330.590328] tvp5150 6-005c: tvp5150am1 detected.
    
    [ 331.369015] successfully attached tuner
    
    [ 331.371002] em28xx #0: V4L2 VBI device registered as /dev/vbi0
    
    [ 331.380375] em28xx #0: V4L2 device registered as /dev/video0
    
    [ 331.380568] em28xx #0: Found Hauppauge WinTV HVR 900
    
    [ 331.386799] analog tv open()
    
    [ 331.386804] modelock active!
    
    [ 331.386800] usbcore: registered new interface driver em28xx
    
    [ 331.388502] em2880-dvb.c: DVB Init
    
    [ 331.415417] vbi open()
    
    [ 331.415423] modelock active!
    
    [ 331.555256] DVB: registering new adapter (em2880 DVB-T)
    
    [ 331.555263] DVB: registering frontend 1 (Zarlink ZL10353 DVB-T)...
    
    [ 331.555449] Em28xx: Initialized (Em2880 DVB Extension) extension
  5. Now try the digital tuner using scan or w_scan.
  6. Check analogue tuning, for example using tvtime. In order to get working audio with tvtime you will currently need to install the project’s patched version.

Analogue Samples

These were taken from NZ analogue channels TV2 and Maori TV. As you can see the analogue reception in my office is less than perfect. The linked images are the original unmodified PNG screen captures.

TV2 – 576i SD
TV2 Shortland St
Maori TV – 576i SD
Maori TV

Digital Samples

Here is a mix of samples pulled from New Zealand’s freeview|HD service. The images below have been re-scaled, but you can click through to the PNGs from the original screen captures. All of the freeview|HD broadcasts are in H.264.

Sadly none of the broadcasters were showing native HD content whilst I was performing these tests so any HD video was upscaled prior to broadcast.

TVNZ 7 – 576i SD
TVNZ 7
TV One – 720p HD
TV One HD
TV 2 – 720p HD
Shortland St HD
TV 3 – 1080i HD
TV3 1080i

The picture issues shown in the TV 3 1080i sample are due to missing support for PAFF interlaced spatial direct video in FFMPEG’s H.264 decoder.

Using HVR 900 with MythTV

Recent builds of MythTV will detect both the analogue and digital tuners of the HVR 900. The device can only operate a single tuner at a time, and MythTV already has the required patches to understand this.

When setting up the V4L based analogue tuner you need to make sure you select the correct audio device as the driver exposes its own DSP interface.

At the moment the support for New Zealand’s H.264 terrestrial service freeview|HD is rather limited, but you can scan for the 3 active multiplexes. For other countries you might have more luck.