Recording TV from HDHR-Connect 1

Posted by JD 12/13/2016 at 12:00

Got a new toy recently, an HDHR4-US (also known as an HDHR-Connect) from SiliconDust. These are the guy who have been making the HD-Homerun network TV tuners for years.

This device is added to my antenna connections providing 2 more tuners for use on the network. But it is different from my other tuners. It is a DLNA provider. That means all sorts of things are possible, but mainly it means that there is a URL that will return a video mpeg2 transport stream with content, if we know the correct URL. Thankfully, the main webpage produced by the device – just on port 80/tcp – shows the URL under the channels link. We can tune to any digital station (not by the RF frequencies).

The Script

Anyway, wrote a tiny script to record TV:


#!/bin/bash

CH=“$1” # digital channel 2.1, 2.2, etc…
DUR=“$2” # in minutes
DATE=`date “+%y%m%d-%H%M%S”`

WGET=/usr/bin/wget
TIMEOUT=/usr/bin/timeout

TRANS=“?dlna&transcode=mobile”
URL=http://hdhr4:5004/auto/v

if [ “X$DUR” = “X” ] ; then

echo “$0 channel duration(min)” exit 1;

fi

\# Set the timeout for 3 min longer than duration
$TIMEOUT $((DUR*60+180)) $WGET O $DATE$CH.ts $URL$CH$TRANS

Like the use of timeout to control how long? So far, the duration hasn’t been working. Sometimes the recording is cut off early. Can only guess this is due to an interruption of the stream.
The DLNA and mobile options don’t seem to work. Think they are ignored and only useful for a different model of HDHR.
Anyway, this is the start of a little script that will probably grow over time to deal with stream interruptions and add schedule data information to the filename.
Oh – and the “hdhr4” in the URL is set thanks to DHCP reservations and /etc/hosts entries. Effectively making it have a static IP which is always the same on this network. The other HDHR devices here are similarly configured.

Watching TV using DVR Capabilities

By recording to a file, we can use a video player like vlc to watch, rewind, fast-forward through the file as needed without interrupting the recording. This assumes the computer has sufficient disk I/O performance and CPU to support the multiple programs. A Raspberry Pi might not. I don’t know. My Core i3 Chromebook does. No issues at all. Plus watching 1080i channels isn’t an issue at all.

What Else?

The HDHR4 is viewable using vlc or Kodi or android DLNA clients like Bubble-UPnP or even Win7 Media Center. For some reason, the Kodi TV plugin doesn’t attempt to support “recording.” Don’t know why. As you can see, it does just need to save the stream for a specific period of time.

Raspberry Pi v2

Running Kodi on a r-pi v2. HiDef h.264 works great. SD for xvid/divx/mpeg2v4 videos also works great thanks to drivers that decode it using the GPU, not the CPU. The CPUs can keep up easily. However, for mpeg2 video in hidef, the CPUs can’t keep up and a paid driver (just $2.61) is required. Without this, sometimes the r-pi switches to a different video mode with 1080i inputs and scrambles the video output.
There are 2 addons to be installed inside Kodi to get this working. The hdhomerun video addon and the pvr-hdhomerun-client addon. After adding the pvr addon, a kodi reboot seems necessary to get the “TV” menu option to show up.

The HDHomerun video addon is needed to be installed and it can be used to watch TV, but it routinely locks up. Turns out that using the PVR addon to interface with it is very solid for non-HiDef content.
For years, I’ve had a r-pi that couldn’t be used to watch live TV. That will be a change – to be able to watch live TV.

Kodi on Normal Ubuntu x86/amd64 Computer

TBD – haven’t setup the stuff needed to make this work yet.

Win7 Media Center

HD Homerun Connect works well with media center, as expected. But since 7MC limits the total number of tuners that can be used to 4, I have disabled the new DLNA Connect version from it, so devices that only support the DLNA method can use it. The tuner does seem to be slightly more sensitive than the other HDHR3 tuners on the network here connected to the same antennas.

Networking Suggestions

As always, avoid using WiFi. The HDHR tuners are not wifi and those devices should be wired. They need a solid network connection. The same applies to any other devices that are used to watch/record TV. This is a basic thing, however, certain devices cannot watch TV except over wifi, like a Android tablet. To get the best possible network performance, have as few network devices attached to the wifi network during streaming. I consider this common sense, but many people just don’t understand that wifi networking is not very stable from a computer’s standpoint. The bandwidth changes constantly due to atmospheric conditions inside our homes. If you don’t believe me, there are wifi network testers where you can watch as the available bandwidth changes 50% and more.

  1. JD 01/06/2017 at 19:13

    Recording TV from the HDHR4 and capturing that using a Raspberry Pi v2 is working using the script above. My Pi doesn’t have external storage, so this isn’t a long-term viable option. Did it just to see that it was possible. Wrote the mpeg-ts file to the SDHC card. Worked fine. Looking at top, the CPU for the wget never exceeded 5%. At the same time, I was watching a transcoded DVD. No issues at all. Thanks to h.264 GPU decoding, the CPU never got above 40%.

    I’ve been making incremental improvements to the recording script. Also wrote a transcoding script that gets called after the capture period is done. It deals with 3 different types of recordings

    1. hi-def – h.264+vorbis/mkv limited to 720p resolution.
    2. sd-def – h.264+vorbis/mkv at the input resolution.
    3. sd-def – copy mpeg2-ts audio and video into mpeg2-ps for extremely compressed channels.

    Why? One of the broadcasters in this area puts about 20 different channels into their 20Mbps bandwidth. They compress so much that artifacts are clearly seen in their mpeg2. Transcoding using h.264 actually makes the file larger.

    I wouldn’t transcode on the Pi. It would take weeks.

    On another machine, I’ve modified the script to grab the stream from the HDHR4 and transcode it using ffmpeg directly into 264+vorbis/mkv. To use this all the time will take some more work, since settings are different for SD vs HD content. Think a lookup table of HiDef channels vs SD channels is the easiest solution. Either that or transcoding a 5 sec pre-file and using it to determine the resolution of the channel first … hummmm. That could work.