Friday, June 28, 2013

Streamlining spur-of-the-moment recording with HD Homerun (Rev A)

(Rev A - see Notes)

The HD Homerun GUI provided by Silicondust is pathetic, as you can discover for yourself by using it to set one tuner to one subchannel within a channel, and the other tuner to another subchannel within the same channel, and then entering a "save" command (hdhomerun_config <tuner ID#> save /tunerN <FileName>.ts, where N is 0 or 1 in a dual-tuner unit) for each tuner. (This requires using one terminal for each tuner to avoid having to use background/foreground commands, which would be required to use the same terminal-window to control both recording processes.) For a complete listing of HDHR commands, find hdhomerun_development.pdf on the internet.

Let the recording processes run for a while, and then close the terminal-windows to stop recording. Then use the VLC player to examine the two files just recorded, and you'll find that both are the same. 

So, I came up with a method to avoid having to use this sorry excuse for a control panel, and to make it as easy as possible to record two channels simultaneously on the spur of the moment, without having to learn to program in Python and to create a GUI's with GTK+ to create a proper GUI for the HD Homerun. (I suggested such a program to the HD Homerun Recorder's developer, and perhaps he'll get around to it some day. But in the meantime, my system is tolerable.)

My system consists of a list commands for each tuner, which are then copied and pasted into terminal-windows. The idea is to minimize the need to alter any commands before copying and pasting them (the only field that requires alteration is the FileName field in the save command), and to make them as easy to find in the list. Each list consists of a set-command for each channel and subchannel that I might want to watch (it's necessary to set the channel, and then the subchannel, to tune in a program - use the HDHR's GUI to perform a scan and get all the channel/subchannel information) and a single save command, whose FileName slot must be modified to some unique name to prevent recordings from being overwritten, and to allow the file to be easily identified later.

I put quite a bit of effort into designing these lists to be easy to use, and I've included an excerpt from one of them as an example. I also spent quite a bit of time looking for a convenient way to copy and paste the commands into the terminal, and in the process learned of a key-combination (Shift-Insert, which I gather is widely known) which allows text to be highlighted, and then pasted into another window by simply clicking on the other window and then pressing Shift-Insert. Try it, and I think you'll like it.

Here's an excerpt from my list for Tuner1:

-->
Tuner 1


Save

hdhomerun_config 1038702F save /tuner1 <program designation>.ts

==========================================

Set

4

hdhomerun_config 1038702F set /tuner1/channel auto:23

hdhomerun_config 1038702F set /tuner1/program 1

=====================================

6

hdhomerun_config 1038702F set /tuner1/channel auto:30

KUAT

hdhomerun_config 1038702F set /tuner1/program 1

Ready-TV

hdhomerun_config 1038702F set /tuner1/program 3
====================================

9

hdhomerun_config 1038702F set /tuner1/channel auto:9

KGUN

hdhomerun_config 1038702F set /tuner1/program 3

Classic

hdhomerun_config 1038702F set /tuner1/program 4

LWN

hdhomerun_config 1038702F set /tuner1/program 5


[End of excerpt]

Note that except for the Save command (which must be altered to suit each recording), the commands are small, because at this point there's no need to read them, but to just highlight them for pasting with Shift-Insert into the terminal-window of interest. Making them small also reduces the amount of scrolling required to find a particular command. The labels are large so the commands can be found easily.)

Set-command formats

The general format of the channel-set command is as follows:

hdhomerun_config <tuner ID#> set /tunerN/channel <modulation-type>:<channel>

The tuner's ID number is on the rear of the unit, and it can also be obtained from the GUI once the tuner is set up and connected to your computer. (Two numbers will be listed - the ID # is the one that's the same in both cases.) For modulation-type, I use "auto," which is one of the options. For the others, refer to the HDHR development guide, which can be found by searching for hdhomerun_development.pdf on the internet. The channel-number is the physical channel, not the virtual channel. (The virtual channel is the traditional, pre-HDTV channel for the station of interest.)

The general format for the set-subchannel command (a.k.a. the "filtering" command because it filters out the unwanted subchannels) is as follows:

hdhomerun_config <tuner ID#> set /tunerN/program P

where N is 0 or 1 for a dual-tuner unit, and P is the "program" number associated with the subchannel of interest. 

All of the information required for the set commands can be found by tuning in the channel of interest with the HDHR's GUI, and examining the drop-down list of subchannels associated with that channel. The program number is the first number in each entry on that drop-down list. I suggest using the GUI to perform a scan of all channels, and creating a list of channel numbers and program numbers associated with each subchannel of interest. 


Notes
Rev A: Added Set-command formats section

 



Saturday, December 15, 2012

HDHR Recorder installation tips

Rev  G (see Notes)

