March 11, 2004

Watch TV on your Linux computer

Author: Rob Reilly

Wouldn't it be nice to sit at your Linux machine and have a crisp little color TV screen right there in one of your desktop windows? Using a cheapo TV tuner card, you can get great picture and sound quality on anything from an old 133 MHz Pentium on up. The hardware requirements, at $20 for a TV card after rebates, are pretty modest, and the payoff is a lot of fun.

"Obsolete" hardware is a beautiful thing, when you can make it do productive work again. My Linux TV machine is a classic Pentium desktop box with the following components:

  • 133 MHz Pentium CPU, jumpered to run at 187 MHz
  • 128 MB RAM
  • 8 MB ATI Rage video card
  • Hauppauge Win-TV BT878-based TV tuner card
  • 3 GB disk
  • 8X CD-R
  • Generic audio card
  • Stereo speakers
  • Mouse and keyboard (these are optional)
  • 15-inch Sony monitor

Obviously, you can put a TV card in a more current desktop machine and be quite happy. I've found that the main factors influencing performance are video memory, followed by main memory. Increasing video memory allows for a larger TV window on the screen and better picture quality. For example, with a 4 MB video card, you can expect a nice color picture in a window of about 200x100 pixels. At 8 MB you'll get a clear picture at about 480x320. It's possible to make the picture bigger, to a limited extent, but it shows horizontal lines and noticeable lags in movements as you increase the window size and keep memory size constant.

Similar issues come up with regular computer memory, although they're not as pronounced as video memory. I've run TV cards on old Pentiums with 64 MB of memory and the performance is just OK. KDE comes up slowly, applications take a long time to load, and action on the picture is jerky.

Hook your computer up to TV input, like a cable connection or external antenna feed. My setup uses a BrightHouse Network cable feed.

Naturally you'll need to have Linux running on your TV box. The distribution I use is SUSE 8.2 Pro. It's a good mix of GUI-based and "do it yourself" configuration tools. The beauty of a distribution like SUSE is that you can use the GUI utilities or the command line, depending on your abilities and knowledge.

Mainstream Linux TV applications

When you install Linux you'll want to look up the TV applications that your distribution supports. There are several such TV programs in the SUSE 8.2 package, all of them mature and easy to use. I'll use one as an example for setup and operation, then point out some particulars you'll want to know about two other packages. Setup and operation are very similar across the three programs.

motv

motv is my favorite TV program because of its easy-to-use, mature user interface. It's actually a cool front end to the xawtv program, which we'll discuss shortly. motv should be available if you load the xawtv package. You can start it from the command line or from the SUSE start menu under Multimedia and Video. It first appear on the screen as a window that displays whatever video source is connected at the time. You can set the video source to the TV tuner, a composite video input, or USB video input, depending on what devices you have hooked up.

To watch TV with motv, begin by making sure your cable TV coax is screwed into the back of the TV tuner card and that you have a good TV signal. Make sure your sound card is working. You may need to start a sound mixer program, such as Kmix or smixer, to adjust sound settings. And don't forget to plug the audio output of the TV card into the line input on your audio card. The first time I used a TV card I sat there wondering why I couldn't hear anything, while puzzling at the little male-to-male audio cable that came with the card. When I made the connection, pardon the pun, I felt pretty doofy.

Once you've started motv, right-click anywhere in the video picture on the screen to see the motv control window, which lets you select Options and Frequency Table. You need to pick the correct channel type for your area. For me it's us-cable.

Next, select Options, TV Norm, and select NTSC if you're in the United States. You may have to use another protocol if you are in another location.

