[Libav-user] Hooks for decrypting data between libavformat and libavcodec?

Peter Krefting peter at softwolves.pp.se
Wed Apr 20 20:35:38 EEST 2022


Hi!

I am using  to read data in MPEGTS format that is encrypted using HLS 
sample AES encryption. I am reading the segment files directly, so I 
cannot use the code in libavformat to do the decryption for me. I am 
currently reading the file using avformat_open_input() and calling 
av_read_frame() to get the individual frames, which I then decrypt using 
a custom routine before passing to the decoder using 
avcodec_send_packet().

My problem is that before I get the packet the library code sets up 
metadata from the stream, but fails as the data is encrypted, so 
AVPacket::duration and AVPacket::sample_rate are both 0 some times.

Is there a way to inject a hook to decrypt the packages after they are 
unpacked by the MPEGTS container reader, but before they are sent to the 
probing code? I can use a custom AVIOContext to read from the file, but 
that is before container unpacking.

-- 
\\// Peter - http://www.softwolves.pp.se/


More information about the Libav-user mailing list