Hauppauge HDPVR in Linux

Post date: Apr 29, 2012 7:13:25 PM

hdpvr image

This is a HD video recorder that encodes component HD (or composite) signal to mp4.I originally bought it to work with my MythTV setup but it was a bit to unreliable to use with MythTV. That being said... It does work and works well, it just needed to be reset every time it gets used, so I use it to manually record HD from my Shaw Direct satellite box, my BluRay disc or other sources (like Hi8) that I want to transfer to disk.It encodes x264 with A52(AC3) to an mp4 file!In GNU Linux distributions you set it up with Video 4 Linux 2 (V4L2) - v4l2-ctl command that allows you to configure its video settings and encoding settings. The MythTV Wiki page has all the details.Here is how I tweaked the settings to get it running reliably.1st off I updated it to the latest firmware - version 1.7.1 which fixed a major problem I was having. Follow these directions to upgrade firmware. Previously it would not handle the input signal switching its resolution. Now it rides right through without exiting the recording!

I will now test it to see how reliable it is and then connect it back to the MythTV.

It has been working really well. It is finally stable. no more hanging or quiting recording mid-video.

The over saturation problem with the driver settings is still present, but its an easy fix with the last v4l2-ctl call (see below).

After it gets turned on I run an init script to get all the config settings the way I like them...

HDPVR init script

#!/bin/bash -v

# Gets the HDPVR setup with good settings

MPEG4_IN=/dev/hdpvr # sym link to /dev/video1

sudo rmmod hdpvr

sleep 10s

sudo modprobe hdpvr

sleep 5s

# bitrate_mode 0=VBR, 1=CBR

sudo /usr/bin/v4l2-ctl --verbose -d $MPEG4_IN -c video_bitrate_mode=0

sudo /usr/bin/v4l2-ctl --verbose -d $MPEG4_IN -c video_bitrate=10000000

sudo /usr/bin/v4l2-ctl --verbose -d $MPEG4_IN -c video_peak_bitrate=16500000

#

#If you wish to see more verbose dmesg output, you can use the following module option:

# hdpvr_debug=#

# Where # = an integer between 1 and 7, increasing in level of verbosity.

#

# video_nr=#

# Sets the device node to /dev/video#

#

# default_video_input=#

# default video input: 0=component, 1=S-Video, 2=composite

#

# default_audio_input=#

# default audio input: 0=RCA back, 1=RCA front, 2=S/PDIF.

#

# Audio IN 0=RCABack 1=RCAFront 2=SPDIFsudo /usr/bin/v4l2-ctl --verbose -d $MPEG4_IN --set-audio-input=0

# Video Input IN 0=component, 1=s-vid1(front) 2=composite1(front)

sudo /usr/bin/v4l2-ctl --verbose -d $MPEG4_IN --set-input=0

#

# For firmware 0xf, default audio input must apparently be set to 2 to enable spdif/optical recording.

# This does not change the encoding default (AAC) and does not up-convert to 5.1 if the spdif/optical input is stereo.

# Simply edit /etc/modprobe.d/hdpvr.conf to have this info (without quotes):

# "options hdpvr default_audio_input=2".

# If this doesn't work for you or if you want to be able to easily change it on the fly, try this script

# https://github.com/davidstoll/HDPVR-config

#

# if using SPDIF the ctrl "audio_encoding" has to be 4 [3=AAC - 4=AC3] or you get an empty file

# audio_encoding [3=AAC - 4=AC3]

# I found to use the SPDIF the STB has to also send AC3 or you get silence

sudo /usr/bin/v4l2-ctl --verbose -d $MPEG4_IN -c audio_encoding=4

#

# Patch for new firmware BUG

#

sudo /usr/bin/v4l2-ctl --verbose -d $MPEG4_IN --set-ctrl brightness=0x80 --set-ctrl contrast=0x40 --set-ctrl hue=0xf --set-ctrl saturation=0x40 --set-ctrl sharpness=0x80