w3c / encrypted-media

Encrypted Media Extensions
https://w3c.github.io/encrypted-media/
Other
180 stars 80 forks source link

Is there any tool to encrypt video with initialization data? #436

Closed lenny0702 closed 6 years ago

lenny0702 commented 6 years ago

First of all, thanks for the great work here! which give us a possible solution for copyright protection.

I'm working in a music streaming service product. We're trying to implement the EME feature in our web player to protect our music copyright.

But the thing is, the document or the tutorial about this is pretty rare. I successfully run a demo which can play a already encrypted webm video. But When I try to encrypt my our video with no matter MP4BOX or mp4encrypt. They all don't work. the "encrypt" event didn't fire at all. The encrypted video is not with initialization data.

As I checked the document of MP4BOX. They just don't support the clear key system. https://github.com/gpac/gpac/issues/239

So all in all, my question is, for now, is there any available tools for us to encrypt video with initialization data, i.e. conforming to the EME spec?

sandersaares commented 6 years ago

EME is an API that enables you to interact with content decryption modules provided by DRM technologies that are implemented in browsers. One such module is the clear key module, which is a sort of "encrypt without any protection" type of non-protection, just for workflow integration and testing purposes. It does not offer any meaningful level of protection, understand.

If you are looking for copyright protection, I recommend you contact a DRM service provider who can work with you to integrate your content with the various DRM technologies supported by different platforms (you will likely need to use a combination of different DRM technologies, depending on the platforms you target; platform in an EME context being browser, not OS).

Murmur commented 6 years ago

See this github project and tools subfolder has a java application (using ffmpeg,mp4box) to multidrm init segments and manifest files. https://github.com/HbbTV-Association/ReferenceApplication

PlayreadyDRM uses Microsoft test server. https://test.playready.microsoft.com/service/rightsmanager.asmx?cfg=(kid:header,sl:2000,persist:false,firstexp:60,contentkey:EjQSNBI0EjQSNBI0EjQSNg==)

ClearkeyDRM can use this PHP script as a test server (as of now hardcoded list of KIDs being processed) https://github.com/HbbTV-Association/ReferenceApplication/blob/master/tools/test/laurl_ck.php

mp4box drm.xml file

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

<!-- Playready -->
<DRMInfo type="pssh" version="0">
  <BS ID128="9A04F07998404286AB92E65BE0885F95"/>
  <BS bits="32" endian="little" value="852"/>
  <BS bits="16" endian="little" value="1"/>
  <BS bits="16" endian="little" value="1"/>
  <BS bits="16" endian="little" value="842"/>
  <BS data64="PABXAFIATQBIAEUAQQBEAEUAUgAgAHgAbQBsAG4AcwA9ACIAaAB0AHQAcAA6AC8ALwBzAGMAaABlAG0AYQBzAC4AbQBpAGMAcgBvAHMAbwBmAHQALgBjAG8AbQAvAEQAUgBNAC8AMgAwADAANwAvADAAMwAvAFAAbABhAHkAUgBlAGEAZAB5AEgAZQBhAGQAZQByACIAIAB2AGUAcgBzAGkAbwBuAD0AIgA0AC4AMAAuADAALgAwACIAPgA8AEQAQQBUAEEAPgA8AFAAUgBPAFQARQBDAFQASQBOAEYATwA+ADwASwBFAFkATABFAE4APgAxADYAPAAvAEsARQBZAEwARQBOAD4APABBAEwARwBJAEQAPgBBAEUAUwBDAFQAUgA8AC8AQQBMAEcASQBEAD4APAAvAFAAUgBPAFQARQBDAFQASQBOAEYATwA+ADwASwBJAEQAPgBlAEYAWQBoAFEAegBRAFMATgBCAEkAUwBOAEIASQAwAEUAagBRAFMATgBnAD0APQA8AC8ASwBJAEQAPgA8AEMASABFAEMASwBTAFUATQA+ACsAOQBrAGkANwAvAHQAdABzAGUAQQA9ADwALwBDAEgARQBDAEsAUwBVAE0APgA8AEwAQQBfAFUAUgBMAD4AaAB0AHQAcABzADoALwAvAHQAZQBzAHQALgBwAGwAYQB5AHIAZQBhAGQAeQAuAG0AaQBjAHIAbwBzAG8AZgB0AC4AYwBvAG0ALwBzAGUAcgB2AGkAYwBlAC8AcgBpAGcAaAB0AHMAbQBhAG4AYQBnAGUAcgAuAGEAcwBtAHgAPwBjAGYAZwA9ACgAawBpAGQAOgBoAGUAYQBkAGUAcgAsAHMAbAA6ADIAMAAwADAALABwAGUAcgBzAGkAcwB0ADoAZgBhAGwAcwBlACwAZgBpAHIAcwB0AGUAeABwADoANgAwACwAYwBvAG4AdABlAG4AdABrAGUAeQA6AEUAagBRAFMATgBCAEkAMABFAGoAUQBTAE4AQgBJADAARQBqAFEAUwBOAGcAPQA9ACkAPAAvAEwAQQBfAFUAUgBMAD4APAAvAEQAQQBUAEEAPgA8AC8AVwBSAE0ASABFAEEARABFAFIAPgA="/>
