Hello all clearkey experts, if any!! I am having a hard time with this so I am asking for help. I am using mp4box to create content using clearkey common enc.
I feel like I am doing all the steps correctly but still resulting in failed playback. What am I missing here.
First I run the cablelabs clearkey.jar to generate the crypt file.
san-mpnsk:cryptgen dsparaci$ java -jar clearkey.jar 1:cd7eb9ff-88f3-4cae-b061-85b00024e4c2=63cb5f7184dd4b689a5c5ff11ee6a328
Ensure the following keys are available to the client:
cd7eb9ff88f34caeb06185b00024e4c2 : 63cb5f7184dd4b689a5c5ff11ee6a328 (zX65_4jzTK6wYYWwACTkwg : Y8tfcYTdS2iaXF_xHuajKA)
<GPACDRM type="CENC AES-CTR">
<DRMInfo type="pssh" version="1">
<BS ID128="1077efecc0b24d02ace33c1e52e2fb4b"/>
<BS bits="32" value="1"/>
<BS ID128="cd7eb9ff88f34caeb06185b00024e4c2"/>
</DRMInfo>
<CrypTrack IV_size="8" first_IV="0x603f39bfdb3d9799" isEncrypted="1" saiSavedBox="senc" trackID="1">
<key KID="0xcd7eb9ff88f34caeb06185b00024e4c2" value="0x63cb5f7184dd4b689a5c5ff11ee6a328"/>
</CrypTrack>
</GPACDRM>
san-mpnsk:cryptgen dsparaci$
I then create encrypted track from a video only bigbuckbunny.mp4
mp4box -crypt data.xml BigBuckBunny_320x180_video.mp4 -out BigBuckBunny_320x180_enc.mp4
Now I dash it.
mp4box -dash 6000 -profile live -segment-timeline BigBuckBunny_320x180_enc.mp4
Running mp4box -diso results in this pssh info
<SampleGroupDescriptionBox grouping_type="seig" default_length="20">
<BoxInfo Size="44" Type="sgpd"/>
<FullBoxInfo Version="1" Flags="0x0"/>
<CENCSampleEncryptionGroupEntry IsEncrypted="1" IV_size="8" KID="0xCD7EB9FF88F34CAEB06185B00024E4C2"/>
</SampleGroupDescriptionBox>
</SampleTableBox>
</MediaInformationBox>
</MediaBox>
</TrackBox>
<ProtectionSystemHeaderBox SystemID="0x1077EFECC0B24D02ACE33C1E52E2FB4B">
<BoxInfo Size="52" Type="pssh"/>
<FullBoxInfo Version="1" Flags="0x0"/>
<PSSHKey KID="0xCD7EB9FF88F34CAEB06185B00024E4C2"/>
</ProtectionSystemHeaderBox>
I pass this object into setProtectionData on MediaPlayer.js
var data = {
"org.w3.clearkey": {
"clearkeys": {
"zX65_4jzTK6wYYWwACTkwg": "Y8tfcYTdS2iaXF_xHuajKA"
}
}
}
Stream fails to init here
[198] Initialization finished loading
[203] DRM: onNeedKey
[203] DRM: initData: 4psshw茂矛脌虏M卢茫<R芒没K脥~鹿每聢贸L庐掳a聟掳$盲脗
[208] DRM: KeySystem Access Denied! -- Key system access denied!
Note - regarding the data sent into player, I have tested this process with cablelabs url http://html5.cablelabs.com:8100/cenc/ck/dash_initdata.mpd and data
var data = {
"org.w3.clearkey": {
"clearkeys": {
"IAAAACAAIAAgACAAAAAAAg": "5t1CjnbMFURBou087OSj2w"
}
}
}
And playback works as expected so I am failing somewhere in the content prep steps.
@AkamaiDASH So far, I have not been able to reproduce your issue. I have taken the XML crypt file that you posted and encrypted my own content. Then I used the exact MP4Box -dash command line that you posted to DASH the content. The only difference in my test was that I just updated the sources list with my test content and protection data:
{
"name":"CableLabs Test Content",
"submenu":[
{
"name":"DS Test",
"url":"http://localhost/dash/cenc/dscktest/dash.mpd",
"browsers":"",
"protData":{
"org.w3.clearkey":{
"clearkeys":{
"zX65_4jzTK6wYYWwACTkwg": "Y8tfcYTdS2iaXF_xHuajKA"
}
}
}
},
@greg80303 Thanks for looking!
Are you using mp4box -crypt data.xml ..... ?
I also added same source info into the eme player and still get same message. here is the mpd I have mounted on the dash content storage site
http://dash.edgesuite.net/akamai/test/bbb_enc/BigBuckBunny_320x180_enc_dash.mpd
Error in eme
http://dash.edgesuite.net/akamai/test/bbb_enc/BigBuckBunny_320x180_enc_dash.mpd PlayDelete
ERRORDRM: KeySystem Access Denied! -- Key system access denied!
I wonder if it is based on where it is served from of because it is video only track?
@greg80303 Or is that I do not have something like this in the manifest!!
<ContentProtection schemeIdUri="urn:mpeg:dash:mp4protection:2011" value="cenc" cenc:default_KID="20000000-2000-2000-2000-200000000002"/>
<ContentProtection schemeIdUri="urn:uuid:1077efec-c0b2-4d02-ace3-3c1e52e2fb4b">
<cenc:pssh>AAAANHBzc2gBAAAAEHfv7MCyTQKs4zweUuL7SwAAAAEgAAAAIAAgACAAIAAAAAACAAAAAA==</cenc:pssh>
</ContentProtection>
@AkamaiDASH It doesn't need to be in the manifest if it is in the initialization segment. The test content I created did not have the PSSH data in the manifest. My manifest only has this:
<ContentProtection schemeIdUri="urn:mpeg:dash:mp4protection:2011" value="cenc" cenc:default_KID="cd7eb9ff-88f3-4cae-b061-85b00024e4c2"/>
and is that default KID the GUID used to create crypt file. I tired running the -cp trigger on the CryptfileGen java but keep getting this error.
############# Content Protection Element #############
Exception in thread "main" java.lang.UnsupportedOperationException
at org.cablelabs.cryptfile.DRMInfoPSSH.generatePSSHData(Unknown Source)
at org.cablelabs.cryptfile.DRMInfoPSSH.generateCENCContentProtectionData(Unknown Source)
at org.cablelabs.clearkey.cryptfile.ClearKeyPSSH.generateContentProtection(Unknown Source)
at org.cablelabs.clearkey.cryptgen.CryptfileGen.main(Unknown Source)
and is that default KID the GUID used to create crypt file.
Nevermind I see that it is. No luck after adding this to my MPD. Must be something simple that I am missing. Thanks for confirming the steps are proper.
@AkamaiDASH I don't think this is the problem, but you should always use -profile "dashavc264:onDemand" or -profile "dashavc264:live" when DASH-ing your content with MP4Box. These options will make sure that the <ContentProtection> element is at the AdaptationSet level in the MPD instead of the Representation as mandated by the DASH-IF guidelines.
I don't think this is the problem because I was able to create my own test content using your DASH command line with any problem.
I'll take a look at your content to see if I can see an obvious problem.
Thanks for point that out. I just notice the rep level CP node. I just took it out and moved up to see if it makes a difference in this case, really throwing darts in the dark. Ill redo the content with your suggestions to see if matters.
@AkamaiDASH Here is another thought... When requesting access to a KeySystem you are providing not only information about the DRM (drm type, session persistence, etc), you are also providing information about the media, since often the CDM is responsible for actually decoding the audio/video. So, I'm looking at the content mime type that shows up in your content ("video/mp4:codecs=avc1.42c00d"). It is quite possible that you are using an AVC profile/level combination that is not supported by your browser/CDM.
How are you transcoding your source content?
@greg80303
How are you transcoding your source content?
So, All I actually did we demux the mp4 from https://peach.blender.org/download/ (AVI Mpeg4 video, AC3 surround sound)
Then with the video only file I did the steps above. This must be my issue. Looking at the options in mp4box now
We are trying with proper AAC audio and h2.64 video from transcode group here at Akamai. Ill run the same steps as above and see if it solves the issue. Thanks a million @greg80303. Big help.
@AkamaiDASH You can take a look at my transcoding script that uses ffmpeg.
Hello @greg80303 the transcoding script you linked to no longer exists. Dead link.
@AkamaiDASH You can take a look at my transcoding script that uses ffmpeg.
The link seems to be broken, can you repost it?
Apologies to all who have commented here about the transcoding script. I no longer have access to the github account where that script was held as it is owned by my former employer. However, I will take a pass through some of my archived files and see if I still have a copy anywhere.
@Duna I found the script in some archived files:
#!/bin/bash
# Copyright (c) 2014, CableLabs, Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
# Override paths to FFMPEG tools here
ffmpeg=ffmpeg
ffprobe=ffprobe
function usage {
echo ""
echo "Transcode/Transrate Script"
echo "usage:"
echo " video_scaled_demux_5bitrates <input_file> <output_dir>"
}
if [ -z $1 ]; then
echo "Must provide input media file"
usage
exit 1
fi
if [ -z $2 ]; then
echo "Must provide output directory for transcoded/transrated files"
usage
exit 1
fi
mkdir -p $2
framerate=$((`./ffprobe $1 -select_streams v -show_entries stream=avg_frame_rate -v quiet -of csv="p=0"`))
function transcode_video {
vbitrate=$1
res=$2
profile=$3
level=$4
outdir=$5
infile=$6
outfile=video_`echo $res | sed 's/:/x/'`_h264-${vbitrate}.mp4
$ffmpeg -i $infile -s $res -map_chapters -1 -maxrate $vbitrate -minrate $vbitrate -bufsize $vbitrate -an -codec:v libx264 -profile:v $profile -level $level -b:v $vbitrate -x264opts "keyint=$framerate:min-keyint=$framerate:no-scenecut" $outdir/$outfile
}
function transcode_audio {
abitrate=$1
outdir=$2
infile=$3
outfile=audio_aac-lc_${abitrate}.mp4
$ffmpeg -i $infile -map_chapters -1 -vn -codec:a libfdk_aac -profile:a aac_low -b:a $abitrate $outdir/$outfile
}
transcode_video "360k" "512:288" "main" 30 $2 $1
transcode_video "620k" "704:396" "main" 30 $2 $1
transcode_video "1340k" "896:504" "high" 31 $2 $1
transcode_video "2500k" "1280:720" "high" 32 $2 $1
transcode_video "4500k" "1920:1080" "high" 40 $2 $1
transcode_audio "128k" $2 $1
transcode_audio "192k" $2 $1
Most helpful comment
Hello @greg80303 the transcoding script you linked to no longer exists. Dead link.