某10

懒得写,咕了

视频 DRM 研究

准备工作
需要安装:GPAC,FFmpeg
可选的额外部分:Shaka Player (用于在网页中播放DRM加密过的视频)
Shaka Player的文档

使用FFMPEG分离音视频

ffmpeg -i miku-264-muxed.mp4 -c:v copy -an tmp/video.mp4
ffmpeg -i miku-264-muxed.mp4 -c:a copy -vn tmp/audio.mp4

crypt.xml文件内容

<?xml version="1.0" encoding="UTF-8" ?>
<GPACDRM type="CENC AES-CTR">
<!-- 
  kid=0x43215678123412341234123412341234
  key=0x12341234123412341234123412341234
  iv=0x22ee7d4745d3a26a
--> 

<!-- CENC -->
<DRMInfo type="pssh" version="1">
  <BS ID128="1077efecc0b24d02ace33c1e52e2fb4b"/>
  <BS bits="32" value="1"/>
  <BS ID128="43215678123412341234123412341234"/>
</DRMInfo>

<CrypTrack trackID="1" IsEncrypted="1" IV_size="8" first_IV="0x22ee7d4745d3a26a" saiSavedBox="senc">
  <key KID="0x43215678123412341234123412341234" value="0x12341234123412341234123412341234"/>
</CrypTrack>

</GPACDRM>

使用MP4BOX加密音视频

mp4box.exe -crypt crypt.xml tmp/video.mp4 -out tmp/video-enc.mp4
mp4box.exe -crypt crypt.xml tmp/audio.mp4 -out tmp/audio-enc.mp4

使用MP4BOX 生成Dash

mp4box.exe -dash 6000 -frag 6000 -mem-frags -rap -profile dashavc264:live -profile-ext urn:hbbtv:dash:profile:isoff-live:2012 -min-buffer 3000  -bs-switching no -sample-groups-traf -single-traf -subsegs-per-sidx 1 -segment-name $RepresentationID$_$Number$$Init=i$ -segment-timeline -out tmp/dash/manifest.mpd tmp/video-enc.mp4#trackID=1:id=v1:period=p0 tmp/audio-enc.mp4#trackID=1:id=a1:period=p0

额外参考
https://stackoverflow.com/questions/33632240/how-to-encrypt-webm-or-mp4-file-using-clearkey-and-then-play-it/34939454#34939454

评论卡