September 25, 2003

And the winning Linux TV program is: tvtime


- by Joe Barr -
If you're like me, you have used XAWTV or Xine or similar applications for Linux over the years to watch TV at your PC. It may have taken a little bit of tinkering, but at least you could have live TV on your desktop. Well, I have news good news. There is a new TV player in town. It's called SourceForge, and it's a dandy. It's easy to install, easy to use, and it works great on my old Hauppauge WinTV card. As a special bonus, you can plug your console game station into the TV card and use tvtime to play GT3. Here's a review of tvtime along with a little info from and about its creator, Billy Biggs.

Prior to downloading tvtime, of course, I had the necessary hardware installed and configured on my system. I'm running Red Hat 9 with Ximian Desktop 2 on a 1 GHz Athlon with 512 MB of SDRAM. The TV card is a an old Hauppage WinTV which kudzu (the Red Hat program that keeps up with your hardware to add/remove configurations as necessary) recognizes as needing the bttv driver. In order to get sound from the WinTV card, I run an audio line from its line-out connection to my SoundBlaster Live's line-in.

The download page on the tvtime homepage is well organized. If you're running Red Hat, Debian, Gentoo, SuSE or Mandrake, you'll find the distribution specific package you need there. If not, you can grab the source code and build it yourself.

By the way, Billy Biggs and his friend Doug Bell (also a tvtime developer) have just published an editorial on about the lessons they have learned from tvtime packaging. If you're a Linux developer, you might want to read it.

I don't believe this is true for all distribution packages of tvtime, but the Red Hat rpm installs tvtime as suid. Biggs explains why a video processing application like tvtime needs to have root privileges. It's basically for two things: access to the rtc and SCHED_FIFO.

Biggs said "The RTC device is the real time clock and it can be used to send an application an interrupt at a resolution of 1/64th of a second up to 1/8192th of a second. The device is quite restrictive, only one application can use it at a time, and unless you are root or have configured it via /proc, you can only use it to get interrupts every 1/64th of a second."

He continued by saying "Running SCHED_FIFO lets tvtime take up almost all of the CPU and never miss a frame. Why? Because it can never be stopped by having some other process decide that it wants to do something."

The real bottom line is performance. Biggs noted "For a user like me watching NTSC content, tvtime must wake up every 16.6ms to draw the next frame, deinterlacing takes 8ms to do well, and then it takes (for me) about 4ms to draw it to video memory. That's 12 out of every 17ms being used by tvtime. Obviously, to ensure this is smooth even if other processes are running might require stronger priority systems than reniceing."

But what about security concerns with suid programs? Biggs answered by saying "Is it a security risk? We try to minimize this, like anything else, we drop root privs on startup and do 'the right thing'. Having a setuid executable could mean that if someone broke into your box, they could get root access. It's not unreasonable to be paranoid, but it's naive to think that no multimedia applications require root access to do their job well."

I left tvtime suid because I was convinced there was a valid need for it and also that some thought had been given to issue of security.

Starting tvtime for the first time brings up a configuration screen which allows you to do things like Station management, Input configuration, Picture settings, Video processing, and Output configuration. I just needed to choose two of those to get started.

I did Input configuration first. The TV card was being fed by an outside antenna, so I selected Television as my video source (instead of Composite1, Composite3, or S-Video), and NTSC for the Television standard (as opposed to other standards used in Europe and around the globe).

Then I went into Station management and selected Broadcast instead of Cable for the Frequency table before asking tvtime to scan all the channels to build a list of what is available to me. It took about a minute and when it finished I was watching and hearing the first station on the list. The results of the scan are stored in an xml file in the .tvtime directory created in your user home directory.

I visited the configuration screen later to see what other knobs and tweaks were available. There are quite a few. For one thing, you can adjust your audio mode by selecting from mono, stereo, or SAP. For another, you can fine tune individual channels to improve reception. The results of your tuning efforts are stored in the channel list so you don't have to repeat the process. You can also adjust the sharpness of the image by choosing from low, moderate, standard, and high sharpness (they range from 360 to 768 pixels).

You can also adjust the picture by changing its brightness, contrast, color, and hue.
Under the heading of Video processing, I found a category for "Deinterlacer configuration." I didn't understand the impact of any of the choices, so I left it at the default "Television: full resolution."

The frame rate is also user selectable. You can attempt the high of 59.94 frames per second or go with half that number while deinterlacing either the top fields or the bottom fields. Exactly what "deinterlacing the top fields or the bottom fields" means, I don't know. But it's great a great cite to use when impressing those who know less than you do.

There are also five input filters you can experiment with, as well as selecting from a number of different output settings including a 16:9 frame. Be sure to click on "Output configuration" from the Setup menu before you leave, or else the changes you make won't be saved.

