生成加密key
1 | openssl rand -base64 120 > enc.key |
生成iv
1 | openssl rand -hex 16 |
创建keyinfo文件,将上面的内容写进文件
1 | https://pure-sea-19495.herokuapp.com/api/key |
1 | ffmpeg -i output.mp4 -c copy -bsf:v h264_mp4toannexb -hls_time 600 -hls_key_info_file keyinfo -hls_segment_filename data/output%03d.ts data/playlist.m3u8 |
播放
1 | ffplay -protocol_whitelist "file,https,crypto,tcp,tls" playlist.m3u8 |
修改加密文件中的key为本地文件
1 | ffplay -allowed_extensions ALL new.m3u8 |
1 | -bsf:v h264_mp4toannexb |
解码暂时没测试通过…
iv 不需要加 0x
k 是16进制的值
1 | openssl aes-128-cbc -d -in output000.ts -out output000_d.ts -nosalt -iv 57cf5c1e976898bd436da81ec8779539 -K xx |