Theory of Operation

<< Click to Display Table of Contents >>

Navigation:  Movie >

Theory of Operation

 

This section is provided to give you a better understanding of the way the CVB Movie tool works and describes its possibilities and its limitations.

DirectShow provides a relatively easy way of accessing the Windows platform's multimedia capabilities and CVB Movie uses this.
In principle it gives you access to any DirectShow compression/decompression codec installed on your computer (Filters, VCM and DMO codecs) for either replaying a prerecorded AVI file or for encoding the data that is put into one.

 

A complete description of DirectShow can be found in the Microsoft online help, we will give a brief outline of the characteristics of this framework in this document.

In DirectShow each element that provides or processes (displays) any kind of data (including but not limited to images belonging to a live video stream) is called a 'filter'.
Those filters exchange their data through so-called pins which may be either output- or input-pins.
Output and input pins may establish a direct connection to pass data from one to the other, but also events that control the flow of that data.
With this concept, the components necessary to play a video file are (in the direction of data flow):

1.A file source filter that reads the video (and audio) data from the AVI file where that data is stored.
This filter normally only has an output pin, through which data is passed out.

2.An AVI demultiplexer that extracts the video data from the AVI file (as AVI stands for audio video interleaved the file may of course also contain an audio stream).

3.A video decompression filter capable of decompressing the video stream from the AVI file.
This step is only necessary if the video stream in the AVI file is compressed (it is important to note, that the extension AVI itself does not tell anything about the compression; it only tells that there is a video and/or audio stream present in the file - the type of compression, and hence the needed decompression codec is determined by tags included in the file).
If the video data is uncompressed, this filter will of course not be used.

4.A video render filter, that will display the video stream on screen

To do video streaming to disk, the filter chain is set up the other way round in a similar way - this process is handled for you by the CVB Movie tool.

 

One of the base parts of CVB Movie is therefore a filter that passes CVB image data into a DirectShow video stream.
This filter has to deal with a special peculiarity of the AVI format:
The uncompressed AVI stream consists of nothing else than Device Independent Bitmaps (DIBs), and those are arranged 'upside down' in memory.
That means that the first line in memory is the last line of the bitmap and so on.
Images delivered by a Camera or Frame grabber are normally oriented the other way round (exceptions to this rule exist; for example with some Frame grabbers you may choose the orientation prior to image transfer into host memory).
The CVB source filter therefore has to rearrange (and in consequence to copy) the image data before it is passed on to whatever filter comes next.
Although the CVB source filter will choose the fastest possible way to do this, this nevertheless always implies a performance loss to some extent (normally of the order of about 5 ms).
The impact resulting from the need of rearrangement of the image data gets heavier, if the VPAT of the image object serving as a source for the AVI stream has a shape that requires rearrangement of the whole image data, not only the lines.
In such cases, we measured performance drops by about 60% - so if you experience little performance and you are sure your hardware is not the cause, analyze your VPAT's; for good performance at least the XVPAT should be linear!
With RGB-capable hardware you should always choose 24 Bit RGB formats if possible, because for RGB32 formats this reshaping of the image block in memory is mandatory.

 

More severe is the impact of compression on the performance, because here heavy processing of the data is done.
Normally the standard MPEG4 codecs like Divx and Xvid can be used for real-time encoding with modern systems.
But only with the most up-to-date computers today it is possible to record compressed AVI files in realtime with the newer high quality H.264/MPEG4-AVC codecs without losing images.
Therefore, if speed is the main focus, you should either have a very strong number cruncher use a fast codec or consider using no compression when recording (which will however result in huge files in almost no time and requires a sufficiently fast hard disk system, preferably a RAID stripe set).
Provided that either your hard disk and controller or your overall system are fast enough, chances are good that you will be able to record AVI files in real-time, without losing images, in a format which is readable on any computer (also without CVB).
An even safer, but more costly alternative would be compressing the acquired sequences offline.

 

By the way: You can of course also compress uncompressed AVI files offline after recording, using the video file vin-driver of CVB and for example the MovieInteractive Tool.
Which option is best, strongly depends on your hardware at hand and the needs in your application. Therefore the best help in choosing would be to test CVB Movie in demo mode on the target machine.

 

It is also important to note, that many DirectShow Video compression codecs impose restrictions on the video stream to be compressed in that they will only accept certain colour formats or certain image sizes.
In most cases these restrictions are not well documented and published, but if they are not satisfied, CVB Movie will not be able to set up a proper filter connection and report an error when using such a codec.
This ultimately is the reason, why some codecs do not appear to work properly with CVB Movie - whereas the true reason for this is simply that the requirements of the compression codec are not met (in rare cases this may also be a licensing issue: There are codecs that will refuse to work in a filter graph, if they are not properly licensed).