</DRMInfo>

<!-- Widevine -->
<DRMInfo type="pssh" version="0">
  <BS ID128="EDEF8BA979D64ACEA3C827DCD51D21ED"/>
  <BS data="0x08011210"/>
  <BS ID128="43215678123412341234123412341236"/>
</DRMInfo>

<!-- Marlin -->
<DRMInfo type="pssh" version="0">
  <BS ID128="69f908af481646ea910ccd5dcccb0a3a"/>
  <BS data="0x000000186d61726c000000106d6b69640000000000000000"/>
</DRMInfo>

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

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

</GPACDRM>

MultiDRM manifest (without ClearkeyDRM as browser may not pick it up if other drms signalled)

<?xml version="1.0" encoding="UTF-8"?>
<MPD xmlns="urn:mpeg:dash:schema:mpd:2011" xmlns:cenc="urn:mpeg:cenc:2013" xmlns:mas="urn:marlin:mas:1-0:services:schemas:mpd" xmlns:mspr="urn:microsoft:playready" maxSegmentDuration="PT0H0M8.000S" mediaPresentationDuration="PT0H2M26.048S" minBufferTime="PT3.000S" profiles="urn:mpeg:dash:profile:isoff-live:2011,http://dashif.org/guidelines/dash264,urn:hbbtv:dash:profile:isoff-live:2012" type="static">

 <Period duration="PT0H2M26.048S" id="p0">
  <AdaptationSet lang="eng" maxFrameRate="25" maxHeight="1080" maxWidth="1920" par="16:9" segmentAlignment="true" startWithSAP="1">
   <ContentProtection cenc:default_KID="43215678-1234-1234-1234-123412341236" schemeIdUri="urn:mpeg:dash:mp4protection:2011" value="cenc"/>