One of the things I like best about tvtime is its ease of use. I will not say that it is intuitive, but I will say that it is very easy to learn to use, and to actually use. Example. Volume up/volume down use the +/- keys. To mute the card press "m", to toggle on-screen captions press "c", to change channels use the arrow keys, and to toggle between full-screen and windowed video modes, simply press "f."

Another thing I like is the great picture you get with it. I get a sharper image of local Austin stations on my PC using an outdoor antenna and tvtime than I do with my 35-inch RCA being fed by Time Warner cable. Of course, I could easily feed cable to the WinTV card as antenna input. To handle that change in tvtime, all that I would need to do is change the Frequency table selection (under Station Management in the config menu) from broadcast to cable and rescan the channels for my local directory.

One thing not (yet) available in tvtime is the ability to record video streams. But the web site is asking for volunteers to assist in developing this functionality, so I hope some of you decide to pitch in and help get this added, because it would be great to have. Did I mention that tvtime is not yet to its 1.0 release? I am running the 0.9.10-1 version.

I've exchanged a number of emails with Billy Biggs since I started this review. One of the questions I had for him was when the 1.0 release would be ready. He replied "I wanted to have 1.0 out this summer, but I'm waiting now until we can solve European config problems in tvtime. North American TVs don't work like those in Europe: I have CNN on channel 18, assigned that way By the cable company, and it is always on channel 18. In Europe, TVs scan for signal and begin assigning numbers as they find active channels.So, since CNN for me is, say, the 15th active channel, it would get number 15, and I would be able to edit my station list via an OSD."

One of the changes for this release was to eliminate the LIRC (infrared) support found in earlier versions and replace it with the tvtime-command program.
This program allows you to control tvtime from a command line while it's running. It also allows you to take screenshots of the tvtime window. That's a very handy feature since neither the GIMP nor import can capture anything but blue screen from it. As explained in the FAQ on the tvtime web site, "tvtime outputs video into a video overlay surface, an area of memory outside of the framebuffer, using the XVIDEO X extension. As such, applications which take screenshots such as ksnapshot, gimp or xwd only see the colour keyed window, and not output of tvtime."

When I experimented with the SCREENSHOT command and then tried to use the GIMP to display the image, I got a warning message from GIMP stating that the image resolution was "out of bounds." A query to Biggs about this resulted in a very detailed technical explanation involving hypothetically squared pixels. He also put it in language I could understand by saying: "we believe the error message from gimp is harmless, And we believe it is a bug in the gimp. We have not yet forwarded this bug report up since we are slack bastards."

Joe Barr awards tvtime the coveted
joey award for Linux TV excellence (below)

Biggs also explained how I could make the screenshots more accurate, like those tvtime uses on its website. Assuming you are using the standard resolution in tvtime, you would load the image in the GIMP, force the resolution to 640 x 480, then crop it by taking the middle 608x456 pixels and setting x to 16 and y to 12 for a starting point, and then save.

In the course of our email exchanges, I learned a little bit more about the history of the tvtime project and its creator. Biggs is currently "working on his masters at Dalhousie University in Halifax, NS, Canada." Other open source projects he has done include kphone ("the first open source SIP-based IP phone for Linux"), movietime ("a DVD player app that nobody has heard of"), and ttrk "a MIDI sequencer."

Biggs began tvtime in 2001. He told me that school sidetracked him for a bit, but when summer came "my friend Doug Bell was annoyed that none of the Linux TV apps gave full 59.94 fps framerate output and this was no good for playing dreamcast games with a capture card. He had success with tvtime, and began trying to turn it into a proper TV application. By October we had our first release of the new tvtime."

This is a very nice app: it looks professional and its performance is superb. Not only that, but tvtime source code is showing up in other open source projects: in xine, freevo, and mythtv for example. There is a tvtime support/development channel on called #livid, and you'll often find Biggs (his nick is vektor) in active conversation there. Biggs and the other developers seem to care a lot about tvtime's looks, performance, and ease of use. And it clearly shows.

Update: Billy Biggs has pointed out a couple of errors in the story. The default deinterlacer is not "Television: Full Resolution" but rather "Motion adaptive: advanced." Also, support for LIRC has not gone away in the new release. The change was in how LIRC and tvtime communicate. There is a page on this subect on the tvtime website.

Joe Barr has been writing about personal computing for 10 years, and about Linux for five. His work has appeared in IBM Personal Systems Journal, LinuxGazette, LinuxWorld, Newsforge, phrack, SecurityFocus,, and He is the founder of The Dweebspeak Primer, home of the official newsletter of the Linux Liberation Army, an organization in which he holds the honorary rank of Corporal-for-life.

Click Here!