HDHomeRun Recorder is a program which can turn the combination of an HD Homerun (an external tuner which contains two or three silicon tuner ICs and some logic to wrap their outputs in a network protocol to allow them to be placed on a computer network or fed into a computer's ethernet port) and a computer running Ubuntu, into a DVR. It's the only program I've seen (besides Microshaft's Windows Media Center) that delivers on the promise of turning a PC into a DVR. Because it's written for a specific tuner (the only one worth having, in my opinion, although overpriced and poorly documented due to lack of competition), and it requires the user to program recordings like a VCR would be programmed, it is far smaller than those that supposedly try to cover all tuners and automate the programming. I've used it with a single HDHR with two tuners to perform timer-type recordings of two channels simultaneously, so you can rest assured that if you install and use it properly, your efforts will not be wasted. Just be sure to download it from the official site, which contains a README file with installation/use instructions.

Before HDHR Recorder can be used, the HDHR and its software must be installed, and this is covered in the blog-entry below this one. However, the easiest way to install the HDHR's software is to install the hdhomerun software package offered by  Ubuntu Software Center (USC). I believe that the VLC player is included with this package, although if not, it is included with the packages provided by the Synaptic Package Manager (assuming there are any differences, which I doubt). Synaptic PM, which has functions which the USC doesn't have as of this writing (such as the ability to generate download scripts to allow software packages to be downloaded on other computers, which is handy if your computer has a slow internet connection) would have to be installed via the Software Center since it doesn't come with Ubuntu.

The HDHR's software consists of hdhomerun_config and hdhomerun_config-gui.  The _config program allows the HDHR to be controlled, and its outputs to be saved to a hard drive, by entering instructions into a terminal-window (see entry below for details).  The _config-gui program provides a control panel to make it convenient for the typical computer user to perform some basic functions with the HDHomeRun, but not to record.  The VLC Player can record the program being viewed by pressing its record button, which doesn't appear unless the "advanced controls" option is chosen. To record two (or more) programs simultaneously, you can enter appropriate commands into terminal-windows (one for each tuner), or program the HDHR Recorder to do so.

The latest version of HDHR Recorder is a major upgrade, and the installation and use has been drastically simplified. So, the original impetus for this entry has been largely eliminated, but some people might still need to have the README file's first couple of installation instructions translated, so I retained the relevant portion of the previous revision, as follows:

1. Install python if you don't have it already

Translation: If you have a recent version of Ubuntu, you already have a recent version of Python. To find it, and its version, open a terminal-window by pressing Ctrl-Alt-t, and entering "whereis python" (without the quotes).

2. Install apscheduler from here. The old version of apscheduler has some issues, so be sure to install the latest V2 version. (https://bitbucket.org/agronholm/apscheduler)

Translation: The easiest way to install apscheduler is with a python installation-utility known as pip, which is the replacement for EasyInstall, which based on something I've read has problems and isn't being maintained any more. To learn whether you have pip, just open a terminal-window (Ctrl-Alt-T), type pip on the command line, and follow the instructions which then appear in the window.

To install any software, you have to give yourself Administator powers by starting the command with "sudo." It will ask for your password, assuming you specified one when you installed the operating system. It will automatically install the latest appropriate version and any other components required.

Then, once you get pip installed, enter the following into the command line:

sudo pip install apscheduler

and follow the Terminal's instructions.

The rest of the installation, and the setup, have been automated, and I assume that they've been tested and that they work properly.  (I haven't had time to try it yet.)


Notes

Rev G: Eliminated the majority of the entry because HDHR Recorder and its documentation have undergone a major upgrade which drastically simplifies its installation and use.

What it does, and how to make it do it

Rev C (see Notes)


The HDHomeRun is a digital TV tuner designed to be connected to ethernet ports. It produces amazing picture and sound quality even with weak signals, as is typical of the silicon tuner ICs it uses. Of course, if the signals are barely detectable in your area (see TVfool), you'll need an antenna placed where it can make the most of what's available (see HDTV Primer), and with enough gain to boost the signals to a level suitable for an antenna preamp. Once that's done, you should have no problems getting amazing video and audio.

You'd think that SiliconDust would spend some of their obscene profits on documentation for Linux. Windows installation is automatic, so no Windows documentation is required.

After flailing about for a couple of days thanks to the lack of decent documentation, I discovered that the necessary software (hdhomerun-config and hdhomerun-config_gui) can be installed automatically on a computer running Ubuntu, via the Ubuntu Software Center. Or you could get a degree in programming, and do it manually.

Then, by entering some simple commands (outlined below) into command-lines in terminal windows, you can save the HDHomeRun's output directly to your hard drive with no conversion to another format, so the recordings are also amazing, but they consume a lot of disk space. (By the way, the xfs format is the most efficient for recording and deleting those potentially vast ts files, so you might want to create a partition for the directories where recordings might be saved and give it the xfs format.)

