From 907ac20aa29341e49a4f89ff3d4240d92f9a0cb9 Mon Sep 17 00:00:00 2001 From: Christian Suloway Date: Mon, 15 Jun 2015 10:58:07 -0800 Subject: avformat/hlsenc: added HLS encryption Added HLS encryption with -hls_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: (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 Signed-off-by: Dan Dennedy Signed-off-by: Michael Niedermayer --- doc/muxers.texi | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) (limited to 'doc/muxers.texi') diff --git a/doc/muxers.texi b/doc/muxers.texi index 95cdb8faea..1dd7d06761 100644 --- a/doc/muxers.texi +++ b/doc/muxers.texi @@ -263,6 +263,62 @@ ffmpeg in.nut -hls_segment_filename 'file%03d.ts' out.m3u8 This example will produce the playlist, @file{out.m3u8}, and segment files: @file{file000.ts}, @file{file001.ts}, @file{file002.ts}, etc. +@item hls_key_info_file @var{key_info_file} +Use the information in @var{key_info_file} for segment encryption. The first +line of @var{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 @var{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: +@example +@var{key URI} +@var{key file path} +@var{IV} (optional) +@end example + +Example key URIs: +@example +http://server/file.key +/path/to/file.key +file.key +@end example + +Example key file paths: +@example +file.key +/path/to/file.key +@end example + +Example IV: +@example +0123456789ABCDEF0123456789ABCDEF +@end example + +Key info file example: +@example +http://server/file.key +/path/to/file.key +0123456789ABCDEF0123456789ABCDEF +@end example + +Example shell script: +@example +#!/bin/sh +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 +@end example + @item hls_flags single_file If this flag is set, the muxer will store all segments in a single MPEG-TS file, and will use byte ranges in the playlist. HLS playlists generated with -- cgit v1.2.3