Video writing - from single file to video archive

Previous tutorial: Sandbox wizard introduction - image processing


As it was mentioned in the previous tutorial, sandbox wizard allows to put not only image processing plug-ins into video processing graph, but plug-ins of other supported types as well. For example, video processing plug-ins. Those have something in common with image processing plug-ins in some respect, however there are things which are different - video processing plug-ins never change pixel format of the incoming video frames and never change their size either. Also very often video processing plug-ins may have their own internal state, which depends not only on the configuration of properties they provide, but also on the run time conditions.

The video processing plug-in we'll describe here in more details is the Video File Writer plug-in, which can be used as for writing individual video files, as for making 24/7 video archives, when new video is written while old is removed to maintain video archive size - a useful feature to make a home video surveillance system, for example.

There are number of properties provided by the plug-in, which allow achieving different results - from simplest video to a video archive. Just to get a video file written, there is not much more to configure but its destination folder, file name and the video codec properties. Few properties to tell more about are bit rate and sync presentation time. The bit rate property basically tells codec how many bits should be taken by 1 second of compressed video stream. As a result this property becomes a trade-off between video files size and its quality - higher bit rates make bigger video files of a better quality, while smaller bit rates result is smaller video files and so lower quality. The sync presentation time property allows to make sure that the saved video file is played with the same speed as the original video source. Lets say we have a video source providing 15 frames a second and we configured video codec to write at 30 frames a second rate. We may not be bothered about the difference if all we want is just to save all video frames into a video file. However such file will give impression everything is moving twice faster. This might be actually a benefit for someone trying to make time-lapse video - saving 1 frame a second at 30 fps rate may look cool indeed. However if we want to play video at the same speed it was generated (even if we cannot match frame rate of camera and video file being written), then we can tell plug-in to sync presentation time - to add time-stamp for every video frame telling video player when to present those frames.

By default the Video File Writer plug-in always writes to the same file and so, if the sandbox is restarted, it overwrites any existing file with the same name. If we want to keep old files and create new video files every time the plug-in is started, it is possible to add time-stamp to video file names (date and time with seconds resolution).

And now we are getting closer to the properties used in video archive writing. The first property to enable is splitting video files. When it is switched on, the plug-in writes video files of the certain specified length (in minutes) instead of writing all to a single file. Enabling this property will disable Add time stamp property and make it on for sure - in the end we don't want to overwrite same file again and again. Also once it is enabled, few more properties become available. The main ones we are interested in now are Remove old files and Directory size limit. By enabling those, we tell the plug-in to remove old video files to make sure the size of the destination directory is not more than the specified limit. So set this property to the desired limit (50Gb, 100Gb or more if you wish to) and enjoy you fact you have video archive at hand. You may ask what will be the video archive length in days? Well, it depends on the bit rate you choose and video frame size/rate to some extent.

One last note however - don't try making video archive of multiple cameras writing to the same destination folder. This will create a clash between several instances of the video writing plug-in and so they will start deleting each others old files. If you have several cameras to write video archive for, make sure you configured them to write to different folders.


Next tutorial: Virtual video camera