[root@node2 ~]# cat /etc/redhat-release Red Hat Enterprise Linux Server release 6.8 (Santiago) [root@node2 ~]# uname -a Linux node2 2.6.32-642.el6.x86_64 #1 SMP Wed Apr 13 00:51:26 EDT 2016 x86_64 x86_64 x86_64 GNU/Linux [root@node2 ~]#
1.https://ffmpeg.org/download.html#build-linuxhtml
2.node
3.下載用wget或者迅雷linux
wget https://johnvansickle.com/ffmpeg/builds/ffmpeg-git-amd64-static.tar.xzgit
4.若是想要ffmpeg命令全局可用,能夠在/usr/bin目錄加個連接bash
cd /usr/bin ln -s /root/ffmpeg-git-20191105-amd64-static/ffmpeg ffmpeg
1.命令ide
ffmpeg -y -i test.mp4 -hls_time 50 -hls_playlist_type vod -hls_segment_filename "video/file%d.ts" playlist.m3u8
-i test.mp4 輸入文件test.mp4 ui
-hls_time 50 分隔的每小段是50s加密
-hls_playlist_type vod 播放類型 vod 是點播,表示PlayList不會變
-hls_segment_filename "video/file%d.ts" 首先創建video文件夾,文件名都是相似file0.ts
playlist.m3u8 m3u8的文件名spa
加密用的 key.net
openssl rand 16 > enc.key (生成一個enc.key文件)
生成 iv
openssl rand -hex 16 (生成一段字符串,記下來)
64f362fe759fcd5f36570ef03fab696f
新建一個文件 enc.keyinfo
[root@node2 ~]# cat enc.keyinfo http://localhost/video/enc.key enc.key 64f362fe759fcd5f36570ef03fab696f
http://localhost/video/enc.key enc.key的路徑,使用http形式 Key URI
enc.key Path to key file
64f362fe759fcd5f36570ef03fab696f iv
命令:
ffmpeg -y -i test.mp4 -hls_time 50 -hls_playlist_type vod -hls_segment_filename "video/file%d.ts" -hls_key_info_file enc.keyinfo playlist.m3u8
-hls_key_info_file enc.keyinfo
[root@node2 ~]# hexdump -v -e '16/1 "%02x"' enc.key deb7bc285a864bbd9073d72250829728
開發時常常會需查看非文本文件內容,最多見的16進制查看器就是hexdump
-v 不要省略
-e 指定格式字符串,格式字符串由單引號包含,格式字符串形如:’a/b 「format1」 「format2」
%02x:兩位十六進制
命令
openssl aes-128-cbc -d -in env.ts -out media_decryptd_0.ts -nosalt -iv 00000000000000000000000000000000 -K deb7bc285a864bbd9073d72250829728
-K deb7bc285a864bbd9073d72250829728 密鑰16進制查看器就是hexdump 看的enc.key
-iv printf '%032x' $index index 就是file%d.ts 中的d
參考資料:
1.https://blog.csdn.net/nizhengjia888/article/details/78041945