[FFmpeg-user] Achieving key rotation for aes-128 encryption for HLS with ffmpeg

Aameer Rafiq Wani aameer.rafiq at gmail.com
Wed Mar 15 14:38:39 EET 2017

Hey Guys,

I was trying to figure out how to achieve key rotation while doing aes-128
encryption for HLS trans-coding using ffmpeg . As it is mentioned here (
http://stackoverflow.com/a/34244568/2833695) it should be possible.
Moreover service providers like zencoder.com (
 also do similar thing, so I am guessing that it is an industry standard,
but unfortunately I couldn't figure it out nor could I find any useful
material online .

Till now I was able to do the encryption and decryption (hls transcoded
video),  sample command which is working for me is as under. I am doing
many other things but the encryption bit is highlighted:

ffmpeg  -i sintel_trailer-720p.mp4 -profile:v baseline -level 4.0 -vf
 -start_number 0 -hls_time 10 -hls_list_size 0 -*hls_key_info_file
file.keyinfo* -f hls test_360_.m3u8

bash script which I am using to generate .key and .keyinfo files :
openssl rand 16 > file.key
echo $BASE_URL > file.keyinfo
echo file.key >> file.keyinfo
echo $(openssl rand -hex 16) >> file.keyinfo

Any help especially code snippets describing how to achieve the key
rotation (i.e use of multiple keys based on different segments) would be
ideal, otherwise any suggestions are more than welcome.Thanking all of you
in anticipation of a quick and favorable response.


email: aameer.rafiq at gmail.com
websites: aameer.github.io <aameer at github.io>

More information about the ffmpeg-user mailing list