Wish to achieve:
Mp4 a video file into a plurality of cutting segments ts, using AES-128 encryption for each segment in the cutting process, and finally generate a video index file of m3u8;
If you want to encrypt, ready to look at two things first:
Encryption key used
openssl rand 16 > enc.key ( 生成一个enc.key文件 )
Another is iv
openssl rand -hex 16 ( 生成一段字符串,记下来)
Create a new file enc.keyinfo content format is as follows:
Key URI # enc.key的路径,使用http形式
Path to key file # enc.key文件
IV # 上面生成的iv
A few examples:
http://localhost/video/enc.key
enc.key
48c674428c1e719751565ad00fe24243
Finally, the focus here
ffmpeg -y \
-i test.mp4 \
-hls_time 12 \ # 将test.mp4分割成每个小段多少秒
-hls_key_info_file enc.keyinfo \
-hls_playlist_type vod \ # vod 是点播,表示PlayList不会变
-hls_segment_filename "file%d.ts" \ # 每个小段的文件名
playlist.m3u8 # 生成的m3u8文件
M3u8 generated files can be played directly by most players