X264 VFW

From Emgu CV: OpenCV in .NET (C#, VB, C++ and more)
Revision as of 03:13, 2 October 2018 by Canming (talk | contribs) (Added instruction to install x264 VFW)
Jump to navigation Jump to search

VideoWriter & H.264

Open CV's VideoWriter is used for saving image sequences into Video files. For Windows, the default Open CV implementation for saving MJPEG files do not provide much compression, if you are saving a long video file it may consume lost of hard drive space. H.264 video format generally provide great compression ratio and is of good quality. One of the option to encode H.264 file using Open CV's VideoWriter, is to use the FFMPEG backend, and install Cisco's H.264 codec from here. While the cisco H.264 implementation using FFMpeg provides good default compression ratio, but there is no option to specific the quality of the video. Some times we would like to have higher quality video output that takes more spaces, and some times we want lower quality video that can save spaces.

Here we are going to walk you through using the X264 VFW pacakge with VideoWriter, such that you can specify the video quality and producing H.264 files that matches your needs.

System Requirement

Component Requirement Detail
Emgu CV Version 4.0+
Operation System Windows
  • The code used in this tutorial use components from the Open CV / Emgu CV 4.0 release. At tise moment you will need to build the binary from the source code in the Git repository.

Installing X264 VFW

You can download X264 VFW from sourceforge

Note: X264 VFW licensed under GPL v2, you may need to seek professional advise if you are going to use it in a commercial product.

Once downloaded and installed, there should be two configuration program for you to setup x264vfw. One is for the 32-bit codec (Configure x264vfw) and the other is for the 64bit codec (Config x264vfw64). You can use the default configuration but here I am going to walk you through the 64-bit settings.

Once the configuration page is loaded, it will look like follows: X264vfw64 configuration.png

Use the Ratefactor under the Rate control to set the video output quality. Higher quality means bigger file and lower quality means smaller file.

You would also want to check the "Create stats file" box and let the X264 VFW codec write out some statistic to a file on the local disk. It will be a good way to confirm Open CV is using X264 VFW to save video files later. Once that is done, click the "OK" button to finish the configuration.