我正在尝试对sample H.264的Google Shaka player文件进行转码和DASH(使用Clear Key加密)。我能够在线拼凑的每一组步骤都会在未加密的情况下产生可播放的版本,然后在我尝试加密时进行分解。
以下是我正在使用的未加密版本的步骤:
将视频与音频分开
ffmpeg -i input.mp4 -an -c copy video_only.mp4
ffmpeg -i input.mp4 -map 0:2 -c copy audio_only.m4a
将视频转码为工作变体(目前仅限1个)
ffmpeg -i video_only.mp4 -an -vcodec libx264 -s 1280x720 -c:v libx264 -b:v 384k -bf 2 -g 90 -sc_threshold 0 -an -strict experimental video_only_384kbps.mp4
3A。创建mpd
MP4Box -dash 5000 -segment-name 'outputseg-%s' -url-template -bs-switching no \
-out output.mpd -rap \
audio_only.m4a \
video_only_384kbps.mp4
4A。将视频加载到Osmo4或Google Shaka中 它会播放。
现在,我尝试进行加密分层。从上面的第2步开始:
3B。使用Clear Key加密变体
MP4Box -crypt drm.xml audio_only.m4a -out audio_only_encrypted.m4a
MP4Box -crypt drm.xml video_only_384kbps.mp4 -out video_only_384kbps_encrypted.mp4
其中drm.xml包含直接来自MP4Box/GPAC site的样本:
<?xml version="1.0" encoding="UTF-8"?>
<GPACDRM type="CENC AES-CTR">
<!-- example for GPAC - keys are listed after the content and UL follows -->
<DRMInfo cypherIV="0x00000000000000000000000000000001" cypherKey="0x6770616363656E6364726D746F6F6C31" cypherOffset="9" type="pssh" version="1">
<BS ID128="6770616363656E6364726D746F6F6C31"/>
<BS bits="32" value="2"/>
<BS ID128="0x279926496a7f5d25da69f2b3b2799a7f"/>
<BS ID128="0x676cb88f302d10227992649885984045"/>
<BS bits="8" string="CID=Toto"/>
<BS ID128="0xccc0f2b3b279926496a7f5d25da692f6"/>
<BS ID128="0xccc0f2b3b279926496a7f5d25da692d6"/>
</DRMInfo>
<CrypTrack IV_size="16" IsEncrypted="1" first_IV="0x0a610676cb88f302d10ac8bc66e039ed" saiSavedBox="senc" trackID="1">
<key KID="0x279926496a7f5d25da69f2b3b2799a7f" value="0xccc0f2b3b279926496a7f5d25da692f6"/>
</CrypTrack>
</GPACDRM>
4b中。创建mpd
MP4Box -dash 5000 -segment-name 'outputseg-%s' -url-template -bs-switching no \
-out output.mpd -rap \
audio_only_encrypted.m4a \
video_only_384kbps_encrypted.mp4
5b中。将视频加载到Osmo4或Google Shaka中。 *在Osmo4上,没有发现任何错误,但玩家只是挂起,直到我杀了它 *在Google Shaka上,我一直收到播放器错误: “CustomEvent {detail:错误:没有DrmInfo存在! 在shaka.media.EmeManager.buildKeySystemQueries_(http://localhost:808 ...,srcElement:null,target:s ... a.p ... r.Player,currentTarget:s ... a.p ... r.Player}
5b之后的output.mpd如下所示:
<?xml version="1.0"?>
<!-- MPD file Generated with GPAC version 0.5.2-DEV-rev566-g4c06d0f-master at 2015-09-03T19:17:57.544Z-->
<MPD xmlns="urn:mpeg:dash:schema:mpd:2011" minBufferTime="PT1.500S" type="static" mediaPresentationDuration="PT0H0M54.424S" maxSegmentDuration="PT0H0M4.992S" profiles="urn:mpeg:dash:profile:full:2011" xmlns:cenc="urn:mpeg:cenc:2013">
<ProgramInformation moreInformationURL="http://gpac.sourceforge.net">
<Title>output.mpd generated by GPAC</Title>
</ProgramInformation>
<Period duration="PT0H0M54.424S">
<AdaptationSet segmentAlignment="true" lang="eng">
<Representation id="1" mimeType="audio/mp4" codecs="mp4a.40.2" audioSamplingRate="48000" startWithSAP="1" bandwidth="140631">
<AudioChannelConfiguration schemeIdUri="urn:mpeg:dash:23003:3:audio_channel_configuration:2011" value="2"/>
<ContentProtection schemeIdUri="urn:mpeg:dash:mp4protection:2011" value="cenc" cenc:default_KID="27992649-6a7f-5d25-da69-f2b3b2799a7f"/>
<SegmentTemplate timescale="48000" media="outputseg-audio_only_encrypted$Number$.m4s" startNumber="1" duration="239616" initialization="outputseg-audio_only_encryptedinit.mp4"/>
</Representation>
</AdaptationSet>
<AdaptationSet segmentAlignment="true" maxWidth="1280" maxHeight="720" maxFrameRate="24" par="16:9" lang="eng">
<Representation id="2" mimeType="video/mp4" codecs="avc1.64001f" width="1280" height="720" frameRate="24" sar="1:1" startWithSAP="1" bandwidth="375052">
<ContentProtection schemeIdUri="urn:mpeg:dash:mp4protection:2011" value="cenc" cenc:default_KID="27992649-6a7f-5d25-da69-f2b3b2799a7f"/>
<SegmentTemplate timescale="12288" media="outputseg-video_only_384kbps_encrypted$Number$.m4s" startNumber="1" duration="46080" initialization="outputseg-video_only_384kbps_encryptedinit.mp4"/>
</Representation>
</AdaptationSet>
</Period>
</MPD>
软件版本:
有没有人对如何进行有任何建议?