TV Tuner

This is a stub for using TV Tuners with Gentoo Linux.

See also Gentoo Linux VDR Guide

(Need entries for for kernel config of analog and digital tuner drivers.)

(Need entries for your preferred method of viewing and recording. I use the console and figured some would be interested how I do this. ;-)

Command Line Tools
The package is needed.

Console or Terminal Method
To get a list of channels from your digital TV USB or PCI tuning device, the dvbscan application from the package is needed.

For the US over-the-air digital TV:

Channel Naming Problems of DVBSCAN
The channel naming scheme for over-the-air digital TV is likely not well thought out in your area. The first field of this file is the lettered name field, of which, you may likely see duplicate identical names and no channel numbers. The remainder of the fields relate to the frequency.

For my area, the channel number reported by dvbscan on stdout is correct, but the channel lettered identification contains identical duplicates or is not well named. I have already emailed the linux-media mailing list on Sep 29 2011 to include a switch for writing the channel number to the file instead of the channel letter identification.

For the meantime, I've found a method of creating duplicate frequency entries, and then replacing the channel letter name field with the channel's number. More duplicated entries can be created to eleviate the need for typing ".1" for the first channel.

Linux Virtual Terminal with Framebuffer
Compile with +fbcon and +svga USE Flags. (In the latest mplayer versions, USE Flag svga is deprecated.)

Compile. This is a SVGA Linux Kernel driver for framebuffer console applications such as &.

Make sure to have booted Linux with a framebuffer enabled virtual terminal(s). Make the necessary edits within the bootloader configuration file. (ie. Lilo/Grub). (ie. Add "vga=788" or "video=uvesafb:nocrtc,ywrap,mtrr:3,1280x1024-16@60")

Up until quite recently, MPlayer could only be used within a plain Linux virtual terminal. It is now possible to use MPlayer even within a Linux virtual terminal running GNU Screen! Full size video playback using MPlayer within Linux virtual terminals doesn't seem to work here.

MPlayer: Slow CPU or Graphics Card
For most scenarios, playing live streams on slower machines is not possible. One solution around this is to first record the MPEG streams to file and then play them using your media player.

The following will resize your previously recorded MPEG to something adequately smaller. Use lowres=1 or lowres=2 depending on how slow your system is.

Normal Console or Terminal within Xorg
There's a multitude of media players, of which, mplayer seems to be the most popular and lightest on resources.

MPlayer will use the first field of each line within the channels.conf file for playback. If you have duplicate entries like I do and haven't renamed them as I've done so above, you'll need to specify the entire line from the channels.conf to play the second, third, fourth, ... duplicated entries:

Console or Terminal Method
There's several methods for grabbing EPG TV Guide data and printing to stdout.

Method 1: dvbstreamer
Q. How do I update the EPG data ... (Untested)

Method 2: atsc_epg
After much searching, I found atsc_epg (media-tv/linuxtv-dvb-apps)!

(According to LinuxTV.org, their linuxtv-dvb-apps package is now considered legacy code. No recent snapshot has been made of their dvb-apps GIT repository since.

Also, LinuxTV has a wealth of information on it's linuxtv-dvb-apps package.

Usage example. Take an entry from the $HOME/.mplayer/channels.conf (from dvbscan) and strip the first field. (ie. "KUAC-DTO:189028615:8VSB:49:52:3")

This will print a very nicely formated schedule to stdout!

Now automating this process to use $HOME/.mplayer/channels.conf (dvbscan) data is a bit of a trick, especially if channels are updated. However, notice the atsc_epg command only needs a frequency and atsc_epg will tell you the channel number(s) the frequency will resolve to on stdout as well. (ie. This one PBS frequency will broadcast all four PBS channel's EPG data along with printing each of the four channel numbers to stdout.)

Issues with Only One Tuner
The catch is, you need to have this run in the background while you are not recording as it will use the only tuner on your card for getting the broadcasted EPG data. When a recording starts, the recording script needs to check for this dvbstreamer and kill it before the recording starts, else the recording will fail to initiate as the only tuner is being used. The data being retrieved is simple ASCII text and can be likely easily parsed by even a script. I just haven't had the time to write such a script or console program, and the EPG data broadcasted here is not consistent with more accurate web based options such as TitanTV.

Console or Terminal Method
You can schedule to records a channel by creating a script to record (mencoder) a certain number of minutes (or hours) using vixie-cron (ie. crontab -e).

Create a recording script
One method is to create a script for each channel, such as the one below. One problem with this is, transmitter technicians keep changing the channel naming and frequencies. So it's wise to use my suggestion about creating aliases within the channels.conf file, noted at the beginning.

Another issue, more specifically with the below script, mencoder will possibly remux an already broadcasted MPEG2 stream even though specifying 'copy', causing A/V sync issues. As a result, I've gone ahead and created a more elaborate record-dvb.sh which can be found on my server. The record-dvb.sh script accepts a channel number and number of minutes and can be used via cron. This record-dvb.sh supersedes the below simpler script.

Schedule a recording
Setup a crontab entry, as user, root or within /etc/cron, but I prefer a user cron entry.

# Record Doctor Who #  Sundays @ 23:00 #0 23 * * 0 $HOME/bin/record-ch9.1-60m.sh #0 23 * * Sun $HOME/bin/record-ch9.1-60m.sh   0 23 * * Sun $HOME/bin/record-dvb.sh -c 9.1 -m 60

#  Thursdays @ 20:00 #0 20 * * 4 $HOME/bin/record-ch9.1-60m.sh #0 20 * * Thu $HOME/bin/record-ch9.1-60m.sh   0 20 * * Thu $HOME/bin/record-dvb.sh -c 9.1 -m 60

Save and exit your console editor of choice. No need to restart cron as changes take effect immediately. (Read 'man 5 crontab' for an explanation of crontab field names.)