So you could use ffmpeg from the command line to output just the raw compressed video data: ffmpeg -i filename -an -vcodec copy -f rawvideo output_filename You will most likely find header information belonging to the container format interspersed within the compressed data of a single frame. One problem is that most video files have a container (AVI, MP4, MPEG-PS/TS) around the actual compressed data and you would not want to encrypt anything in that area.
Destroying this information may invalidate your test.Ī possibly easier way to approach the problem would be to research the bitstream syntax of the codec used to encode the video and use the start codes to determine where frames start and whether or not they are I-frames. For instance, I have often seen libavformat return sequence or group of picture headers as part of a video frame packet.
RECOMPRESS ALL FRAMES SOFTWARE
One thing to note is that you might have to be careful when you just encrypt the I-frame packets returned from libavformat or some other demuxing software since they may include data from other headers that are stored in the bitstream. You would then have to write the packets to a new file. In this case, once you read the AVPacket, just encrypt its data if it's a key frame ( packet->flags & PKT_FLAG_KEY). You will not have to actually decode/encode the frames because I assume you just want to encrypt the compressed data. There is a good libavformat/libavcodec tutorial here. Finally you can remultiplex the video into a new file. You can then encrypt data in the packets that are marked as key frames.
Using libavformat (library from ffmpeg), you can demultiplex the video into packets that represent a single frame.