From video tape to the www

From video tape to the WWW

... or how to create high quality animations with low cost software.
Fancy hardware provided by employer ...

Digitising

The video clip for the following animations was captured from a VCR by a Parallax XVideo board in a Sun SPARCstation 20. Length of the clip is 52 seconds. The resulting video data stream was saved as 320x240 pixels, 24 frames per second, in full color JPEG. It is accompanied by a 48khz 16bit linear stereo audio stream. Ouput format of the capture software was a single file in their own jmovie format, taking nearly 16 Megabytes of disk space.

160x120 2.4f/s 0.7MB 160x120 4.8f/s 1.0MB 160x120 7.2f/s 1.2MB 160x120  12f/s 1.8MB 160x120  24f/s 3.2MB
240x180 2.4f/s 0.9MB 240x180 4.8f/s 1.5MB 240x180 7.2f/s 2.0MB 240x180  12f/s 3.1MB 240x180  24f/s 5.8MB
320x240 2.4f/s 1.2MB 320x240 4.8f/s 1.9MB 320x240 7.2f/s 2.7MB 320x240  12f/s 4.2MB 320x240  24f/s 7.9MB

What we got

The public domain tool jmovie2jpeg claims it can convert such a file into a set of "JFIF compatible JPEG images". Actually I found that the jpeg files are a bit non-standard, as most viewers refuse to load them. Luckily the djpeg/cjpeg tools (included in the free jpeg library of the IJG) can convert them to real JPEG (with only a few complaints).

The audio file dropped by jmovie2jpeg is in SUN AU format. Sox (version 11p12beta) is able to convert 48khz stereo into 8khz mono. In an anttempt to resample to 22050 Hz or 11025 Hz I learned that it likes to add a strange buzzing noise.

Finally I was stuck with the set of 1272 images occupying 6 MB and an audio file of 10 MB and had time to wonder why Parallax devoted 60% of the jmovie stream to audio and only 40% to video. Probably Parallax considers an image size of 320x240 as "small". For a better video to audio ratio, I should have captured full size 768x575 PAL format. :-)

What we need

With 'being stuck' I mean, that I needed to bring the video clip in one of the many standard formats that people browsing through www would accept, but I could not.

I assume you do not want to download a 16MB file and you do not want to download a file in jmovie format and you sure do not want to download 16MB of jmovie format. While surfing through other www-sites, I learn that you want to see clips in AVI, FLI, AVI, QuickTime, AVI, MPEG and of course AVI format. And the smaller, the better. I consider 3MB to be a big animation.

I have found two free encoders:

  1. fbm2fli and
  2. the famous mpeg_encode from Berkeley.

The FLI format has limited video quality (8bit colormapped) and does not provide audio. But it has the advantage of a simple algorithm (compared to MPEG and most AVI formats). So, if you have a slow machine and want to read subtitles rather than listening to audio and have a good network connection, FLI is your friend. The simple encoding algorithm provides a weak compression and results in larger files (even with with less quality).

The MPEG format provides an excellent quality to filesize ratio. So if you have a weak network and a powerful CPU, you want MPEG; furthermore MPEG format supports audio - at least in theory. Documentation of mpeg_encode does not mention the keywords 'audio' or 'sound' anywhere, while its companion mpeg_play is documented to handle multiplexed video+audio streams by discarding the audio.

I always aimed towards xanim, a wonderful and free multi-media player, which plays nicely synchronised audio and video from a large variety of file formats.

My solution

Finally I decided to spend one Friday studying xanim source code. The major discovery was that AVI format is really a container for various sub formats. Most of the AVI examples I analyzed were in CRAM sub format, which is used by the dominant non-unix software vendor. But AVI can be anything from uncompressed RGB images over CRAM and CVID up to JPEG and MPEG.

The fact that JFIF type JPEG was on this list and my 1272 images happend to be in JFIF JPEG, caused me to spend a weekend writing an encoder. Another Monday was required to add audio support. I call it jpeg2avi although I have never seen any AVI specs. All I know is this: It encodes something that xanim can play. Feedback from outside the unix world is welcome.

Since version 1.4, jpeg2avi is able to extract all jpeg images from a single jmovie file as created by the /opt/SUNWits/Graphics-sw/xil/examples/test/SunVideo tool.

Wysiwyg

Two more sets of JPEG images have been created by scaling down the original set: one at 240x180 and another one at 160x120 pixels resolution. Decoding JPEG at a rate of 24 images per second is beyond the capabilities of most machines, so I encoded each set also at lower rates by skipping images (12, 7.2, 4.8 and 2.4 fps). Audio quality (8khz 8bit linear) is quite low, but the 48khz 16bit stereo did not sound much better. I guess the Video tape was already worn out.

Local users can access the AVI files per NFS by clicking on the above icons. All other users may retrieve them per FTP from

ftp://ftp.uni-erlangen.de/pub/Multimedia/Animations/avi
(If downloaded with Netscape, the files may appear corrupt. E.g. my Nescape wants to translate each LF into CR-LF. Try downloading with ftp then.)

To register xanim as the external image viewer for AVI files with Netscape or Mosaic, add the line

video/x-msvideo; /local/multimedia/bin/xanim +vSr %s
(or similar) to your personal ~/.mailcap file and make sure this file is listed as the "Personal Mailcap File" in the dialog "Helper Applications" from the Options/Preferences menu.

Xanim running on a 168Mhz UltraSPARC processor is able to display the 320x240 format in 24 frames per second.