The HDHomeRun can be connected directly to PC's, and this paragraph describes how this is done with a computer running Ubuntu 12.04. (Connecting the HDHR to a router would be simpler, if you had a router.) In Windows, this setup is totally automatic, but in Ubuntu, it's only partly automatic. In Ubuntu (as with Windows), you have to first connect the signal and power to the HDHomerun, and connect it to your PC. Then you open the System Settings ("gear" icon on left of screen) and select Network, select Wired, and then set the on/off button to On. Then, you click on Options, then IPv4 Settings. Then, in the Method box, select Link-Local Only, and Ubuntu will automatically establish a connection to the HDHomeRun. The exact procedure will vary between some versions of Ubuntu, but I assume there will be some resemblance. If the HDHR and your computer ever have difficulty establishing a connection, after having established connections previously, go into System Settings/Network/Wired and verify that the port is turned on. Sometime clicking on Rescan in the HDHR control panel helps.

At this point, you should be able to fire up the HDHomeRun GUI by clicking on its icon on the left side of the screen (assuming you let the Ubuntu Software Center install the HDHomeRun software, as described above). You should also be able to find channels and view them via the VLC player. (If scenes with motion appear "smeared," this could be due to the VLC player's difficulty with de-compressing the amount of compression used by that station. One fix is to record it and convert it to another format before viewing.) YOU CAN ALSO SAVE THE PROGRAM YOU'RE WATCHING to Downloads by clicking on the Record button, which can be made to appear by clicking on View in the main menu, and selecting Advanced Controls.

The VLC player produces smeared/pixelated video when playing some programs on some  systems, because some high-definition programs require a lot of processing to decode "on the fly" due to the amount of compression used in encoding them. This is a complex issue that's beyond the scope of this entry, so I won't mention all of the things I considered in the course of finding a solution that works for me, which is to save the program to disk, and convert it to a format which is easier to play. A "transcoder" program called Handbrake performs such conversions very simply, and with satisfactory results. You just need enough space on your drive for the source file and the output file.

As far as I know, VLC doesn't facilitate recording both tuners' outputs simultaneously. Its documentation doesn't say anything about recording, and there's nothing about recording with VLC on the internet either (or at least there wasn't until this was published), other than a passing remark about the hidden Record button.

However, there is a way to record the outputs of both tuners simultaneously without installing any more software. It requires typing (or copying/pasting) text into the Linux command-line, which is accessed by pressing Ctrl-Alt-t. Pasting into the command line in done with Ctrl-Shift-v.

First, set each tuner to the desired channel, and note that each tuner has the same ID#, followed by -0 or -1 (displayed in the GUI). Then open two terminal-windows, because once you start a recording process in one window, you won't be able to enter any more commands into it.

Then decide where you want to put the recordings (.ts files) and change the directory (folder) to that directory by typing cd Downloads or cd Videos (or whatever folder you want to use) into the command line, and pressing Enter. (Note: the cd command is case-sensitive, so that "videos" is not the same directory as "Videos.") Then decide what you want to name the files. In the first, terminal, enter the following command:

hdhomerun_confg ID# save /tunerN filename.ts,

where ID# is the tuner's ID#, N is 0 or 1, and filename is the file where you want to save that tuner's output. (These commands can be found in the HDHomeRun Development Guide, which can be found by Googling the title.)

That should start the recording process for that tuner, and the terminal-window will start filling up with dots to indicate recording in progress.

To record the other tuner's output, do the same thing in another terminal-window.

To stop EACH recording, click on the ID# of the associated tuner in the GUI "control panel," click on Stop, and then close the associated terminal-window.

Once you're done recording, you can close the terminal windows, open the VLC player, and open the recording you want to watch.

Those who want to automate recording to a degree similar to that of programming a VCR should consider HDHomeRun Recorder. The official page can be found by Googling "hdhomerun_recorder" (with the quotation marks and the underscore). As of this writing (12/12), the best set of instructions I've seen on installing and using it (besides mine) is contained in the Michigan Telephone blog, evidently written by a programmer.

Notes
Rev C: In section on setting up partition with XFS format, suggested using the partition for all directories where videos might be saved, instead of just the Videos directory. Experience has shown me that they the VLC player puts them in the Downloads directory, and that other methods of saving the files put them in other directories. 
Rev B: Revised paragraph about video smearing/tearing when being played by the VLC Player.  The previous revision seemed to put the blame on the VLC Player itself, when it's actually due to the demands which it puts on the system in some cases. There are entire forums dedicated to this issue, so I can't cover all the bases here.