avformat/crypto: add seeking support on read

Multimedia / FFmpeg - Simon Hailes [googlemail.com] - 30 August 2016 10:14 UTC

cyrpto allows reading of data which has been aes-128-cbc encrypted given a key and an iv. But it did not handle filetypes which require seeking... e.g. it failed on an encrypted .mp4 file.

example: take 25.mp4 created with: ffmpeg -f lavfi -i sine=frequency=1000:beep_factor=2:r=48000:duration=720.0 -f lavfi -i testsrc=duration=720.0:rate=25 -vcodec libx264 -cmp 22 -timecode 10:00:00:00 -r 25 -y out\25.mp4

encrypt with: openssl enc -aes-128-cbc -K 12345678901234567890123456789012 -iv 12345678901234567890123456789012 -in 25.mp4 -out 25.enc then to transcode in ffmpeg: ffmpeg -key 12345678901234567890123456789012 -iv 12345678901234567890123456789012 -i crypto:25.enc -vcodec mpeg4 -r 25 -y 25dec.mp4

prior to this modification, the transcode would fail.

Note also: crypto previously maked both reads and writes as streamed, which caused the whole file to be read before the transcode started. Now, for read only, if the underlying layer is not marked as streamed, then crypto is not. This should enable efficient reading of encrypted containers which require seeking.

a13a81a avformat/crypto: add seeking support on read
libavformat/crypto.c | 116 +++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 114 insertions(+), 2 deletions(-)

  • Share