<ContentProtection schemeIdUri="urn:uuid:9a04f079-9840-4286-ab92-e65be0885f95">
  <mspr:pro>VAMAAAEAAQBKAzwAVwBSAE0ASABFAEEARABFAFIAIAB4AG0AbABuAHMAPQAiAGgAdAB0AHAAOgAvAC8AcwBjAGgAZQBtAGEAcwAuAG0AaQBjAHIAbwBzAG8AZgB0AC4AYwBvAG0ALwBEAFIATQAvADIAMAAwADcALwAwADMALwBQAGwAYQB5AFIAZQBhAGQAeQBIAGUAYQBkAGUAcgAiACAAdgBlAHIAcwBpAG8AbgA9ACIANAAuADAALgAwAC4AMAAiAD4APABEAEEAVABBAD4APABQAFIATwBUAEUAQwBUAEkATgBGAE8APgA8AEsARQBZAEwARQBOAD4AMQA2ADwALwBLAEUAWQBMAEUATgA+ADwAQQBMAEcASQBEAD4AQQBFAFMAQwBUAFIAPAAvAEEATABHAEkARAA+ADwALwBQAFIATwBUAEUAQwBUAEkATgBGAE8APgA8AEsASQBEAD4AZQBGAFkAaABRAHoAUQBTAE4AQgBJAFMATgBCAEkAMABFAGoAUQBTAE4AZwA9AD0APAAvAEsASQBEAD4APABDAEgARQBDAEsAUwBVAE0APgArADkAawBpADcALwB0AHQAcwBlAEEAPQA8AC8AQwBIAEUAQwBLAFMAVQBNAD4APABMAEEAXwBVAFIATAA+AGgAdAB0AHAAcwA6AC8ALwB0AGUAcwB0AC4AcABsAGEAeQByAGUAYQBkAHkALgBtAGkAYwByAG8AcwBvAGYAdAAuAGMAbwBtAC8AcwBlAHIAdgBpAGMAZQAvAHIAaQBnAGgAdABzAG0AYQBuAGEAZwBlAHIALgBhAHMAbQB4AD8AYwBmAGcAPQAoAGsAaQBkADoAaABlAGEAZABlAHIALABzAGwAOgAyADAAMAAwACwAcABlAHIAcwBpAHMAdAA6AGYAYQBsAHMAZQAsAGYAaQByAHMAdABlAHgAcAA6ADYAMAAsAGMAbwBuAHQAZQBuAHQAawBlAHkAOgBFAGoAUQB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zAGkAcwB0ADoAZgBhAGwAcwBlACwAZgBpAHIAcwB0AGUAeABwADoANgAwACwAYwBvAG4AdABlAG4AdABrAGUAeQA6AEUAagBRAFMATgBCAEkAMABFAGoAUQBTAE4AQgBJADAARQBqAFEAUwBOAGcAPQA9ACkAPAAvAEwAQQBfAFUAUgBMAD4APAAvAEQAQQBUAEEAPgA8AC8AVwBSAE0ASABFAEEARABFAFIAPgA=</cenc:pssh>
</ContentProtection>
<ContentProtection schemeIdUri="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed">
  <cenc:pssh>AAAANHBzc2gAAAAA7e+LqXnWSs6jyCfc1R0h7QAAABQIARIQQyFWeBI0EjQSNBI0EjQSNg==</cenc:pssh>
</ContentProtection>
<ContentProtection schemeIdUri="urn:uuid:5e629af5-38da-4063-8977-97ffbd9902d4">
  <mas:MarlinContentIds>
<mas:MarlinContentId>urn:marlin:kid:43215678123412341234123412341236</mas:MarlinContentId>
</mas:MarlinContentIds>
</ContentProtection>
   <SegmentTemplate initialization="$RepresentationID$_i.mp4" media="$RepresentationID$_$Number$.m4s" startNumber="1" timescale="12800">
    <SegmentTimeline>
     <S d="76800" r="22" t="0"/>
     <S d="102400"/>
    </SegmentTimeline>
   </SegmentTemplate>
   <Representation bandwidth="519875" codecs="avc1.4D4028" frameRate="25" height="360" id="v1" mimeType="video/mp4" sar="1:1" width="640">
   </Representation>
   <Representation bandwidth="1511185" codecs="avc1.4D4028" frameRate="25" height="720" id="v2" mimeType="video/mp4" sar="1:1" width="1280">
   </Representation>
   <Representation bandwidth="2108715" codecs="avc1.4D4028" frameRate="25" height="1080" id="v3" mimeType="video/mp4" sar="1:1" width="1920">
   </Representation>
  </AdaptationSet>
  <AdaptationSet lang="eng" segmentAlignment="true" startWithSAP="1">
   <ContentProtection cenc:default_KID="43215678-1234-1234-1234-123412341236" schemeIdUri="urn:mpeg:dash:mp4protection:2011" value="cenc"/>
<ContentProtection schemeIdUri="urn:uuid:9a04f079-9840-4286-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G4AdABrAGUAeQA6AEUAagBRAFMATgBCAEkAMABFAGoAUQBTAE4AQgBJADAARQBqAFEAUwBOAGcAPQA9ACkAPAAvAEwAQQBfAFUAUgBMAD4APAAvAEQAQQBUAEEAPgA8AC8AVwBSAE0ASABFAEEARABFAFIAPgA=</cenc:pssh>
</ContentProtection>
<ContentProtection schemeIdUri="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed">
  <cenc:pssh>AAAANHBzc2gAAAAA7e+LqXnWSs6jyCfc1R0h7QAAABQIARIQQyFWeBI0EjQSNBI0EjQSNg==</cenc:pssh>
