Difference between revisions of "Hauppauge HD-PVR"

From MythTV Official Wiki
Jump to: navigation, search
(Again, the HD-PVR is *not* capturing digital component, it's capturing analog component.)
Line 143: Line 143:
 
== Configuring the HD-PVR in MythTV ==
 
== Configuring the HD-PVR in MythTV ==
  
MythTV SVN Trunk now includes rudimentary support for the HD-PVR.  While it is still strongly recommended that the average user not switch to the Myth development branch, advanced users of Myth and Linux are invited to participate in development and bug squashing of the HD-PVR driver and its support in MythTV.  With a few caveats, the HD-PVR can be expected to work semi-reliably for scheduled recordings.   
+
MythTV SVN Trunk now includes support for the HD-PVR.  While it is still strongly recommended that the average user not switch to the Myth development branch, advanced users of Myth and Linux are invited to participate in development and bug squashing of the HD-PVR driver and its support in MythTV.  With a few caveats, the HD-PVR can now be expected to work reliably for scheduled recordings.   
  
 
==== Caveats ====
 
==== Caveats ====
  
For maximum stability, the tuner/Set-top-box/Satellite Receiver feeding the HD-PVR should be set to output 720p at all times.  There are several reasons behind this.  MythTV currently has a variety of problems properly displaying the interlaced captures of the HD-PVR, including spontaneous crashes, flickering video, and inaccurate timestamps and skipping.  A variety of solutions are in the works to improve 1080i capture and playback with the HD-PVR, including updating Myth's copy of libavcodec, improvements to the driver, and fully implementing HD-PVR support in MythTV.    Additionally, once the tuner has been added as an encoder in MythTV, it is vital that the user not access the tuner in outside programs such as cat, VLC, and mplayer.  This can lead to MythTV's connection with the driver becoming unstable, and subsequent recordings failing until the driver is reloaded and power is cycled on the HD-PVR.
+
For maximum stability, the tuner/Set-top-box/Satellite Receiver feeding the HD-PVR should be set to output 720p at all times.  There are several reasons behind this.  MythTV currently has a variety of problems properly displaying the interlaced captures of the HD-PVR, including spontaneous crashes, flickering video, and inaccurate skipping.  A variety of solutions are in the works to improve 1080i capture and playback with the HD-PVR, including updating Myth's copy of libavcodec, improvements to the driver, and fully implementing HD-PVR support in MythTV.    Additionally, once the tuner has been added as an encoder in MythTV, it is vital that the user not access the tuner in outside programs such as cat, VLC, and mplayer.  This can lead to MythTV's connection with the driver becoming unstable, and subsequent recordings failing until the driver is reloaded and power is cycled on the HD-PVR.
  
 
Perhaps the largest "gotcha" currently with the HD-PVR in Myth is that the driver will crash when the resolution changes between channels.  For this reason, whichever resolution the tuning device outputs *must* remain the same for the sake of stability.  For Motorola STB's, it is also important to set the "4:3 Override" option to Off or Stretch.   
 
Perhaps the largest "gotcha" currently with the HD-PVR in Myth is that the driver will crash when the resolution changes between channels.  For this reason, whichever resolution the tuning device outputs *must* remain the same for the sake of stability.  For Motorola STB's, it is also important to set the "4:3 Override" option to Off or Stretch.   
Line 155: Line 155:
 
A [http://svn.mythtv.org/trac/ticket/5443 ticket] for Myth support of the HD-PVR has been created.  The initial patches have been applied to Trunk, and no patching is currently necessary for basic usage of the HD-PVR in MythTV.  You can follow the ticket to see what new functionality is being implemented.   
 
A [http://svn.mythtv.org/trac/ticket/5443 ticket] for Myth support of the HD-PVR has been created.  The initial patches have been applied to Trunk, and no patching is currently necessary for basic usage of the HD-PVR in MythTV.  You can follow the ticket to see what new functionality is being implemented.   
  
Presently, the HD-PVR uses the MPEG-2 encoder card type in mythtv-setup, and utilizes its recording profiles for bitrate settings.  IR Blasting and receiving is totally unimplemented, and there are issues with interlaced content.  If using the optical audio input, the STB must currently be set to 2 channel PCM output.  Hauppauge intends to implement 5.1 channel AC3 muxing in a future firmware release, but this is presently unavailable.
+
Recent changes to SVN trunk have added a new encoder card type unique to the HD-PVR.  IR Blasting and receiving is totally unimplemented, and there remain some issues with interlaced content.  If using the optical audio input, the STB must currently be set to 2 channel PCM output.  Hauppauge intends to implement 5.1 channel AC3 muxing in a future firmware release, but this is presently unavailable.
  
 
==== Steps to Add the HD-PVR as a Capture Device in MythTV ====
 
==== Steps to Add the HD-PVR as a Capture Device in MythTV ====
Line 161: Line 161:
 
# Compile the driver and test it for proper operation as described above.
 
# Compile the driver and test it for proper operation as described above.
 
# Run mythtv-setup, and enter option 2, Capture Cards.
 
# Run mythtv-setup, and enter option 2, Capture Cards.
# Add a new capture card.  When prompted, select "MPEG-2 encoder card (PVR-x50, PVR-500)" as the card type.  Set the /dev/video node to the number of your HD-PVR.  Finish adding the new capture card.
+
# Add a new capture card.  When prompted, select "H.264 Encoder Card (HD-PVR)" as the card type.  Set the /dev/video node to the number of your HD-PVR.  Finish adding the new capture card.  You can also set the audio input on this screen.
 
# Enter option 3, "Video Sources."  Set up a video source for your HD-PVR's tuner as described in [[User_Manual:Detailed_configuration_Backend]].
 
# Enter option 3, "Video Sources."  Set up a video source for your HD-PVR's tuner as described in [[User_Manual:Detailed_configuration_Backend]].
 
# Enter option 4, "Input Connections."  Connect the video source to the appropriate input on the HD-PVR.  '''Important Note:''' You ''must'' set a channel change script for the HD-PVR to work properly.  If you don't care about channel changes, you can set it to /bin/true, but there absolutely must be a channel change script defined.
 
# Enter option 4, "Input Connections."  Connect the video source to the appropriate input on the HD-PVR.  '''Important Note:''' You ''must'' set a channel change script for the HD-PVR to work properly.  If you don't care about channel changes, you can set it to /bin/true, but there absolutely must be a channel change script defined.
  
Assuming you followed the directions carefully, you should now be able to record with the HD-PVR.  If you get "Select Timeout" errors, these can sometimes be overcome by stopping the backend, removing the hdpvr module, cycling the power on the HD-PVR, modprobing the hdpvr module, and restarting the backend.  You can set the bitrate for the HD-PVR by going into Reording Profiles, and editing the profiles associated with MPEG-2 encoders.  In the near future, the HD-PVR will gain its own more granular support for bitrate and resolution in recording profiles, but in the meantime the MPEG-2 Profiles must be used.
+
Assuming you followed the directions carefully, you should now be able to record with the HD-PVR.  If you get "Select Timeout" errors, these can sometimes be overcome by stopping the backend, removing the hdpvr module, cycling the power on the HD-PVR, modprobing the hdpvr module, and restarting the backend.  You can set the bitrate for the HD-PVR by going into Recording Profiles, and editing the profiles associated with HD-PVR encoders.  These recording profiles have bitrate settings for low (480i/p), medium (720p), and high (1080i) resolution material, allowing you to set appropriate bitrates based upon the resolution of the material.
 
 
Myth currently has no method of changing the audio inputs on the HD-PVR, so you will need to pass the audio input you want as a module option in modprobe.conf (or equivalent), example for SPDIF audio:
 
 
 
options hdpvr default_audio_input=2
 
 
 
You can also set the audio input from the command line. To see the audio input numbering, use:
 
 
 
v4l2-ctl --list-audio-inputs
 
 
 
And to set it, use something like:
 
 
 
v4l2-ctl --set-audio-input=2
 
  
 
If you have patched the driver or myth for any further functionality, or if you have a specific problem associated with the HD-PVR driver, you can join #hdpvr on Freenode.  Under ''no circumstances'' will support in compiling mythtv be provided, nor will there be any walking through of the steps outlined above.  If you are not comfortable with compilation, just hang in there!  Better, stable support (and potentially backports to the .21 family) are coming soon.
 
If you have patched the driver or myth for any further functionality, or if you have a specific problem associated with the HD-PVR driver, you can join #hdpvr on Freenode.  Under ''no circumstances'' will support in compiling mythtv be provided, nor will there be any walking through of the steps outlined above.  If you are not comfortable with compilation, just hang in there!  Better, stable support (and potentially backports to the .21 family) are coming soon.

Revision as of 18:48, 12 August 2008

The Hauppauge HD-PVR Model 1212.

The Hauppauge HD-PVR is the first consumer-level analog HD capture device available. The HD-PVR is a USB device that captures the component video outputs and analog/optical audio outputs of any consumer device (including cable/satellite set-top-boxes, HD Disk Players, video game consoles, and various other home media devices). The HD-PVR is a highly anticipated capture device because it captures video via component output, permitting the user to capture High-Definition video from most sources and without concern for encryption. In other words, since component video is not and cannot be encrypted, previously un-capturable HD sources such as satellite and premium television will now be fully accessible in MythTV. Prior to this device, component capture devices were cost-prohibitive and were not directly supportable within Linux.

The HD PVR captures at resolutions from VGA/D1 up to 1080i, and encodes the component inputs in real time using the h.264/MPEG-4 video codec and the AAC audio codec. The streams are muxed into a slightly modified MPEG-2 Transport Stream container. Capture resolution is dependent on the source (ie 720p video with be captured as such, 1080i as 1080i, etc.) but the bitrate is user-selectable from 1 Megabit/second up to 13.5 Megabits/second. The h.264 video codec is, bit-for-bit, up to 40% more efficient than the MPEG-2 video codec commonly used in US HDTV broadcasts today. A 13.5 Mb/s h.264 stream is roughly equivalent to a full-channel-bitrate MPEG-2 recording at approximately 19 Mb/s.

The HD-PVR uses modern codecs capable of exceptional compression rates at excellent quality. The tradeoff is that decoding h.264 material is very processor-intensive. Systems which struggle or barely manage to play back US broadcast HD are likely to fail altogether when playing back recording from the HD-PVR. Hauppauge recommends a dual-core CPU as a minimum. A frequently cited minimum for medium-bitrate h.264 playback is a Core 2 Duo 1.8 Ghz processor. HD Playback Reports acts as a repository for processor requirements to play High Definition material. HD-PVR users are encouraged to contribute to the page to ascertain real-world playback requirements with MythTV.

Hauppauge has signalled their intention to update the HD-PVR firmware and software with the ability to mux the original AC3 audio of the source via the optical connector, enabling the device to record the original multichannel audio track. This capability will not be present at launch.

Possible Countermeasures

Some UK television providers (notably Virgin and Freesat) have attempted to counter the HD-PVR and similar devices by selectively disabling the component outputs of their set-top-boxes. In the US, the Motion Picture Association of America has requested that the Federal Communications Commission allow providers to selectively disable the component outputs of their devices when showing recently released movies.

There is a theoretical solution to this, albeit somewhat expensive. A company called HDFury makes a HDCP-compliant HDMI to RGB bridge. The RGB output of the HDFury can be converted to component with a second device from Box1020. In essence, a user with an HDMI-only device could utilize the following path to convert HDMI to component video:

HDMI Source -> HDMI to DVI cable -> HD Fury -> Box1020 -> Component Cable -> HD-PVR

At the time of this writing, the HDFury and Box1020 cost approximately $350 US. Add to that the cabling and $250 US cost of the HD-PVR and the total cost approaches $650 US. Some users will be put off by the high cost and circuitousness of the solution, but for an increasing number of MythTV users, it may be the only one.

Another possibility is the Exten HD HDMI to Component Video Converter. It is currently available for approximately $260.00 US. However this device automatically shuts off the component outputs when the input is encrypted (Protected), so it is no different than the outputs of the set top box.

HD-PVR Driver Compilation Howto

The alpha release of the HD-PVR Linux driver is available at http://hg.jannau.net/hdpvr/

Please note the following release notes:

The driver is currently at most alpha quality and tested only with
v4l2-ctl and cat /dev/video0. Other applications might fail in
interesting ways.

I've compiled the driver only with kernel 2.6.24 and 2.6.25. A tester
reported success on 2.6.22. 

TODO:
-extend V4L MPEG encoding api (atm only add mpeg4 AVC and AAC
 as formats)
-test IR support and merge it into the official repo
-improve buffer management, especially make it fault-tolerant
-add missing device options (iirc only sharpness and
 chroma/luma filters)
-test with other v4l application and fix issues 

Support for MythTV is already worked on. 

I've probably missed a couple of things so feel free to reply or join
the development irc channel #hdpvr on freenode.net.

Janne

Currently, firmware loading is unimplemented in the driver. As a result, you must install the HD-PVR at least once on a Windows machine to load the firmware into it. Once you have done so, you will need a working build environment, Mercurial tools, and kernel headers on your system. In Debian and debian-based distros, the following command should install all necessary dependencies to build the driver.

sudo apt-get install build-essential mercurial linux-headers-`uname -r` 

In rpm based distros such as Mythdora, the following command should suffice assuming proper dev tools, kernel-headers and kernel-devel have already been installed.

sudo yum install mercurial

Then, you can download the driver source with the following command:

hg clone http://hg.jannau.net/hdpvr/

In best case scenarios, the following should be enough to compile and install the driver:

cd hdpvr
make
sudo make install 

If compilation and installation succeeded, it should be possible to load the HD-PVR driver with:

sudo modprobe hdpvr

If dmesg shows "wrong firmware version," and "device init failed," then you did not install the device in Windows first and the firmware has not been loaded. Install the HD-PVR on a windows machine, install the drivers, and after that the device should work fine in Linux.

In Ubuntu, the module may fail to load and refer you to the dmesg command. If this happens, reboot and see if the error resolves itself. It is also possible that Ubuntu is prioritizing another, older copy of the v4l-dvb modules above the one you just installed, and the hdpvr will fail because the two versions do not match. Try a command like:

locate cx88-dvb.ko |grep `uname -r`

This will search for the cx88-dvb kernel module, which is provided in the Hg tree you just built, and also in default Ubuntu installs. If you see more than one copy of this file, you may need to move the older versions out of the way. In at least one case, alternate versions of all the modules were located in "/opt/ltsp/amd64/lib/modules/kernel version number/ubuntu/". The symbol mismatch was solved by moving the "/opt/ltsp/amd64/lib/modules/kernel version number/ubuntu/media" directory into a backup directory in the user's home, then rebooting.

Testing the Driver

Once the module has loaded successfully, you can check dmesg for output and to determine which /dev/video node it has created. You can then test the device as with any hardware encoder:

cat /dev/video1 > test.ts

Press Ctrl-C to stop the capture, and play it back with any compatible media player (ie mplayer, xine, MythTV).

Bitrate and Picture Controls

The HD-PVR driver is compatible with the v4l2-ctl command line utility included in ivtv-tools. To see a list of adjustable controls, use the following command:

v4l2-ctl --device=/dev/video0 -l

Substitute the correct video# in the example above. The following controls are presently supported in the driver:

Control Name Values Default Description
brightness 0 to 255 134 Brightness picture control over recordings.
contrast 0 to 255 128 Contrast picture control over recordings.
saturation 0 to 255 128 Saturation picture control over recordings.
hue 0 to 255 128 Hue picture control over recordings.
sharpness 0 to 255 128 Sharpness picture control over recordings.
audio_encoding 3 3 Non-adjustable control for Audio Encoding (AAC).
video_encoding 2 2 Non-adjustable control for Video Encoding (H.264).
video_bitrate_mode 0 to 1 1 Control for VBR versus CBR. 0=VBR, 1=CBR.
video_bitrate 1000000 to 13500000 6500000 Bitrate control over recordings in bits, from 1 Mbit/s to 13.5 Mbit/s.
video_peak_bitrate 1100000 to 20200000 9000000 Peak bitrate control in bits, from 1.1 Mbit/s to 20.2 Mbit/s.

You can adjust any of these values with a command like:

v4l2-ctl --device=/dev/video0 --set-ctrl=controlname=value

Or, for example:

v4l2-ctl --device=/dev/video0 --set-ctrl=video_bitrate=13500000

This command will set the bitrate to the maximum of 13.5 Mbit/s for the HD-PVR at /dev/video0.

Configuring the HD-PVR in MythTV

MythTV SVN Trunk now includes support for the HD-PVR. While it is still strongly recommended that the average user not switch to the Myth development branch, advanced users of Myth and Linux are invited to participate in development and bug squashing of the HD-PVR driver and its support in MythTV. With a few caveats, the HD-PVR can now be expected to work reliably for scheduled recordings.

Caveats

For maximum stability, the tuner/Set-top-box/Satellite Receiver feeding the HD-PVR should be set to output 720p at all times. There are several reasons behind this. MythTV currently has a variety of problems properly displaying the interlaced captures of the HD-PVR, including spontaneous crashes, flickering video, and inaccurate skipping. A variety of solutions are in the works to improve 1080i capture and playback with the HD-PVR, including updating Myth's copy of libavcodec, improvements to the driver, and fully implementing HD-PVR support in MythTV. Additionally, once the tuner has been added as an encoder in MythTV, it is vital that the user not access the tuner in outside programs such as cat, VLC, and mplayer. This can lead to MythTV's connection with the driver becoming unstable, and subsequent recordings failing until the driver is reloaded and power is cycled on the HD-PVR.

Perhaps the largest "gotcha" currently with the HD-PVR in Myth is that the driver will crash when the resolution changes between channels. For this reason, whichever resolution the tuning device outputs *must* remain the same for the sake of stability. For Motorola STB's, it is also important to set the "4:3 Override" option to Off or Stretch.

Tracking Progress

A ticket for Myth support of the HD-PVR has been created. The initial patches have been applied to Trunk, and no patching is currently necessary for basic usage of the HD-PVR in MythTV. You can follow the ticket to see what new functionality is being implemented.

Recent changes to SVN trunk have added a new encoder card type unique to the HD-PVR. IR Blasting and receiving is totally unimplemented, and there remain some issues with interlaced content. If using the optical audio input, the STB must currently be set to 2 channel PCM output. Hauppauge intends to implement 5.1 channel AC3 muxing in a future firmware release, but this is presently unavailable.

Steps to Add the HD-PVR as a Capture Device in MythTV

  1. Compile the driver and test it for proper operation as described above.
  2. Run mythtv-setup, and enter option 2, Capture Cards.
  3. Add a new capture card. When prompted, select "H.264 Encoder Card (HD-PVR)" as the card type. Set the /dev/video node to the number of your HD-PVR. Finish adding the new capture card. You can also set the audio input on this screen.
  4. Enter option 3, "Video Sources." Set up a video source for your HD-PVR's tuner as described in User_Manual:Detailed_configuration_Backend.
  5. Enter option 4, "Input Connections." Connect the video source to the appropriate input on the HD-PVR. Important Note: You must set a channel change script for the HD-PVR to work properly. If you don't care about channel changes, you can set it to /bin/true, but there absolutely must be a channel change script defined.

Assuming you followed the directions carefully, you should now be able to record with the HD-PVR. If you get "Select Timeout" errors, these can sometimes be overcome by stopping the backend, removing the hdpvr module, cycling the power on the HD-PVR, modprobing the hdpvr module, and restarting the backend. You can set the bitrate for the HD-PVR by going into Recording Profiles, and editing the profiles associated with HD-PVR encoders. These recording profiles have bitrate settings for low (480i/p), medium (720p), and high (1080i) resolution material, allowing you to set appropriate bitrates based upon the resolution of the material.

If you have patched the driver or myth for any further functionality, or if you have a specific problem associated with the HD-PVR driver, you can join #hdpvr on Freenode. Under no circumstances will support in compiling mythtv be provided, nor will there be any walking through of the steps outlined above. If you are not comfortable with compilation, just hang in there! Better, stable support (and potentially backports to the .21 family) are coming soon.