Video Capture

Video Capture is the technical term for recording video in a digital format. In the eBox, my intention is to set it up so it can perform all the normal functions of a VCR - record from TV and other external video sources either on-demand or at pre-set times, and of course play back recorded video.


The eBox uses an Askey / Dynalink TView99 TV tuner card (sold worldwide, sometimes under the name CPH051), which I bought a few years ago, had trouble with under Windows, and basically gave up on until I started on the eBox. Like most capture cards, it has a TV and FM tuner, a Composite video input, and an S-Video input. Also like many other cards apart from the more recent ones it is based on the Brooktree/Rockwell/Conexant Bt878 chip, which is widely supported under Windows and Linux. When set up correctly, you can capture video at 25fps 640x480 with these cards.

Some general tips:



Video capture is reasonably mature under Linux. The Video4Linux (V4L) architecture has been around for a few years now, and drivers for many different capture cards are available or in the works. The Bt8xx drivers support about 30 different types of cards based on this chipset including the TView99. FM radio tuning is also handled through V4L because this functionality is often bundled with video capture cards. There is also V4L2, which is supposed to be the "next generation" but it hasn't really been embraced yet and I don't think it'll be in mainstream use until the 2.6 kernel comes out. Someone can correct me if they think I'm wrong, but it seems that plain old V4L is where it's at right now.

Setting up my TView99 card under Linux was relatively easy for the most part. After loading the appropriate modules I could access the device straight away using XawTV. The difficult part came when I tried to find the correct settings for the tuner. After floundering for a while and almost giving up, I was pointed to a little script called ftvco which tests the various combinations of settings. If you live in New Zealand and have the TView99 or similar card, the correct settings are tuner type=5, pll=1. Also make sure you have a strong aerial for testing, as with weak sources you might be fooled into selecting the wrong options (somehow I was getting signal coming through with NTSC set (!) - NZ uses PAL).

Setup instructions

Note: these instructions are specific to capture cards based on the Bt8xx chips. If you're using another sort of card (eg. Zoran based) you'll need to do something else.

With some distributions (Slackware 8.0 included) you will have to create the V4L devices (entries in /dev). This is easy to do, but you'll need your kernel source installed - once you have, run the following:

sh /usr/src/linux/Documentation/video4linux/bttv/MAKEDEV

Now add the following to /etc/modules.conf:

alias char-major-89     i2c-dev
alias char-major-81     videodev
alias char-major-81-0   bttv
options bttv            card=24 radio=1 pll=1
options tuner           type=5
post-install bttv modprobe tuner; modprobe videodev

This sets the options for the modules which you need to load, and sets up the tuner and videodev modules so that they load automatically when you load the bttv module. You'll need to set the appropriate options for your exact card (card=x, radio=x) and tuner/TV broadcast system (tuner=x, pll=x). Valid values for these are documented in the video4linux documents directory in the kernel sources (available locally from /usr/src/linux/Documentation/video4linux/bttv/ if you've got the kernel sources installed). If you have trouble getting the right values, try ftvco. BTW, if you're compiling your own kernel, don't get any ideas about compiling bttv in - always use modules for this and the i2c stuff because that's what the docs say you should do. This is so you can configure them easily.

Now you need to make the modules load on boot, assuming you haven't set up the kernel module loader (I have no experience with this myself). To load the modules, I added the following lines into /etc/rc.d/rc.modules (not available/necessary/used on some distributions):

/sbin/modprobe i2c-dev
/sbin/modprobe i2c-algo-bit
/sbin/modprobe bttv

Now you can reboot, or you can just run these commands yourself to load the modules. This should then make /dev/video0 available as the video device for the capture card. Now you can try out the various programs that support V4L devices.


There are many Linux applications that support V4L video devices. Below are some that I've looked at.


