AVI Movie Players and Capture

by Robin Rowe

Last month we tried some MPEG players, including aKtion, gmpeg, gxanim, MPlayer, plaympeg, XAnim, xine and Xtheater. We also looked at the Be operating system in order to compare its video capabilities with Linux.

Our goal this month is to look at the AVI players aKtion, Aviplay, MPlayer and XAnim. We will also capture some AVI files using Video4Linux and XawTV or QtVidcap.

AVI (audio video interleave) is one of the most common formats for video files on PCs. The AVI file format and the RIFF format (resource interchange file format) generally, were defined by Microsoft and IBM back when they were still friends. The Microsoft audio WAV format is another variant of a RIFF file. The RIFF format was based upon IFF, a format standard on the Amiga. When seeking information about the AVI format, a good place to start is John McGowan's “AVI Overview”, available at www.jmcgowan.com/avi.html or www.faqs.org.

Internally, video files are chunks of interleaved pictures and audio. To play a video, those chunks are read sequentially one after the other by a video player and mixed together in a way that makes them appear seamless. Typically, audio playback is the reference and the video picture is synchronized to it. Variations in audio playback rate would be discernible as wow and flutter, but slight variations in video playback framerate are not apparent.

Video file formats rely upon two easily confused concepts: transports and codecs. A transport is the structure that describes the chunks of audio and video that follow. AVI, MPEG and QuickTime are all examples of transports. Within the transport, each compressed chunk of video or audio must be read using a codec that understands the particular scheme of that chunk. Examples of video codecs include Cinepak and Indeo. AVI sound codecs may be PCM, ADPCM, GSM or many others. If you have what seems to be a perfectly good video file, but your video player only plays the video or audio part, it is probably because you are missing a codec. Players are designed to skip over things in the transport they don't understand.

WMP (Windows Media Player) is the movie player included with Windows. It uses installable codecs that work as plugins, called dlls (dynamic link libraries). If you develop a new Windows codec, your video or audio can play back in WMP. For Linux codec developers, this means it is feasible to port your code to Windows as a plugin, so that files created with open formats in Linux can be viewed in the proprietary Windows player. Conversely, some Linux video players are able to use Windows plugins and will play proprietary Windows formats in otherwise open Linux players. It is therefore possible to deliver a single plugin that will work for both Linux and Windows, at least on Intel.

AVI Movie Players and Capture

The Windows Media Player

AVI files identify their embedded codecs using a magic number called a FOURCC code. This four-byte id is how the AVI transport knows what codec to load in order to play a stream. To guarantee uniqueness, the FOURCC must be registered with Microsoft. The unofficial but “Almost Definitive” FOURCC Definition list is kept at http://www.webartz.com/fourcc/ and provides a lot of good information.

It is widely believed that AVI files can't be larger than 2GB or used for professional video applications, but that's not really true. The main reason for the file-size limitation is that a RIFF block uses a 32-bit integer to describe its size. You may hear this alternately referred to as a 1GB limit because a bug in the early Microsoft Video for Windows code made that (huge at the time) the limit. Because an unsigned 32-bit integer can also contain 4GB, you may see that number suggested as a maximum, too—4GB also happens to be the limit for the FAT16 filesystem.

The original AVI file spec only permits one RIFF chunk per file. The obvious fix to the size limit was to allow multiple RIFFs in one file. At the urging of Matrox, that's what the Open Digital Media (OpenDML) Consortium did when it created the OpenDML AVI file format extensions. The spec is available from a link in McGowan's AVI Overview. OpenDML AVI support has been reportedly contained in Matrox's DigiSuite software and in Microsoft WMP since version 5.1.

Recently, AVI is losing steam to new formats available from Microsoft; advanced streaming format (ASF) and later Windows Media Format (WMF) were added in WMP 7. Microsoft has tested WMF files as large as 30GB, but they can theoretically hold 17 million terabytes. For audio files, the file extension is wma, for video, wmv.