</ContentProtection>
<ContentProtection schemeIdUri="urn:uuid:5e629af5-38da-4063-8977-97ffbd9902d4">
  <mas:MarlinContentIds>
<mas:MarlinContentId>urn:marlin:kid:43215678123412341234123412341236</mas:MarlinContentId>
</mas:MarlinContentIds>
</ContentProtection>
   <SegmentTemplate initialization="$RepresentationID$_i.mp4" media="$RepresentationID$_$Number$.m4s" startNumber="1" timescale="44100">
    <SegmentTimeline>
     <S d="263177" t="0"/>
     <S d="264192" r="22"/>
     <S d="101133"/>
    </SegmentTimeline>
   </SegmentTemplate>
   <Representation audioSamplingRate="44100" bandwidth="133597" codecs="mp4a.40.2" id="a1" mimeType="audio/mp4">
    <AudioChannelConfiguration schemeIdUri="urn:mpeg:dash:23003:3:audio_channel_configuration:2011" value="2"/>
   </Representation>
  </AdaptationSet>
 </Period>
</MPD>

ClearKeyDRM manifest (only drm system signalled)

<?xml version="1.0" encoding="UTF-8"?>
<MPD xmlns="urn:mpeg:dash:schema:mpd:2011" xmlns:cenc="urn:mpeg:cenc:2013" xmlns:mas="urn:marlin:mas:1-0:services:schemas:mpd" xmlns:mspr="urn:microsoft:playready" maxSegmentDuration="PT0H0M8.000S" mediaPresentationDuration="PT0H2M26.048S" minBufferTime="PT3.000S" profiles="urn:mpeg:dash:profile:isoff-live:2011,http://dashif.org/guidelines/dash264,urn:hbbtv:dash:profile:isoff-live:2012" type="static">

 <Period duration="PT0H2M26.048S" id="p0">
  <AdaptationSet lang="eng" maxFrameRate="25" maxHeight="1080" maxWidth="1920" par="16:9" segmentAlignment="true" startWithSAP="1">
   <ContentProtection cenc:default_KID="43215678-1234-1234-1234-123412341236" schemeIdUri="urn:mpeg:dash:mp4protection:2011" value="cenc"/>
<ContentProtection schemeIdUri="urn:uuid:1077efec-c0b2-4d02-ace3-3c1e52e2fb4b">
  <cenc:pssh>AAAANHBzc2gBAAAAEHfv7MCyTQKs4zweUuL7SwAAAAFDIVZ4EjQSNBI0EjQSNBI2AAAAAA==</cenc:pssh>
</ContentProtection>
   <SegmentTemplate initialization="$RepresentationID$_i.mp4" media="$RepresentationID$_$Number$.m4s" startNumber="1" timescale="12800">
    <SegmentTimeline>
     <S d="76800" r="22" t="0"/>
     <S d="102400"/>
    </SegmentTimeline>
   </SegmentTemplate>
   <Representation bandwidth="519875" codecs="avc1.4D4028" frameRate="25" height="360" id="v1" mimeType="video/mp4" sar="1:1" width="640">
   </Representation>
   <Representation bandwidth="1511185" codecs="avc1.4D4028" frameRate="25" height="720" id="v2" mimeType="video/mp4" sar="1:1" width="1280">
   </Representation>
   <Representation bandwidth="2108715" codecs="avc1.4D4028" frameRate="25" height="1080" id="v3" mimeType="video/mp4" sar="1:1" width="1920">
   </Representation>
  </AdaptationSet>
  <AdaptationSet lang="eng" segmentAlignment="true" startWithSAP="1">
   <ContentProtection cenc:default_KID="43215678-1234-1234-1234-123412341236" schemeIdUri="urn:mpeg:dash:mp4protection:2011" value="cenc"/>
<ContentProtection schemeIdUri="urn:uuid:1077efec-c0b2-4d02-ace3-3c1e52e2fb4b">
  <cenc:pssh>AAAANHBzc2gBAAAAEHfv7MCyTQKs4zweUuL7SwAAAAFDIVZ4EjQSNBI0EjQSNBI2AAAAAA==</cenc:pssh>
