Lossless compression for video in opencv

I am working on a video processing project that involves some kind of encryption using a simple XOR operation of a given frame from a camera with a key image and, finally, storing a video file. And for the decryption phase, the XOR operation with the same image will receive the original frames. But the problem is that I decrypt the frame, it seems to be very noisy, and found out that this is due to the lossy image compression that I used during storage. Are there any other lossless compression compression files for opencv ??

+6
source share
4 answers

If you work with windows, you can use CV_FOURCC_PROMPT as the second parameter of the VideoWriter constructor - it will allow you to select a codec from the list and set various parameters. Just for the test you can use uncompressed avi (aka full frames [not compressed]) . It will produce huge files, but should work fine.

Otherwise, just check all the features from the list.

http://www.fourcc.org/codecs.php

Please note that HighGui is meant as a simple tool for experimentation. ( http://opencv.willowgarage.com/wiki/VideoCodecs ), so it may not provide the functionality you need. If so, you will have to use some other library and provide it with every frame processed by opencv.

+3
source

According to the old OpenCV page :

There are several lossless video compressors available. However, none of them is supported on all platforms simultaneously. Look for HuffYUV, CorePNG, Motion PNG or Motion JPEG2000.

Recent OpenCV docs also mention several alternatives such as JPG2000 and LAGS (Lagarith Lossless Codec).

Some time ago, someone posted a post explaining how he used OpenCV and FFmpeg to render video with lossless compression.

+2
source

Official documentation http://docs.opencv.org/trunk/dd/d9e/classcv_1_1VideoWriter.html#ad59c61d8881ba2b2da22cff5487465b5

Most codecs are lossy. If you need a lossless video file, you need to use lossless codecs (e.g. FFMPEG FFV1, Huffman HFYU, Lagarith LAGS, etc.)

If FFMPEG is enabled, use codec = 0; frames per second = 0; You can create an uncompressed (unprocessed) video file.

+1
source

On Debian Linux (using ffmpeg):

 int width = 640; int height = 480; bool isColor = true; string outFName = "out.avi"; Size frameSize = Size(width, height); int fourcc = VideoWriter::fourcc('p', 'n', 'g', ' '); outputVideo.open(outFName, fourcc, cap.get(CAP_PROP_FPS), frameSize, isColor)); 
0
source

All Articles