Some Video Players for Linux

XawTV is a popular application for watching video on Video4Linux devices. Video4Linux (V4L) enables many different video capture cards to be used interchangeably in applications. Hauppauge WinTV is one of the most popular inexpensive TV cards (less than $70 US). Other comparable cards are based on the same Conexant chipset (formerly Rockwell Brooktree).

AVI Movie Players and Capture

The XawTV Video Player

AVI Movie Players and Capture

The XawTV Config Screen

Ralph and Marcus Metzler created the first bttv Linux driver code to work with Brooktree BT848-based TV cards. Gerd Knorr eventually took over development, creating the bttv-0.7.x series drivers. He also created and continues to maintain XawTV. Alan Cox developed a generic video architecture called Video4Linux that was influenced by ideas in the OSS sound drivers. He developed V4L around the bttv driver and brought it into the Linux kernel. The original bttv driver is no longer supported and has been replaced with the V4L version maintained by Justin Schoeman.

V4L2 is a substantial rewrite of the bttv driver for Linux. According to Justin Schoeman's web page (http://sourceforge.net/projects/bttv-v4l2/), the aim of bttv-v4l2 is to support high performance video capture on Bt848/878-based video capture cards. Bill Dirks is responsible for the current development of the V4L version 2 architecture (V4L2). He developed the capture API and made architectural changes to better accommodate a variety of hardware devices. His web page, http://www.thedirks.org/v4l2/, has more information.

When building and installing the bttv driver (as we did in this column in the April 2001 issue of LJ), we encountered something called the i2c driver. This perplexed us at the time because we couldn't get it to work, and none of the V4L web pages say what it does. Looking more closely at Gerd Knorr's web site, we noticed that we needed a 2.3 or newer kernel for i2c and therefore had to do a minor patch to Debian Potato's 2.2 kernel. We had the fix but didn't understand it.

Talking with Bill Dirks finally solved the mystery for us of what the i2c driver does. TV cards have tuners, and they have their own communications bus called i2c (or iic), defined by manufacturer Phillips. It is a three-wire synchronous serial bus (clock, data, ground) that communicates between the tuner and other components on the card. It is the PCI bus that talks to the i2c. Another place an i2c bus is used is on the PC motherboard so it can talk to the temperature sensor for the CPU.

Although it is still experimental, Bill Dirks recommends using V4L2 unless doing so causes a problem. V4L is more bttv-centric, but apps may use either Video4Linux version transparently. The videodev driver loads the device specific driver in V4L. In V4L2, the driver loader may be videodev or videodevx. The V4L2 videodev package works only with 2.2.x kernels and supports only V4L2 drivers. The new V4L2 videodevx driver works with 2.2.x and 2.4.x kernels and supports both V4L2 and V4L device drivers.

V4L is included with the kernel. To get V4L2, you need to install something extra. Because the version of V4L with Potato is so old, we did that anyway. However, we finally went with V4L because we were scared off by the newness of V4L2. We haven't followed Bill's advice yet to switch to V4L2, which may have something to do with some difficulties we had testing video capture.

We built the AVI players from source, either because we wanted the latest version or because no deb package was available. The procedure is to search on freshmeat.net for the project, use tar xvfz or xvfI to unpack it (depending on whether the file is gzipped or bzipped), then build it. Building is typically done the GNU way: ./configure, then make and make install.

MPlayer was deemed the most stable MPEG player in our evaluation last month, although the 0.11 version we had wouldn't play AVI files. The new version does. It does a pretty good job, but it is obvious that AVI support isn't as mature. Some files didn't play, some had no video and one even played upside down.

In theory, MPlayer can play any video that Microsoft WMP can because it tries to use WMP codec plugins copied into the Linux /usr/lib/win32 directory. However, tricking the WMP plugins to work in Linux isn't entirely perfected yet, and MPlayer continues to suffer from a spartan command-line control interface.