</ContentProtection>
   <SegmentTemplate initialization="$RepresentationID$_i.mp4" media="$RepresentationID$_$Number$.m4s" startNumber="1" timescale="44100">
    <SegmentTimeline>
     <S d="263177" t="0"/>
     <S d="264192" r="22"/>
     <S d="101133"/>
    </SegmentTimeline>
   </SegmentTemplate>
   <Representation audioSamplingRate="44100" bandwidth="133597" codecs="mp4a.40.2" id="a1" mimeType="audio/mp4">
    <AudioChannelConfiguration schemeIdUri="urn:mpeg:dash:23003:3:audio_channel_configuration:2011" value="2"/>
   </Representation>
  </AdaptationSet>
 </Period>
</MPD>
lenny0702 commented 6 years ago

@sandersaares Thanks for quick reply! Yeah, exactly, we are just in test phase to figure out what we need to implement this EME technology just for browser platform, then decide whether we do the DRM service by ourselves or use third parties. But for now we even can't work the basic clear key demo out. Do you have any successful experince?

@Murmur Thanks for the example in detail. But I'm a little confusing. Should I compile and then use the Reference Video Application directly? Or I just still use the MP4BOX with you drm.xml to encrypt the video? If it's possible, a complete code example or tutorial would be greatly appreciated. Thanks in advance!

sandersaares commented 6 years ago

I do not exactly use clear key myself but I have some test content at https://github.com/axinom/dash-test-vectors that includes clear key support. They are made using a private tool, so not exactly useful as guidance for making content, I suppose, but perhaps for additional reference and comparison.

There is also a "DRM quick start" here that might help explain some of the concepts involved: https://github.com/Axinom/drm-quick-start

I would also note that it is not required for an encrypted video to contain initialization data. The page JavaScript might simply directly provide it via EME, without it ever coming from the content (no "encrypted" event is ever raised). In fact, this is the recommended way to do this with DASH - the initialization data is in the manifest XML, from which a player simply reads it and provides to EME, without anything in the actual media segments. Without knowing your scenario in detail, perhaps you are expecting to see something that is not even supposed to be there?

lenny0702 commented 6 years ago

@sandersaares Thanks so much. Actually what I tried to do is to play a simple encrypted mp4 video without using any adaptive video technology such as dash or hls. So I just tried to encrypt that single mp4 file. And if the encrypted mp4 file is without initialization data. The "encrypt" event won't fire. That's my problem. I'm wondering have you ever encrypted a single mp4 video and played it by using EME successfully? And thanks for the projects you recommend, let me go through them firstly.

sandersaares commented 6 years ago

You do not need the "encrypted" event. You can just start a key session with the initialization data directly.

For clear key, I think all browsers accept the "keyids" JSON format defined in EME, which just lists all the key IDs (albeit in rather uncommon base64url-encoded format that I have never seen used anywhere else).

Murmur commented 6 years ago

See this topic about the dashjs ClearkeyDRM example. https://github.com/Dash-Industry-Forum/dash.js/issues/2249

You don't need to compile ReferenceApplication java app, you may use mp4box and own postprocess script to modify manifest. You can use my example gpacdrm.xml file as a starting point.

MP4Box.exe -crypt gpacdrm.xml temp-v1nodrm.mp4 -out temp-v1.mp4
MP4Box.exe -crypt gpacdrm.xml temp-v2nodrm.mp4 -out temp-v2.mp4
MP4Box.exe -crypt gpacdrm.xml temp-v3nodrm.mp4 -out temp-v3.mp4
MP4Box.exe -crypt gpacdrm.xml temp-a1nodrm.mp4 -out temp-a1.mp4
MP4Box.exe -dash 6000 -frag 6000 -mem-frags -rap -profile dashavc264:live -min-buffer 3000 -mpd-title refapp -mpd-info-url http://refapp -bs-switching no -sample-groups-traf -single-traf -subsegs-per-sidx 1 -segment-name $RepresentationID$_$Number$$Init=i$ -segment-timeline -out manifest.mpd temp-v1.mp4#trackID=1:id=v1:period=p0 temp-v2.mp4#trackID=1:id=v2:period=p0 temp-v3.mp4#trackID=1:id=v3:period=p0 temp-a1.mp4#trackID=1:id=a1:period=p0

