Dealing with video codecs when processing video observations

Recently I bought one of those digital video recorder devices which record video directly to a hard drive. It is very small and cheap option and it could be a great way of recording asteroidal occultations and lunar grazes. It also seems that those gadgets are becomming popular latetly as a week ago at the Occultation Symposium in Auckland a question was asked about another digital video recorder that records MPEG-4 compression. The question was how to load the video file into Limovie. At this time I didn't know that my recorder also uses MPEG-4 compression. I did some test records and I also had the same problem - Limovie could not load and analyze the produced video file. Later I solved the problem and I thought that this same solution could be used for all other similar digital video recorders and here I am writing this article.



Understanding codecs

Video codecs are used to compress video streams for storing them into media. Initially the codecs were developed to compress the data for saving space on the storage media. Nowadays codecs are used everywhere from posting files on the internet to compressing audio and video for MP3 players, iPods, digital video recorders etc. Still the main advantage of using codecs is that they make the video file smaller without loosing much of its quality. For example when I record uncompressed video from my WAT 902-H camera 10 minutes of video is almost 10Gb, when I use MPEG-4 compression 10 minutes is less than 300Mb.

The MPEG-4 compression was introduced 10 years ago. It become very popular with the release of the free Div-X encoding (which is based on MPEG-4) and which was used in almost all riped movies downloaded from the internet. Few years layer Div-X became paid if you want to use it to record. It is still free for decoding (i.e. playing). Soon after Div-X became commersial a new free encoding based on it was born. They called it X-viD. Because it is free for encoding/recording it is very possible that your digital video recorder is using this codec. MPEG-4 is still a developing standard but probably the most popular codecs based on it are the two Div-X and X-viD.

Another important thing to remember is that the file extension of your video file generally cannot tell you which encoding is used to generate the file. This is particulary true for the AVI file format. The AVI file format is used as a container format which may be used by many different codecs.

For additional information on codecs and video compression please have a look at the following Wikipedia artickles:

Codec - COding and DECoding video streams
Video Codecs
AVI Files (Audio Video Interleave)



Identifying codecs used

To identify the codec used by your digital video recorder to record the file you need to use special software. There are a couple of options here to choose from. The one I use is called GSpot but there are other alternatives such as VideoInspector and MediaInfo.

To use GSpot you simply need to load the file or use its windows explorer integration and simply right-click on the file in windows explorer and go "Open With -> GSpot Codec Information Appliance (tm)". The the program analyzes the file and shows you the codec used, is this codec installed on your computer or not and some other useful parameters of the video file. In the screenshot shown below GSpot tells me that the video file is using "XviD ISO MPEG-4" codec and that this codec is not installed on the system.





Finding, downloading and installing missing codecs

Once you have identified the codec used by your video file you may have to download and install the codec (if you don't have it). To do this you basically have to find this codec on the internet. You can go "Tables -> Video Codes" in GSpot to find some more information about your codec such as the vendor of the codec. This will help you to easily find this codec on the internet and download it.



For example in my case I found that the XviD ISO MPEG-4 codec is created by xvid.org and that this is an open source codec. Now that I know this I can go to www.xvid.org and download the latest version of X-viD (1.1.3 at the time I created this article).

Here are links to download the two most popular MPEG-4 codecs X-viD and Div-X. If the links don't work for you at the time you read this article then simply use Google to find another download location.

Once you know the coded used by your video you can also find more information about it from the following site: http://www.fourcc.org/codecs.php



Using AviSynth to host the video file


Our work is almost done. The last step is to load the AVI file into Limovie. The best way to do this is by using the AviSynth software. There is an excellent article by Stephen Russell about using AviSynth and LiMovie on his web site: http://www.netstevepr.com/Avisynth-LiMovie.htm.

In the most cases when you are not stacking frames to load your video into LiMovie you simply need to create a new text document using for example Notepad and write this single line ot text:

DirectShowSource("F:\ASTRO\XVID\REC_011.AVI")

Of course you have to enter the path to your video file. In my case this was "F:\ASTRO\XVID\REC_011.AVI". After you are done just save the file and give it an extension AVS (for example "REC_011.avs"). Then use LiMovie to load the AVS file.

Configuring LiMovie to always use AviSynth when opening AVI files

And there is even an easier way. You can tell LiMovie to always open AVI files via AviSynth. To do this choose "Option" -> "Update Setting Items" from the menu.



Then check the "Use AviSynth" check box and press "Update .INI file" to save your settigs. Now LiMovie will always create an .avs file with the same name as the .avi file you try to open in the same folder where the .avi file is located. If the file exists it will not be modified. Then LiMovie will open the .avs file instead of the .avi file directly.



Hristo Pavlov, 7 July 2007 (Updated: 11 May 2008)