xawtv is a simple application for using TV tuners and capture cards. It doesn't have many bells and whistles and the user interface leaves much to be desired, but for my purposes in the eBox it's fine because I don't need these things. However, it does support control via LIRC, which I did need. Also, of the available TV viewers that I've tried, it has the best full-screen display support. If you'd like a similar application with a nicer interface, try Zapping (a GNOME application) or KWinTV (for KDE).

XawTV has a built-in video capture function, but all I managed to get from it was a corrupted file, which sent me out on a search for another application for capturing video.


mp1e is a command line MPEG encoding capture tool. It takes the input from a V4L device, encodes it into MPEG-1 (there is support for MPEG-2 as well, but I haven't tested it) and writes it to the standard output, which you normally redirect to a file. mp1e must be very well optimised, because I found I can capture at 640x480, 25 frames per second, and not get a single dropped frame once it's started. I was very impressed, to say the least, although this was with it set at 8 megabits per second with I-frames only, so it does tend to fill up the drive pretty quickly. On the other hand, the resultant video is very easy to edit later because every frame is stored separately, so this is sort of equivalent to MJPEG (although MPEG compression effects are quite different to JPEG ones, and I haven't yet found an MJPEG compressor to rival mp1e's performance with these settings). Here is the command line I use for capturing with mp1e:

mp1e -g I -s 640x480 -b 8 -vv > test.mpg

Don't forget to specify -v or -vv or you won't find out how many frames get dropped, etc. You can play with the bitrate setting, 8-10 Mbps seems to be the optimal at this size for good quality captures with I-frames only. You will need a big hard drive though - it will chew up about one MB per second. If your hardware can handle it you may be able to capture using the standard frame configuration as well (try leaving out -g I, and you can probably set the bitrate lower as well).

If I can get nothing else to work then it looks like mp1e is going to be the capture tool of choice. If that is the case I will start building in some minor modifications of my own.


Avifile, a set of tools for handling Microsoft AVI video files, includes a tool called avirec. avirec records from a V4L device to an AVI file, and through the Avifile libraries allows you to use various Windows codecs (via the magic of source code from the Wine project) such as Microsoft MPEG 4, aka DivX. Previously I found Avifile's capture performance to be quite good, but lately I have had trouble getting any captures out of it without dropping frames. A number of capture application projects have been built around Avifile, including vcr and DVR.

At the moment your best bet seems to be to get the latest version of Avifile out of CVS. Beware of old versions, some are very buggy.

Here is the command I use to capture video at 512x384, direct to DivX:

avirec -i1 -c"DivX ;-) Low-Motion" -x 512 -y 384 -d test.avi


The ffmpeg toolset is much like Avifile, but is all Linux-native. I found that while it does support capture, it doesn't seem to be very suitable for it because it does not report the number of dropped frames, and doesn't seem to perform as well at high resolutions either. ffmpeg or parts thereof are being used in a lot of other libraries and programs, though, so there must be some way to get it to work better.


I have yet to try it, but one application that looks very interesting is MythTV. It's fast becoming a full set-top box application, supporting timeshifting, recording, and even ripping CDs to MP3s. I guess I'll have to get into gear with eboxy :-)

I also looked at bttvgrab (now officially abandoned, according to the site) and and zeitreise (very early development stages), but these didn't work for me for various reasons (refusing to compile, crashing etc.). I tried NVrec and lavrec (part of the mjpegtools project) as well, but both of them were too slow - at least I couldn't get them to perform anywhere near as efficiently as mp1e.

FM Radio Software

If your card has an FM tuner as well as TV, then once you've set up the bttv modules on your system, you should be able to just run one of the various FM radio applications that are available for Linux. All you should need to do is select that your radio device is a V4L device, and the program should work. The one I've been using for testing is fmio, which is a simple console application. Other Linux radio apps include QtRadio, OZradio, GQradio, Gnomeradio, KRadio, GRadio, and xmradio.

Home | News | Status | Current Hardware | Pictures | Why Linux? | Resources
Playing Movies | Playing Music | Video Capture | Remote Control | Hardware Mods | Software Setup