0

I am developing a program that encrypts and saves video files and allows them to play only in programs that have key values. (by C#)

I was looking for a way to encrypt a video file and found a way to encrypt it using FFMPEG's CENC.

ffmpeg -i SampleVideo.mp4 -vcodec copy -acodec copy -encryption_scheme cenc-aes-ctr -encryption_key 76a6c65c5ea762046bd749a2e632ccbb -encryption_kid a7e61c373e219033c21091fa607bf3b8 SampleVideo_encrypted.mp4

ffplay SampleVideo_encrypted.mp4 -decryption_key 76a6c65c5ea762046bd749a2e632ccbb

ffmpeg -decryption_key 76a6c65c5ea762046bd749a2e632ccbb -i SampleVideo_encrypted.mp4 -vcodec copy -acodec copy SampleVideo_decrypted.mp4

FFmpeg: how to produce MP4 CENC (Common Encryption) videos

It is easy to encrypt and makes use of the header information of the video file.

But I couldn't find a way to apply decryption at the same time as the Capture Video of OpenCV. I thought I could use FFMPEG of OpenCV Backend and set the options, so I found a way to set the Windows environment variable, but it didn't work.(Only the gray screen is output.) As a result of the search, only options related to H/W acceleration appear in OS environ.

How to add ffmpeg options to VideoCapture (Post written in python)

import os
os.environ["OPENCV_FFMPEG_CAPTURE_OPTIONS"] = "video_codec;h264_cuvid"
cap = cv2.VideoCapture(url)

Code I tested (not worked, c#)

System.Environment.SetEnvironmentVariable("OPENCV_FFMPEG_CAPTURE_OPTIONS",
                                          "decryption_key;76a6c65c5ea762046bd749a2e632ccbb");
VideoCapture video = new VideoCapture(filename, VideoCaptureAPIs.FFMPEG);
...

How can I open a video encrypted with FFMPEG using openCV?

Regards.

0 Answers0