Added HLS encryption with -hls_key_info_file <key_info_file> option. The
first line of key_info_file specifies the key URI written to the
playlist. The key URL is used to access the encryption key during
playback. The second line specifies the path to the key file used to
obtain the key during the encryption process. The key file is read as a
single packed array of 16 octets in binary format. The optional third
line specifies the initialization vector (IV) as a hexadecimal string to
be used instead of the segment sequence number (default) for encryption.
Changes to key_info_file will result in segment encryption with the new
key/IV and an entry in the playlist for the new key URI/IV.
Key info file format:
<key URI>
<key file path>
<IV> (optional)
Example key URIs:
http://server/file.key
/path/to/file.key
file.key
Example key file paths:
file.key
/path/to/file.key
Example IV:
0123456789ABCDEF0123456789ABCDEF
Example:
ffmpeg -f lavfi -i testsrc -c:v h264 -hls_key_info_file file.keyinfo
foo.m3u8
file.keyinfo:
http://server/file.key
/path/to/file.key
0123456789ABCDEF0123456789ABCDEF
Example shell script:
BASE_URL=${1:-'.'}
openssl rand 16 > file.key
echo $BASE_URL/file.key > file.keyinfo
echo file.key >> file.keyinfo
echo $(openssl rand -hex 16) >> file.keyinfo
ffmpeg -f lavfi -re -i testsrc -c:v h264 -hls_flags delete_segments \
-hls_key_info_file file.keyinfo out.m3u8
--
Signed-off-by: Christian Suloway <csuloway@globaleagleent.com>
Signed-off-by: Dan Dennedy <dan@dennedy.org>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
pull/138/head
Christian Suloway10 years agocommitted byMichael Niedermayer
{"hls_allow_cache","explicitly set whether the client MAY (1) or MUST NOT (0) cache media segments",OFFSET(allowcache),AV_OPT_TYPE_INT,{.i64=-1},INT_MIN,INT_MAX,E},
{"hls_base_url","url to prepend to each playlist entry",OFFSET(baseurl),AV_OPT_TYPE_STRING,{.str=NULL},0,0,E},
{"hls_segment_filename","filename template for segment files",OFFSET(segment_filename),AV_OPT_TYPE_STRING,{.str=NULL},0,0,E},
{"hls_key_info_file","file with key URI and key file path",OFFSET(key_info_file),AV_OPT_TYPE_STRING,{.str=NULL},0,0,E},
{"hls_flags","set flags affecting HLS playlist and media file generation",OFFSET(flags),AV_OPT_TYPE_FLAGS,{.i64=0},0,UINT_MAX,E,"flags"},
{"single_file","generate a single media file indexed with byte ranges",0,AV_OPT_TYPE_CONST,{.i64=HLS_SINGLE_FILE},0,UINT_MAX,E,"flags"},
{"delete_segments","delete segment files that are no longer part of the playlist",0,AV_OPT_TYPE_CONST,{.i64=HLS_DELETE_SEGMENTS},0,UINT_MAX,E,"flags"},