Click here to Skip to main content
15,887,027 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi fellow CP'ians,
does anyone happen to know a codec to use with openCV encoding videos with lossless compression? Problem is since the videofiles get encrypted i need a codec that doesn't change the RGB values. Otherwise the encryption gets lost.

I already found this on SO[^] but none of the given answers work for me. If you could provide me a guide you know or share some knwoledge i would appretiate it.


Thanks in advance :)

Edit:
TO be more precise since i guess i was quite unclear on what i wanted, here a "revision" of my Question.

I try to process videos with OpenCV and hide information in single frames using steganographic methods. During saving of the video the compression gets also done with the codec i hand to the videowriter. To get the hidden information back, since i want to decrypt it later after these steps, the RGB values are not allowed to be changed.

As far as i tried it out, the compression gets always done during the save with OpenCV. So i can't reverse the steps? Because if i compress the video and put in the "encryption" later i still have to save it again and then the compression hits again?
Might there be a setting where you can disable compression on saving or is there a specific codec for this purpose.
Does someone maybe have an idea how to use to codecs written below?

Thanks in advance :)

What I have tried:

I already saw CorePNG, Lagarith, MotionPNG but i don't know how to use them. It tells me the encoder can't be found.
Posted
Updated 24-May-16 5:49am
v2

If the videos are already encrypted, I doubt you're going to get any compression at all, if not very little.

For the best result, the video would have to be compressed first, then encrypted.
 
Share this answer
 
Comments
Patrice T 23-May-16 20:45pm    
5ed
HobbyProggy 24-May-16 3:18am    
Thanks for the info, i am the one encryping the videos. It's because of a study of how you could prevent piracy on videos by only masking the faces of the persons in the video.
Dave Kreskowiak 24-May-16 8:31am    
The way you describe is going to be extraordinarily difficult. You're going to have to write a codec to encrypt regions of an image WITHOUT corrupting the image data. That's going to be pretty much impossible along with being very CPU intensive.

The better solution is to encrypt the entire video, not just a portion of every single frame.
HobbyProggy 24-May-16 9:47am    
Well the problem is that this is about finding out if this way is better, algorithms for that system are already in use, i get the encryption done quite good but the compression ruins the RGB values which is destroying the mask.
Dave Kreskowiak 24-May-16 12:45pm    
Well, you're not going to be able to encrypt a block of data and leave the rest of the frame alone. Encrypting that data corrupts the crap out of it. It's either the entire video, or you've got a massive problem on your hands.

Also, you're not encrypting a single block of a frame. You're encrypting each line in the block you're trying to encrypt in each frame individually! For example, each line of video is, say, 400 bytes long. The face you're trying to encrypt is about 80 bytes wide in the center of the frame. This means that you're leaving alone the first 160 bytes of the line, encrypting the next 80, and leaving the remaining bytes in the line alone. This "stride" is repeated for each line in the frame until you reach the end of the block you're trying to encrypt.

Now, you've got a much bigger problem. The block of video you're replacing may be 80 bytes wide, but the encrypted block of bytes you get back will probably NOT be 80 bytes wide. You just completely corrupted the entire frame because now it's much longer than the video codec decoding this crap expects.

What you want to do is STILL not possible the way you want to do it.
Quote:
Problem is since the videofiles get encrypted i need a codec that doesn't change the RGB values. Otherwise the encryption gets lost.
You got the wrong approach.
Things work in reverse order.
you can do tests with standard tools that do compression or encryption.
Compare the results of the 2 ways with sample files
Get data files >> Encrypt >> Compress
Get data files >> Compress >> Encrypt
You will see which one works by yourself.

The right way is :
Get data files >> Compress >> Encrypt
 
Share this answer
 
Comments
HobbyProggy 24-May-16 3:18am    
thanks, i'll try that out and respond :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900