Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Lossless compression for video in opencv

I am working on a video processing project that involves some sort of encryption using simple XOR operation of a given frame from camera with a key image and finally store the video file. And for decryption phase the XOR operation with the same image will get the original frames. But the problem is while I decrypt the frame appears to be very noisy and found out that its because of the lossy image compression foramt I used while storing. Is there any other lossless image compression foramts for opencv??

like image 400
hunter Avatar asked Mar 31 '13 11:03

hunter


2 Answers

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

Otherwise just check all of possibilities from the list

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

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 are looking for. If so you will have to use some other library and give it each frame processed by opencv.

like image 66
cyriel Avatar answered Jan 04 '23 20:01

cyriel


According to the old page of OpenCV:

There are several lossless video compressors available. No single one however is supported on all platforms at the same time. Look for HuffYUV, CorePNG, Motion PNG or Motion JPEG2000.

Recent OpenCV docs mentions a couple of alternatives as well, like JPG2000 and LAGS (Lagarith Lossless Codec).

Some time ago someone posted a message explaining how he had used OpenCV and FFmpeg to render videos with lossless compression.

like image 34
karlphillip Avatar answered Jan 04 '23 21:01

karlphillip