Refapp java application does few postprocess init.mp4 file and manifest.mpd modifications to have best possible cross-device dash compatible file encoding.

lenny0702 commented 6 years ago

@Murmur Thanks so much! Your example works great! There are still some minor problems though, but I think I can fix them.

However, the things is, I think I still need to encrypt the video, embed the initialization data, and use EME without using the manifest(dash.js, shaka-plaer). Because we wanna to use it in music streaming service. The audio file is quite small. Using a manifest file is quite wasteful, and also need such shaka-player's third party lib's help.

So do you think it's possible to using some tools to encrypt the video and use the EME directly? just like what is it like in this demo: https://simpl.info/eme/clearkey/

Thanks in advance!

plehegar commented 6 years ago

Marked as invalid since this is not an issue with the specification. Feel free to reopen the issue to continue the conversation.

nallown commented 6 years ago

@lenny0702 Are you looking for a tool to encrypt MP4 files with so that they can be played with EME? I'm trying to find a tool that can encrypt my MP4 files so that they can work with that https://simpl.info/eme/clearkey demo EME player, do you know any tools that can do that?

joeyparrish commented 6 years ago

@nallown:

The encrypting software doesn't have to support clear key for you to play content with the clearkey CDM. You just need to know the keys and supply them to the browser.

nallown commented 6 years ago

@joeyparrish Thank you those encryption software look good, I'm reading the examples right now and they all mention different key formats that I can use for encryption (Raw, Widevine, Marlin, PlayReady, etc...). Do you have any key formats that you recommend and also can you tell me how I can generate those keys?

Murmur commented 6 years ago

@nallown Please see comments https://github.com/w3c/encrypted-media/issues/436#issuecomment-355272109 and https://github.com/w3c/encrypted-media/issues/436#issuecomment-355360007

It has drm.xml for mp4box tool to encrypt your nonprotected mp4 files. This xml example is using a multidrm solution to put Playready(MSEdge, many hbbtv tv), Widevine(Chrome, Firefox, Opera, Android), Marlin(some set-to-boxes, Android with additional software stack) descriptor inside the init.mp4 segments. The actual payload encryption method AES-CTR-128 is always the same so you can use the same v1_n.m4s, v2_n.m4s so on files for all key systems.

Key server Server system holding the kid=encryptionkey lookup database plus doing few other things KID KeyID is a public value used by clients to get a protected/hidden encryption key from the key server Encryption key Hidden value that should not be revealed to anyone, client drm middleware acquires a key from the keyserver using the kid lookup value. This key is used to decrypt a video+audio payload. IV Initialization vector is to give some randomness to an encryption task, it can be seen in drm.xml file. This is not a secret value but you don't need to worry about it much after encryption. Different key system Playready,Widevine,Marlin are a specific kind of key server and client middleware infrastructure. Clients either have this middleware or not, usually you cannot decide what to use its up to the client manufacturer(hardware or software provider).

You can use a single common encryption scheme and it works with all keysystem drm providers. Small difference is how you signal an existence of the said drm system. This signaling is written to Dash manifest.mpd file and/or init.mp4 segment files.

nallown commented 6 years ago

@Murmur how can I generate my own DRM keys? So far it looks like that the comments are using example and test DRM keys which I'm guessing shouldn't be used in production and Google is just getting me no where.

Murmur commented 6 years ago

@nallown Please see this java code to see how randomizeBytes and randomizeKey can be implemented. DRM keys are just an array of fixed length bytes. Test applications may use easy to memorize arrays such as sequencing a last byte 0x01,0x02,..

Production apps may reuse one KID+KEY+IV for all episodes of the Season 1, unique KID+KEY+IV for each episode or anything usecase goes. License servers may bill per used key + license request and so on. Running a commercial movie service usually involves following the guideline of Hollywood content owners of what key system and drm flags be used(=secured hdmi only video output, max resolution for certain device families etc..).

If you follow my comments you should find Playready Microsoft test server and ClearkeyDRM license server script. You may use them free of charge. I don't know access to a free Widevine or Marlin drm key services.