Ok I'm assuming you know what a video format container is. If you don't then the explanation is as simple as it sounds: It's a container (file format) for holding an audio + video file that you then watch. The .avi or ogm or mkv gives a pretty clear indication of what container is used.
AVI is
Microsoft's container.
OGM was created by the same people who make the audio compression codec [Ogg] Vorbis (
Xiph). It looked better than AVI (simple reason: smaller / less overhead) kinda got terminated, but it kinda stopped getting worked on and the uptake was too slow = kinda dead now.
MKV is the
Matroska format which is like MKV...except smaller and faster seeking again, and more stable, and better support (and still active).
So I use MKV. Sometimes programs still only accept mpg / avi formats though. In this case, it helps to have a fast way to convert the container to an AVI format. Now when I think conversion in Linux, I usually turn to
AVIDemux (guys why not register avidemux.info???), with the codec's set to copy for both video and audio, this would do the trick. But for some reason, the AVIDemux on my
Ubuntu (7.10) eats up all my memory while converting (it eats about 3G in 5 minutes, bringing my system to it's knees ;)
So nuts to that idea. But wait: Matroska to the rescue! Well, I don't know about actually converting...but Matroska give us a neat little command line utility to extract the tracks (audio and video) from the container. Then with a little help of avimerge, we can recombine them into an AVI.
This works and eats very little CPU and memory too :)
I don't do it that often, so I usually just do it by hand, but if you wanted to script it, I guess it would go something like this:
#!/bin/sh
if [ $# != 2 ]
then echo "Usage: $0 [INPUT] [DESTINATION DIR]"
fi
mkvextract tracks "$1" 1:"$2/video.avi"
mkvextract tracks "$1" 2:"$2/audio.mp3"
avimerge -o "$2/$1.avi" -i "$2/video.avi" -p "$2/audio.mp3"
Of course, this assumes that you have mkvextract, and avimerge, in your path. It also doesn't account if you use something other than .mp3 in the MKV container (I use Vorbis :). But hey, I just wrote it while blogging!
Oh by the way, it takes waaaayyy longer to mux to an AVI than it does to [de]mux from an MKV!