Video recording software
Author: Ph.D. Marcin Just, Ph.D. Michał Tyc (DiagNova Technologies)In the case of using a device such as "DVD player with recording function" to record the image, after connecting the signal source (camera), the user can simply press the record button and forget about everything, of course except for switching off the recording. This approach has its advantages, but with regular recording a large number of small files quickly will lead to clutter the collection of video and practically prevent efficient management. A quick search for a few seconds recording in a set of thousands of recordings will then be a real art. In the case of recording short sequences in large numbers, a computer with the appropriate software installed is a much better solution. Initially, this requires more work from the user, but it pays off very quickly. If the number of recordings is really large, the software connected to the database is the best solution to keep the files in order. The chapter discusses issues related to video recording in newer systems from the Microsoft Windows NT, i.e. Windows 2000, Windows XP, Windows Vista and Windows 7. The no longer used systems that are practically older than Windows 2000 will be omitted, ie Windows NT 4 and the Windows 9x (eg Windows Millenium - extremely unstable and not recommended for any computer work).
The recording program is not enough
There are programs that can do all the recording themselves, like:
- handling of the capture device,
- image editing,
- compression,
- recording to disk,
but they are gradually becoming a thing of the past. The variety of recording devices, the variety of requirements as to how to save movies on the computer disk, and generally rapid changes in computer technology (e.g., the recent rapid changes in operating systems) necessitate the development of software that relies heavily on mechanisms embedded in operating systems. On the one hand, it concerns the use of special standards of cooperation with intercepting devices in order to download data, on the other hand, the use of the so-called codecs - programs that compress (properly encode) and decompress (decode) the video material. The recording program must therefore connect correctly to the so-called the driver of the capture device (it must be installed in the system!) through the selected cooperation mechanism, after downloading the image, perform the required operations to improve readability, display it on the screen (if the preview of the recorded material is required) and select the appropriate codec to save it to the the medium (usually on the computer's hard drive). Due to the dependency of the recording program on a whole group of other programs, its malfunction is not always caused by errors in its structure. Problems can often be caused by external programs. Due to frequent changes in standards, currently additional programs (drivers, codecs, etc.) are usually responsible for incorrect operation of recording programs.
We will now go through all the steps leading up to getting video saved to disk.
Getting image data
The entire process must begin with image data recording. The intercepting device can have any internal structure. The recording program usually cannot know it and must rely on the so-called the driver written by the manufacturer of the hardware. It can connect to the controller in several ways:
- directly, which requires the device manufacturer to provide detailed documentation and is very rare,
- using Video for Windows (VfW) mechanisms from Windows 3.1 (from 1992),
- through the DirectShow mechanism, which is a component of the extremely important DirectX mechanism,
- with devices that share single frames (scanners, cameras) using the TWAIN mechanism.
Each of the methods has its advantages and disadvantages. TWAIN is inefficient and is suitable for acquiring only single frames, DirectShow is complicated, prone to minor incompatibilities and very overloading computer hardware, but modern and very universal, Video for Windows - a bit archaic and with very limited functionality, but with due to the possibility of working on old computers - quite efficient. The direct method theoretically ensures the maximum use of the capabilities of the device and would be best if it did not require individual preparation for each device. For this reason, it is practically not used in universal recording programs. Video for Windows and DirectShow are mechanisms that the program can use at every stage of the examination: data download, compression and storage. Each of these mechanisms has advantages and disadvantages at each stage.
DirectShow
Currently, the DirectShow mechanism is the most popular. You will probably need the version shipped with DirectX 9.0c or later (that is, shipped with DirectX 10 or 11) for the recorders to work properly. Generally, DirectShow does not change quickly and there is no requirement for DirectX 10 or 11 to take full advantage of DirectShow.
DirectShow is based on combining the so-called filters. A filter is an object that generates, transforms, presents (e.g. displays on a monitor screen or plays sound) or saves multimedia data to the disk. Combined filters create the DirectShow graph. The capture device manufacturer usually provides a source filter to generate data for the graph with the driver, and the codecs are available as various transform filters.
The appearance of example DirectShow graphs for displaying the image from the camera (top)and displaying the recording from the computer disk (bottom)
When creating a graph to retrieve image data from a grabber, the recorder must first of all select a source filter (in the case of several capture devices, it must allow the user to select one of them) and set the connection parameters (resolution, color space and frame rate).
Data processing
Data processing is provided by a recording program. If its operation is based on DirectShow graphs, it usually implements it by adding a custom filter or a set of filters to the graph (although it is relatively inefficient with complicated processing). In specialized software, however, other approaches to the problem are possible, allowing for better data flow management than is implemented by DirectShow filters. Data processing is designed to:
- optimally convert the data format from the grabber to the format displayed on the screen (optimal conversion from YUV (YUY2 or YV12) to RGB_32 formats)
- correct contrast, brightness,
- correct white balance,
- deinterlace,
- make other improvements (image histogram correction, etc.),
- prepare data for compression filters (in the case of DirectShow).
The best programs, has possiblity to process data in real time with an immediate preview of the results on the screen.
Data compression
Image data has a very large volume. Modern hard drives may have enough capacity to hold thousands of short videos without compression, but the speeds of ordinary drives are even now too low to ensure full comfort in managing such a collection (backup - backup, archiving, search, transfer), and fast SSDs (Solid State Drive / Disks based on Flash memories) are too expensive. This problems solition is data compression. Human eye and brain are not available to catch some image detailes, so they can be removed from the image with no apparent loss of quality. This is how single-frame compression works. In addition, the adjacent frames usually differ slightly from each other and you can only save the differences between them - it is temporal compression. You can also compress movies without losing any information (lossless compression).
Depending on the selected method, a compression ratio (data volume reduction ratio) of 1.5 up to over 100 can be obtained.
You also have to remember that compressed data must be decompressed before viewing. Therefore, in addition to the compressor, you also need a decompressor. They usually constitute a set called a codec.
Among the most famous codecs can be mentioned:
- HuffYUV (lossless, very efficient),
- Lagarith (lossless, relatively good compression),
- Alparysoft, CorePNG, MSU, FFV1 – various lossless
- MJPEG – at the moment essentially obsolete,
- MPEG 1 codecs
- MPEG 2 codecs
- MPEG 4 codecs (many types, np. XviD, ffdshow, Divx)
- x264 (a new format useful especially for movies of good quality and high definition, but with very high requirements as to the computing power of the computer).
Most of this codecs ale available throught Video for Windows mechanisms, and as filters for DirectShow. MPEG 1, MPEG 2, MPEG 4 and other new codecs use temporal copression, older (MJPEG) and lossless codecs usually compress frames individually.
There is a clear distinction between the terms compressor, decompressor, codec, filter and codec pack.
Codec pack (in example K-Lite Codec Pack, CCCP) – a set of selected codecs, theoretically enabling viewing of all types of movies and compression using various methods. Unfortunately, often also having in their collection codecs placed illegally (without paying the required license fees) or completely exotic, often also conflicting with each other. Fixing the codec system corruption in the system caused by the incorrect installation of a codec packet is often extremely complicated, the probability of an optimal codec selection by the system from such a wide list is then small. We strongly discourage this solution.
Codec – compressor/decompressor set
Filter – realization of the compressor or decompressor in a way that enables its use in DirectShow technology.
The best solution is to install a few codecs of your choice. A good solution is to install ffdshow (supports a multitude of different formats), XviD (for MPEG 4 compression as it is stable and efficient), HuffYUV, Lagarith and several others. If necessary, you can install selected codecs to decode several additional formats later.
In the DirectShow mechanism, the filter can be selected manually, or, which is often used, it can be selected by DirectShow automatically. When selecting an automatic system, the system uses a special number set for each codec filter at the time of installation - this is called merit. It specifies the priority in using the filter. Installing a lot of codecs (while installing a codec pack) causes them to compete with each other, assigning each other (simply speaking) higher and higher numbers to "beat" the competition. This leads to a complete lack of control over what will be used and when.
Good software does not allow random selection of the compressor. It chooses a well-known, proven compressor, or leaves the choice to the user.
Saving on data storage media
The saving function is performed, as mentioned, by Video for Windows and DirectShow.
DirectShow provides many more additional features and supports more standards (e.g. streaming data), but also has some drawbacks that make it difficult to operate accurately on single frames. Video for Windows does not support the latest data formats (so-called containers) and data types (including streaming data), but it allows very precise handling of even single frames.
When saving on the disk, the data has a specific format, but you must select the method of saving this data on the medium. This is called container selection. This is partly related to the choice of codec and media type (data type - streaming or not). The most popular container is AVI. It is the only one supported by Video for Windows mechanisms and cannot contain streaming data. Other known containers are those related to the standard VideCD (MPEG1 - DAT) and DVD (MPEG2 - TS), ASF (ASF, WMV), Matroska (MKV), RealMedia (RM), QuickTime (MOV).