libkohn_avi / readavi
Posted: Sometime in 2004?
This is some code I wrote long ago for creating AVI files and debugging them. The libkohn_avi.so / libkohn_avi.dll can be given frames of jpeg files or other formats to create a video from them while readavi will dump the AVI headers to text so the internals of the container can be viewed in a human readable way. Both programs have zero dependencies so they should easily build by simply typing "make" on a Unix system or on Windows using MSYS.
There are basically 3 functions for libkohn_avi:
I've been working on an RTSP client API for recording video and decided to add these three functions. As long as they are called before the AVI file is closed, the framerate, codec, and size can be changed for the whole video:
To use this library, simply call kavi_open() to create the avi file, kavi_add_frame() for every raw frame, and kavi_close() to finalize it all.
I included a sample program called jpeg2avi which can take a series of jpeg files and create an avi using the MJPEG codec. To use this program, if there is a directory full of jpegs with filenames like frame000.jpeg, frame001.jpeg, frame002.jpeg, etc, simply run jpeg2avi like so:
There is also a demo program called axis2avi. It's a pretty short program that uses popen() with wget to grab JPEG frames and stick them in an AVI file. It has the URL to an Axis camera hardcoded in the source code, so it will have to be edited to work with another networked camera. The program can grab frames every X seconds or every time the user presses enter. A ctrl-C should safely close the AVI file.
A demo video using an Axis 211 camera doing "stop motion" video with some toys can be seen on YouTube here:
The AVI file format is an audio/video file "container" that can hold raw video, mjpeg, xvid, divx, and many other compressed audio and video formats. This simple little program is an example how to parse AVI files and will dump the AVI headers from a file. I found this program quite useful for debugging AVI files created by programs I wrote and for figuring out what video codecs an AVI file using. Basic usage is:
All code on this page is distributed under the LGPL license.
Related Projects @mikekohn.net
Copyright 1997-2022 - Michael Kohn