Select Options, Channel Scan, and then Start when the new window appears. The card scans through available channels from 1 to upwards of 115. (One limitation of current commodity TV cards is that they can't scan the whole range of 500+ channels available on cable or satellite service.) Scanning channels may take a few minutes. When the software finishes, you'll see a complete list of channels that it found. You can step through the ones you watch and edit the names to something you can remember. For example, channel 28 in my area is FOX News, so I added that name in place of "channel 28."

When you finish scanning channels and editing station names, and in fact anytime you change any settings, make sure that you save the settings, so that they are there when you start up motv the next time. Select Options and then Save Configuration.

Operating motv is easy. Simply click on one of the channels in the list to watch it. You can resize the picture by dragging a side or corner of the window.

You can explore motv's tool bar and find all kinds of settings to play with to optimize your viewing experience. Clicking on Options and Scales lets you change brightness, hue, saturation, and contrast.

Depending on the video devices you use, it's also possible to grab images and create AVI files using the appropriate buttons or selections from the toolbar. I've had good luck with grabbing pictures to JPEG format using input from the TV tuner source and composite video. I've also captured short video clips, though the picture quality and frame rates are understandably mediocre on the old 133 MHz machines.

xawtv

xawtv is very similar to motv. The biggest difference you'll see is in the simplicity of the user interface. It's basic! xawtv is a nice fast program, though, and has sliders for brightness, contrast, and so on built right into the control panel. The way the sliders work seems backwards to me; I have to right-click while rolled over the slider to get the control to decrease the value. Conversely, I left-click to increase values. xawtv lacks a channel scanning function, although if you configure motv, it will use that channel list.

Like motv, xawtv lets you use alternative video input sources, so if you want to hook up your video camera (composite video, not FireWire) and grab images or make video clips, you can do it with xawtv.

KWinTV

KWinTV is a member of the KDE family. It has a spiffy user interface with a little channel window and control buttons right below the tool bar. Although the interface is nice and offers lots of options to play with, KWinTV doesn't support alternate video sources, such as the composite input.

Much like xawtv, KWinTV scans the channels with a "wizard," and it can grab channels from the motv list.

One unique feature is KWinTV's IR control option, which lets you bind remote control events, such as pushing a certain button, to actions to be taken in KWinTV. Obviously you need an IR detector and the IR drivers set up on your machine. The feature is neat, although might be a little impractical, because getting IR to work on a Linux PC has been problematic and detectors usually are not installed on desktop machines. Still, I've seen some reports of people building personal video recorder boxes and using the IR functions, so if you have the time and patience to get it to work, it's there for you.

What else?

What else can we do with a cheapo TV tuner card and an old desktop Linux box? There are a few more tricks that you might be interested in.

Alternate video input

motv and xawtv have menus that let you select your video input. You can use board-dependent inputs like the tuner or the composite video jack, or you can plug in a USB camera to get your video image. Be cautious, though: some devices (particularly USB-based Web cameras) have driver problems. My five-year-old, $175 CPIA-based Webcam used to lock up my laptop when I was on the 2.4.18 kernel. I've since moved to 2.4.20 and have had much less trouble, except when I try to go to full-screen mode. Make sure you've set up your machine with a journaling file system if you're going to experiment with USB Webcams.

Remote control TV with x2x

In my article Cut the cord on your next presentation" I described using a remote control program called x2x that allows you to control a remote Linux machine and monitor via your local keyboard and mouse. When you want to work on the remote machine, you simply roll the cursor over to that screen and click or type your selections.

I've set up the Linux machine with my cheapo TV card to run without a keyboard or mouse, using x2x. Whenever I want to change channels or raise the volume, I roll the cursor from my laptop screen to the desktop screen and make the adjustments. It works great and helps keep my desk uncluttered.

Poor man's surveillance camera via X

Here's another fun video project. Take two wireless laptops and plug your USB camera into laptop number 1. On laptop number 2, ssh into laptop number 1 with the "-X" option. For example:

     ssh -X 192.168.2.3

You can then start up motv on laptop number 2 and see an image from the camera -- sorry, no audio. When you're using 802.11b cards the picture can be pretty jerky, with a lot of lag in the action. When I've used this technique with regular 100Mbps wired Ethernet, the action from the camera is much smoother.

That's a wrap

Overall, TV cards work very well under current versions of Linux. The key is to use as much video and main memory as possible. The performance is good even with aging hardware. The TV cards are very inexpensive and reliable. Look for sales on the cards at computer and office products retailers around holidays.

Rob Reilly is a freelance technology writer, speaker, and consultant whose articles appear in print and on the Web. He offers contracted writing and seminar services on OpenOffice.org, Road Warrior techniques, and business Web basics.