使用bento4產生加密的DASH
參考:
https://www.bento4.com/developers/dash/encryption-and-drm/
https://github.com/Dash-Industry-Forum/dash.js/wiki/
Step 1. 下載Bento4工具
從bento4官網上下載已編譯好的二進位檔
https://www.bento4.com/downloads/
Step 2. 產生fMP4影片檔
建議使用mp4影片,使用bento4的mp4fragment將mp4正規化成fMP4檔案
mp4fragment original.mp4 fragmented.mp4
Step 3. 決定加密的KEY和IV值
可參考openssl rand -hex 16產生key和iv值
Step 4. 將fMP4加密並輸出成DASH
以下範例使用的加密key和iv
VID_KID=6c145258e3df0584cd61f57e0ed5cba1
VID_KEY=5a867de28e7a029c2e995687b8992693
AUD_KID=1716d547cd7c0398bd244ac06c8a2ec8
AUD_KEY=0c63c5c13d0d25d697f5a38bb1ce7190
COMM_IV=c35263c8381d0b6b80f93360a5ca2ee6
用CENC加密的DASH串流
cenc使用aes-128-ctr應不需要iv值, 這裡只是方便打指令都寫上
mp4dash -f \
--encryption-key=video:${VID_KID}:${VID_KEY}:${COMM_IV},audio:${AUD_KID}:${AUD_KEY}:${COMM_IV} \
--encryption-cenc-scheme=cenc \
-o bento4_cenc \
--mpd-name=encrypted.mpd \
fragmented.mp4
用CBCS加密的DASH串流
mp4dash -f \
--encryption-key=video:${VID_KID}:${VID_KEY}:${COMM_IV},audio:${AUD_KID}:${AUD_KEY}:${COMM_IV} \
--encryption-cenc-scheme=cbcs \
-o bento4_cbcs \
--mpd-name=encrypted.mpd \
fragmented.mp4
用CBC1和CENS加密的DASH串流
bento4工具其實也能產生cbc1和cens的加密流,但是我使用shaka player播放時失敗
mp4dash -f \
--encryption-key=video:${VID_KID}:${VID_KEY}:${COMM_IV},audio:${AUD_KID}:${AUD_KEY}:${COMM_IV} \
--encryption-cenc-scheme=cbc1 \
-o bento4_cbc1 \
--mpd-name=encrypted.mpd \
fragmented.mp4
mp4dash -f \
--encryption-key=video:${VID_KID}:${VID_KEY}:${COMM_IV},audio:${AUD_KID}:${AUD_KEY}:${COMM_IV} \
--encryption-cenc-scheme=cens \
-o bento4_cens \
--mpd-name=encrypted.mpd \
fragmented.mp4
產生無加密的DASH
mp4dash -f -o bento4_clear --mpd-name=clear.mpd fragmented.mp4
留言