Here's another one of those spiffy guides:
Setting up a TV tuner card in Linux
Because of a fairly hot deal at Newegg that appears to be here to stay, about half of the people on the AT forums now have Leadtek WinFast TV 2000 XP Deluxe TV tuner cards. This card, like most other non-ATI tuners, is based on the Brooktree BT878 chip, which is fully supported under Linux and FreeBSD. This guide will explain how to get a BT878 card up and running under Linux.
The first thing you must do (after hooking up the card) is recompile your kernel with Video for Linux (V4L) and the
bttv driver. Note that kernel 2.4.20 and below do not include the bttv driver, so you will need to patch the kernel. 2.4.21 and up do include it, although the version included might be a little out of date.
Anyway, to enable the needed features, run the kernel configurator on your favorite kernel source tree, and enable these options:
Multimedia Devices → Video for Linux
Multimedia Devices → Video for Linux → BT848 video for Linux
Character Devices → I2C support → I2C support
Character Devices → I2C support → I2C bit-banging interfaces
Then compile and install the kernel as usual.
Now V4L and your TV tuner should be fully functional. You can check dmesg to make sure. Look for something like this:
bttv: driver version 0.7.104 loaded
bttv: using 4 buffers with 2080k (8320k total) for capture
bttv: Host bridge is PCI device 10de:01e0 (nVidia Corporation)
bttv: Bt8xx card found (0).
bttv0: Bt878 (rev 17) at 01:09.0, irq: 10, latency: 32, mmio: 0xe5000000
bttv0: detected: Leadtek WinFast TV 2000 [card=34], PCI subsystem ID is 107d:6606
bttv0: using: BT878(Leadtek WinFast 2000/ W) [card=34,insmod option]
i2c-core.o: adapter bt848 #0 registered as adapter 0.
Now, the V4L backend is up and running, so now you need a frontend. Most people talk about XawTV like it's the only game in town, but Linux is all about choice, and I prefer to use
mplayer, so the next part of the guide will tell you how to use it for your TV viewing and capturing needs.
First off, you should install LAME. MPlayer can use it to encode captured audio in MP3 format. Most distributions include a precompiled package, otherwise it's just ./configure && make && make install.
Then, download the latest release of MPlayer, extract it, and enter its directory. You might also want to download the win32, quicktime, xanim and realvideo codecs, and put them somewhere convenient. I use /usr/share/mplayer/codecs. I'll assume you've done this.
1. ./configure --prefix=/usr --enable-smb --enable-largefiles --with-win32libdir=/usr/share/mplayer/codecs --with-xanimlibdir=/usr/share/mplayer/codecs --with-reallibdir=/usr/share/mplayer/codecs
2. make
3. make install (as root)
MPlayer is now ready to go. Now, the only issue that remains is that the command to run mplayer with V4L is a little cryptic. Here are some examples:
mplayer -tv driver=v4l:norm=ntsc:input=1:width=352:height=240 -double -vo sdl tv://
This captures video from the video-in jack on the card (input=1) at a resolution of 352x240, in NTSC format, and outputs it with double buffering using SDL.
mplayer -tv driver=v4l:norm=ntsc:channel=3:chanlist=us-cable:width=352:height=240 tv://
This tunes to North American (chanlist=us-cable) TV channel 3, and outputs it using plain old X video.
mplayer -tv driver=v4l:norm=ntsc:input=1:width=640:height=480 -double -vf lavcdeint -vo sdl tv://
Video-in jack, 640x480 resolution, double buffering, libavcodec de-interlace filter (-vf lavcdeint), SDL output.
If all has gone well, you are now watching TV on Linux. Now, you're probably wondering how to capture to a file. MEncoder, which comes with MPlayer, can capture and encode video in real-time and output it to an AVI file. Here is an example:
mencoder -oac mp3lame -ovc lavc -lameopts mode=1:vbr=2:q=4 -lavcopts vcodec=mpeg4 -tv driver=v4l:norm=ntsc:input=1:adevice=/dev/dsp:width=352:height=240 -af volume=-15 -o tv.avi tv://
Capture video from video-in jack on TV card at 352x240, and audio from the sound card (adevice=/dev/dsp)
Scale the audio by -15 dB (-af volume=-15)
Encode audio in MP3 format (-oac mp3lame), with settings (-lameopts): joint stereo (mode=1), default VBR method (vbr=2), pretty high VBR quality (q=4)
Encode video using libavcodec (-ovc lavc), using a DivX-like MPEG-4 codec (-lavcopts vcodec=mpeg4)
Output to tv.avi in the current directory.
Note that, using this method, MEncoder will only capture sound from the audio channel you have selected as the recording source. In this case, you almost certainly want to set that to Line, using whatever mixer app you prefer. If the sound in the output file is too quiet, either set the -af volume parameter a little higher, or remove it. If it's too loud, set it lower.
As always, refer to the man page for specific details. This guide should be enough to get you started though. Enjoy.