You can't resize the player window, which will annoy most people accustomed to viewing small videos at double size. You also can't get a video to repeat, and quitting doesn't seem to respond very fast.

There is no version number for MPlayer anymore; you can only download a daily CVS snapshot. We had serious trouble getting that to build due to a problem with our gcc compiler. We received a somewhat cryptic message from gcc about an install problem, and it couldn't execute cc1plus, the g++ front end. However, g++ seemed to be installed correctly. The problem went away when we installed a newer version of gcc (2.95.3-5).

XAnim is popular for viewing both MPEGs and AVIs. It uses plugins but not the Win32 dll ones. It offers its own cross-platform plugins for H.261, H.263, Indeo and Cinepak. Although not many are offered, the docs say the plugins run on Intel, Alpha, PowerPC, Sun and SGI hardware. According to the XAnim web page, the plugins are proprietary, developed under NDA.

AVI Movie Players and Capture

The XAnim Player

XAnim worked okay but couldn't play as many AVIs as MPlayer. However, the user interface in XAnim is better. We wanted to try the latest version of XAnim, but we had trouble building it. Building XAnim requires first installing the Imake generator xmkmf. It's supposed to be included with the X Window System development libraries, but we couldn't find that. Later we noticed that the MPlayer web page says those libraries are called lib6g-dev in Debian.

AVI Movie Players and Capture

The XAnim User Interface

Two other players we didn't get built are aKtion and Kmpg. We are running an older version of aKtion, but it has some problems playing AVI files. We couldn't build Kmpg 0.5.4 because it didn't like our system's too-new version of libqt (2.2.4 instead of 1.x). Not having KDE headers was the build error reported by aKtion 0.4.1. Xtheater 0.9.1 built but wouldn't play any AVIs.

Avifile 0.53.5 is a library for playing AVI files. It comes with two sample applications, Aviplay and QtVidcap. Using Aviplay offers a somewhat different interface than XAnim but is a similar experience. XAnim doesn't seem to use Avifile. MPlayer doesn't use Avifile but they do have the Win32 DLL loader in common. Both seem a bit more reliable than Aviplay.

AVI Movie Players and Capture


The QtVidcap capture program looks enticing, but we couldn't get it to work. When it started to capture a file it would fail. We hope it will do better after we install XFree86 4.x and V4L2.

XawTV succeeded in capturing AVI files, but its power seemed feeble compared to the same task in Windows with Windows Media Encoder. XawTV only encodes 15-bit and 24-bit RGB or MJPEG codecs. XAnim was the only player that could play all three XawTV formats. The other players tended to balk, except for MJPEG. Aviplay didn't like any of them. We had trouble playing the files in Windows and wondered if the fault was in the capture. The Linux players did better with Windows-captured video, provided that the codec wasn't too new.

AVI Movie Players and Capture

The QtVidcap Program

AVI Movie Players and Capture

The XawTV Options Window

Two things puzzled us when operating XawTV: adjusting picture size and sound. You must size the window to the size you want to capture videos. Anything larger than 320 x 240 pixels at 15fps gave us problems. We had no sound until it dawned on us to select “line input for record” in gmixer.

Next month we will upgrade our Debian Linux installation from Potato to Woody, giving us the more multimedia capable 2.4 kernel and XFree86 4.0 GUI. We will also upgrade our device drivers to V4L2.

AVI Movie Players and Capture
Robin Rowe is a partner in MovieEditor.com, a technology company that creates Internet and broadcast video applications. He has written for Dr. Dobb's Journal, the C++ Report, the C/C++ Users Journal and Data Based Advisor. His software designs include a client/server video editing system in use at a Manhattan 24-hour broadcast television news station, Time Warner New York One and associated web site http://www.ny1.com/. You can reach him at robin.rowe@movieeditor.com.
Load Disqus comments

Firstwave Cloud