Watch TV on Your Computer

Choose from a variety of Linux programs to watch TV from your desktop.

Your TV tuner is installed, all the cables are connected, and the card is recognized by Linux, but how do you actually watch TV with it? This hack covers some of the Linux tools you can use to configure your TV tuner and watch TV with it from your Linux desktop.

The most basic program you can use to watch TV under Linux is xawtv, which started as an application specifically for the bttv driver, but since then has been expanded to work with video4linux, so you can use it with a number of tuners. xawtv is a good place to start when you want to test your tuner because it has been around for quite a while, so it is not only well tested, it also is likely to be packaged by your distribution. To install it, find the xawtv package in your distribution’s package manager. If for some reason your distribution doesn’t package it, download the latest version of xawtv from the official download page at http://dl.bytesex.org/releases/xawtv and follow the installation documentation to compile and install it.

With xawtv installed, you could just immediately launch it; however, no channel frequencies for your particular tuner have been configured yet, so you won’t be able to tune into a channel. It’s possible to configure everything by hand, but xawtv includes a utility called scantv that scans the tuner for available channels (much like the scan function on many car stereos) and generates a configuration file for xawtv. Open up a terminal and type:

	$ scantv -o ~/.xawtv

	please select your TV norm
	0: PAL
		1: NTSC
		2: SECAM
		3: PAL-Nc
		4: PAL-M
		5: PAL-N
		6: NTSC-JP
		7: PAL-60
	nr ? 1

	please select a frequency table
		0: us-bcast
		1: us-cable
		2: us-cable-hrc
		3: japan-bcast
		4: japan-cable
		5: europe-west
		6: europe-east
		7: italy
		8: newzealand
	9: australia
		10: ireland
		11: france				
		12: china-bcast
	13: southafrica
		14: argentina
		15: australia-optus
		16: russia
	nr ? 1

	scanning channel list us-cable…
	1 ( 73.25 MHz): no station
	…

Since I’m in the United States, I selected NTSC for the TV norm and us-cable as the frequency table. scantv then scans through every channel at that frequency table for valid channels and makes a note of any it detects. It then outputs everything into ~/.xawtv. Now start xawtv:

	$ xawtv

There isn’t much to the interface by default—just a basic window with no extra buttons. Table 4-1 lists keyboard shortcuts you can use to navigate through xawtv. Use the up and down arrows to move through the channels, and left and right keys to fine-tune the frequency of a channel if it’s a bit off.

Table 4-1. xawtv key bindings

key

Function

up/down

Tune up/down one channel.

left/right

Fine-tune.

pgup, spacebar / pgdown, backspace

Change the stations in the config file up/down.

Ctrl-up

Scan for the next station.

F5–F12

Adjust bright/hue/contrast/color.

Esc, q

Quit.

+/-(keypad)

Volume up/down.

Enter (keypad)

Mute.

f

Toggle full screen.

g

Grab screenshot (full-size ppm).

j

Grab screenshot (full-size jpg).

o

Options window.

c

Channels window.

r

AVI recording window.

To configure xawtv, right-click on the window and choose from the number of configuration options in the menu that appears. If you didn’t run scantv, you can change the frequency table and TV norm from this menu instead. Remember to save your changes before you close xawtv so they will be there the next time you start.

Zapping

xawtv works fine, but it doesn’t have much of a GUI. Zapping is a TV viewing program designed for the GNOME environment, but it will work on either GNOME or KDE. Zapping is already packaged for a number of distributions, so check with your package installation tool first, and if it isn’t there, download and compile Zapping from the source package at http://zapping.sourceforge.net/cgi-bin/view/Main/Download.

To start Zapping, launch it from your desktop menu or type zapping in a terminal window. Zapping will automatically scan for valid video4linux devices and connect to the first one found. You must initially configure which video standard to use, so click Channels → Video standards and choose your standard from the list (I’m in the United States, so I would choose NTSC). If you have more than one video4linux device in your computer, click Edit → Preferences to open the preferences window, and then click Devices → Video. You can change the video device to use from this window, and click Devices → Audio to change your audio device. One nice feature of Zapping is that it supports OSS as well as ESD and aRts audio output. The preferences window also lets you configure a lot of other general options such as keyboard shortcuts and on-screen display settings.

Next you need to configure the channels for your tuner device. Click Edit → Channels to bring up the channel configuration window. Choose your region from the region drop-down menu, and then click “Automatic station search” to let Zapping search for channels for you. Alternatively you can have Zapping load the channel information from a xawtv configuration file. In this window, you can also assign names for each of the channels and a key binding so you can quickly switch to a certain channel.

You can change channels in the main interface either with the buttons on the toolbar, or by pressing PgUp and PgDown. The + and - keys control the volume. You can even take a quick screenshot with the s key.

Get Linux Multimedia Hacks now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.