shaka-packager/html/tutorials/raw_key.html

371 lines
21 KiB
HTML
Raw Normal View History

2018-02-10 23:37:42 +00:00
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
2021-06-22 00:16:40 +00:00
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />
2018-08-16 00:35:22 +00:00
<title>Using Raw Key &#8212; Shaka Packager documentation</title>
2021-06-22 00:16:40 +00:00
<link rel="stylesheet" type="text/css" href="../_static/pygments.css" />
<link rel="stylesheet" type="text/css" href="../_static/sphinxdoc_new.css" />
<link rel="stylesheet" type="text/css" href="../_static/graphviz.css" />
<link rel="stylesheet" type="text/css" href="../_static/table_styling.css" />
2021-06-22 00:16:40 +00:00
<script data-url_root="../" id="documentation_options" src="../_static/documentation_options.js"></script>
<script src="../_static/jquery.js"></script>
<script src="../_static/underscore.js"></script>
<script src="../_static/doctools.js"></script>
<link rel="index" title="Index" href="../genindex.html" />
<link rel="search" title="Search" href="../search.html" />
<link rel="next" title="Text output formats" href="text.html" />
<link rel="prev" title="Using PlayReady Key Server" href="playready.html" />
</head><body>
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="text.html" title="Text output formats"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="playready.html" title="Using PlayReady Key Server"
accesskey="P">previous</a> |</li>
<li class="nav-item nav-item-0"><a href="../index.html">Shaka Packager documentation</a> &#187;</li>
<li class="nav-item nav-item-1"><a href="tutorials.html" >Tutorials</a> &#187;</li>
<li class="nav-item nav-item-2"><a href="drm.html" accesskey="U">DRM</a> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Using Raw Key</a></li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
2021-06-22 00:16:40 +00:00
<section id="using-raw-key">
2018-08-16 00:35:22 +00:00
<h1>Using Raw Key<a class="headerlink" href="#using-raw-key" title="Permalink to this headline"></a></h1>
<p>Shaka Packager supports raw keys, for which keys and key_ids are provided to
Shaka Packager directly.</p>
<p>This is often used if you are managing the encryption keys yourself. It also
allows you to support multi-DRM by providing custom PSSHs.</p>
2021-06-22 00:16:40 +00:00
<section id="synopsis">
<h2>Synopsis<a class="headerlink" href="#synopsis" title="Permalink to this headline"></a></h2>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ packager &lt;stream_descriptor&gt; ... \
--enable_raw_key_encryption \
2018-05-23 23:12:00 +00:00
--keys &lt;key_info_string&gt;[,&lt;key_info_string&gt;]... \
[--pssh &lt;concatenated_PSSHs&gt;] \
[Other options, e.g. DASH options, HLS options]
</pre></div>
</div>
<p><strong>key_info_string</strong> is of the form:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">label</span><span class="o">=&lt;</span><span class="n">label</span><span class="o">&gt;</span><span class="p">:</span><span class="n">key_id</span><span class="o">=&lt;</span><span class="n">key_id</span><span class="o">&gt;</span><span class="p">:</span><span class="n">key</span><span class="o">=&lt;</span><span class="n">key</span><span class="o">&gt;</span><span class="p">[:</span><span class="n">iv</span><span class="o">=&lt;</span><span class="n">initialization_vector</span><span class="o">&gt;</span><span class="p">]</span>
</pre></div>
</div>
2018-08-16 00:35:22 +00:00
<p>Custom PSSH(s) can be provided in <em>pssh</em>. If neither pssh nor
protection_systems is specified, <a class="reference external" href="https://goo.gl/s8RIhr">v1 common PSSH box</a>
is generated.</p>
2021-06-22 00:16:40 +00:00
</section>
<section id="examples">
<h2>Examples<a class="headerlink" href="#examples" title="Permalink to this headline"></a></h2>
2018-08-16 00:35:22 +00:00
<p>The examples below use the H264 streams created in <a class="reference internal" href="encoding.html"><span class="doc">Media Encoding</span></a>.</p>
<ul>
<li><p>Example with pre-generated PSSH:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ packager \
2018-08-16 00:35:22 +00:00
in=h264_baseline_360p_600.mp4,stream=audio,output=audio.mp4,drm_label=AUDIO \
in=h264_baseline_360p_600.mp4,stream=video,output=h264_360p.mp4,drm_label=SD \
in=h264_main_480p_1000.mp4,stream=video,output=h264_480p.mp4,drm_label=SD \
in=h264_main_720p_3000.mp4,stream=video,output=h264_720p.mp4,drm_label=HD \
in=h264_high_1080p_6000.mp4,stream=video,output=h264_1080p.mp4,drm_label=HD \
--enable_raw_key_encryption \
2018-08-16 00:35:22 +00:00
--keys label=AUDIO:key_id=f3c5e0361e6654b28f8049c778b23946:key=a4631a153a443df9eed0593043db7519,label=SD:key_id=abba271e8bcf552bbd2e86a434a9a5d9:key=69eaa802a6763af979e8d1940fb88392,label=HD:key_id=6d76f25cb17f5e16b8eaef6bbf582d8e:key=cb541084c99731aef4fff74500c12ead \
--pssh 000000317073736800000000EDEF8BA979D64ACEA3C827DCD51D21ED00000011220F7465737420636F6E74656E74206964 \
--mpd_output h264.mpd \
--hls_master_playlist_output h264_master.m3u8
</pre></div>
</div>
2018-08-16 00:35:22 +00:00
</li>
<li><p>Common PSSH is generated if no PSSH or protection system flag is specified:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ packager \
in=h264_baseline_360p_600.mp4,stream=audio,output=audio.mp4,drm_label=AUDIO \
in=h264_baseline_360p_600.mp4,stream=video,output=h264_360p.mp4,drm_label=SD \
in=h264_main_480p_1000.mp4,stream=video,output=h264_480p.mp4,drm_label=SD \
in=h264_main_720p_3000.mp4,stream=video,output=h264_720p.mp4,drm_label=HD \
in=h264_high_1080p_6000.mp4,stream=video,output=h264_1080p.mp4,drm_label=HD \
--enable_raw_key_encryption \
--keys label=AUDIO:key_id=f3c5e0361e6654b28f8049c778b23946:key=a4631a153a443df9eed0593043db7519,label=SD:key_id=abba271e8bcf552bbd2e86a434a9a5d9:key=69eaa802a6763af979e8d1940fb88392,label=HD:key_id=6d76f25cb17f5e16b8eaef6bbf582d8e:key=cb541084c99731aef4fff74500c12ead \
--mpd_output h264.mpd
</pre></div>
</div>
2018-08-16 00:35:22 +00:00
</li>
<li><p>Example with FairPlay using cbcs protection scheme:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ packager \
in=h264_baseline_360p_600.mp4,stream=audio,output=audio.mp4,drm_label=AUDIO \
in=h264_baseline_360p_600.mp4,stream=video,output=h264_360p.mp4,drm_label=SD \
in=h264_main_480p_1000.mp4,stream=video,output=h264_480p.mp4,drm_label=SD \
in=h264_main_720p_3000.mp4,stream=video,output=h264_720p.mp4,drm_label=HD \
in=h264_high_1080p_6000.mp4,stream=video,output=h264_1080p.mp4,drm_label=HD \
2018-08-16 00:35:22 +00:00
--protection_scheme cbcs \
--enable_raw_key_encryption \
--keys label=AUDIO:key_id=f3c5e0361e6654b28f8049c778b23946:key=a4631a153a443df9eed0593043db7519:iv=11223344556677889900112233445566,label=SD:key_id=abba271e8bcf552bbd2e86a434a9a5d9:key=69eaa802a6763af979e8d1940fb88392:iv=22334455667788990011223344556677,label=HD:key_id=6d76f25cb17f5e16b8eaef6bbf582d8e:key=cb541084c99731aef4fff74500c12ead:iv=33445566778899001122334455667788 \
2018-08-16 00:35:22 +00:00
--protection_systems FairPlay \
--hls_master_playlist_output h264_master.m3u8 \
--hls_key_uri skd://testAssetID
</pre></div>
</div>
</li>
<li><p>Example with multi-drm (Widevine and PlayReady):</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ packager \
2018-08-16 00:35:22 +00:00
in=h264_baseline_360p_600.mp4,stream=audio,output=audio.mp4,drm_label=AUDIO \
in=h264_baseline_360p_600.mp4,stream=video,output=h264_360p.mp4,drm_label=SD \
in=h264_main_480p_1000.mp4,stream=video,output=h264_480p.mp4,drm_label=SD \
in=h264_main_720p_3000.mp4,stream=video,output=h264_720p.mp4,drm_label=HD \
in=h264_high_1080p_6000.mp4,stream=video,output=h264_1080p.mp4,drm_label=HD \
--enable_raw_key_encryption \
--keys label=AUDIO:key_id=f3c5e0361e6654b28f8049c778b23946:key=a4631a153a443df9eed0593043db7519,label=SD:key_id=abba271e8bcf552bbd2e86a434a9a5d9:key=69eaa802a6763af979e8d1940fb88392,label=HD:key_id=6d76f25cb17f5e16b8eaef6bbf582d8e:key=cb541084c99731aef4fff74500c12ead \
--protection_systems Widevine,PlayReady \
--mpd_output h264.mpd
</pre></div>
</div>
2018-08-16 00:35:22 +00:00
</li>
<li><p>Example with LAURL:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ packager \
in=h264_baseline_360p_600.mp4,stream=audio,output=audio.mp4,drm_label=AUDIO \
in=h264_baseline_360p_600.mp4,stream=video,output=h264_360p.mp4,drm_label=SD \
in=h264_main_480p_1000.mp4,stream=video,output=h264_480p.mp4,drm_label=SD \
in=h264_main_720p_3000.mp4,stream=video,output=h264_720p.mp4,drm_label=HD \
in=h264_high_1080p_6000.mp4,stream=video,output=h264_1080p.mp4,drm_label=HD \
--enable_raw_key_encryption \
--keys label=AUDIO:key_id=f3c5e0361e6654b28f8049c778b23946:key=a4631a153a443df9eed0593043db7519,label=SD:key_id=abba271e8bcf552bbd2e86a434a9a5d9:key=69eaa802a6763af979e8d1940fb88392,label=HD:key_id=6d76f25cb17f5e16b8eaef6bbf582d8e:key=cb541084c99731aef4fff74500c12ead \
--protection_systems PlayReady \
--playready_extra_header_data &#39;&lt;LAURL&gt;https://example.com/pr&lt;/LAURL&gt;&#39; \
--mpd_output h264.mpd
</pre></div>
</div>
</li>
2018-08-16 00:35:22 +00:00
</ul>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>Users are responsible for setting up the license servers and managing keys
2018-08-16 00:35:22 +00:00
there unless they are using a cloud service provided by the DRM provider or
third_parties.</p>
</div>
<p>Refer to
<a class="reference external" href="https://shaka-player-demo.appspot.com/docs/api/tutorial-drm-config.html">player setup</a>
on how to config the DRM in Shaka Player.</p>
2021-06-22 00:16:40 +00:00
<section id="test-vectors-used-in-this-tutorial">
<h3>Test vectors used in this tutorial<a class="headerlink" href="#test-vectors-used-in-this-tutorial" title="Permalink to this headline"></a></h3>
<dl class="field-list">
<dt class="field-odd">Key ID</dt>
<dd class="field-odd"><div class="line-block">
<div class="line">SD: abba271e8bcf552bbd2e86a434a9a5d9</div>
<div class="line">HD: 6d76f25cb17f5e16b8eaef6bbf582d8e</div>
<div class="line">AUDIO: f3c5e0361e6654b28f8049c778b23946</div>
</div>
<p>Key ID must be 16 bytes or 32 digits in HEX.</p>
</dd>
<dt class="field-even">Key</dt>
<dd class="field-even"><div class="line-block">
<div class="line">SD: 69eaa802a6763af979e8d1940fb88392</div>
<div class="line">HD: cb541084c99731aef4fff74500c12ead</div>
<div class="line">AUDIO: a4631a153a443df9eed0593043db7519</div>
</div>
<p>Key must be 16 bytes or 32 digits in HEX.</p>
</dd>
<dt class="field-odd">Widevine PSSH</dt>
<dd class="field-odd"><p>The PSSH 00000031707373… is generated using
<a class="reference external" href="https://github.com/google/shaka-packager/tree/master/packager/tools/pssh">pssh-box script</a>:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ pssh-box.py --widevine-system-id \
2018-08-16 00:35:22 +00:00
--content-id 7465737420636f6e74656e74206964 --hex
</pre></div>
</div>
</dd>
</dl>
2021-06-22 00:16:40 +00:00
</section>
</section>
<section id="configuration-options">
<h2>Configuration options<a class="headerlink" href="#configuration-options" title="Permalink to this headline"></a></h2>
2021-06-22 00:16:40 +00:00
<section id="drm-related-stream-descriptor-fields">
<h3>DRM related Stream descriptor fields<a class="headerlink" href="#drm-related-stream-descriptor-fields" title="Permalink to this headline"></a></h3>
<dl class="field-list simple">
<dt class="field-odd">skip_encryption=0|1</dt>
<dd class="field-odd"><p>Optional. Defaults to 0 if not specified. If it is set to 1, no encryption
of the stream will be made.</p>
</dd>
<dt class="field-even">drm_label</dt>
<dd class="field-even"><p>Optional value for custom DRM label, which defines the encryption key
applied to the stream. Typically values include AUDIO, SD, HD, UHD1, UHD2.
2018-02-10 23:37:42 +00:00
For raw key, it should be a label defined in keys. If not provided, the
DRM label is derived from stream type (video, audio), resolutions, etc.
Note that it is case sensitive.</p>
</dd>
</dl>
2021-06-22 00:16:40 +00:00
</section>
<section id="general-encryption-options">
2018-02-10 23:37:42 +00:00
<h3>General encryption options<a class="headerlink" href="#general-encryption-options" title="Permalink to this headline"></a></h3>
<dl class="option-list">
<dt><kbd><span class="option">--protection_scheme <var>&lt;scheme&gt;</var></span></kbd></dt>
<dd><p>Specify a protection scheme, cenc or cbc1 or pattern-based protection
schemes cens or cbcs.</p>
</dd>
<dt><kbd><span class="option">--crypt_byte_block</span></kbd></dt>
<dd><p>Specify the count of the encrypted blocks in the protection pattern, where
block is of size 16-bytes.</p>
<p>There are three common patterns (crypt_byte_block:skip_byte_block):
1:9 (default), 5:5, 10:0.</p>
<p>Apply to video streams with cbcs and cens protection schemes only;
ignored otherwise.</p>
</dd>
<dt><kbd><span class="option">--skip_byte_block</span></kbd></dt>
<dd><p>Specify the count of the unencrypted blocks in the protection pattern.</p>
<p>Apply to video streams with cbcs and cens protection schemes only;
ignored otherwise.</p>
</dd>
<dt><kbd><span class="option">--vp9_subsample_encryption</span>, <span class="option">--novp9_subsample_encryption</span></kbd></dt>
<dd><p>Enable / disable VP9 subsample encryption. Enabled by default.</p>
</dd>
<dt><kbd><span class="option">--clear_lead <var>&lt;seconds&gt;</var></span></kbd></dt>
<dd><p>Clear lead in seconds if encryption is enabled.
Shaka Packager does not support partial encrypted segments, all the
segments including the partial segment overlapping with the initial
clear_lead seconds are not encrypted, with all the following segments
encrypted. If segment_duration is greater than clear_lead, then only the
first segment is not encrypted.
Default: 5</p>
</dd>
<dt><kbd><span class="option">--protection_systems</span></kbd></dt>
<dd><p>Protection systems to be generated. Supported protection systems include
Widevine, PlayReady, FairPlay, Marlin, and
<a class="reference external" href="https://goo.gl/s8RIhr">CommonSystem</a>.</p>
</dd>
<dt><kbd><span class="option">--playready_extra_header_data <var>&lt;string&gt;</var></span></kbd></dt>
<dd><p>Extra XML data to add to PlayReady PSSH data. Can be specified even if
using another key source.</p>
</dd>
</dl>
2021-06-22 00:16:40 +00:00
</section>
<section id="raw-key-encryption-options">
<h3>Raw key encryption options<a class="headerlink" href="#raw-key-encryption-options" title="Permalink to this headline"></a></h3>
<dl class="option-list">
<dt><kbd><span class="option">--enable_raw_key_encryption</span></kbd></dt>
<dd><p>Enable encryption with raw key (keys provided in command line)). This
2018-08-16 00:35:22 +00:00
generates <a class="reference external" href="https://goo.gl/s8RIhr">Common protection system</a> if neither
pssh nor protection_systems is specified. Use pssh to provide custom
protection systems or use protection_systems to generate protection
systems automatically.</p>
</dd>
<dt><kbd><span class="option">--enable_raw_key_decryption</span></kbd></dt>
<dd><p>Enable decryption with raw key (keys provided in command line).</p>
</dd>
<dt><kbd><span class="option">--keys <var>&lt;key_info_string[,key_info_string][,key_info_string]…&gt;</var></span></kbd></dt>
<dd><p><strong>key_info_string</strong> is of the form:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">label</span><span class="o">=&lt;</span><span class="n">label</span><span class="o">&gt;</span><span class="p">:</span><span class="n">key_id</span><span class="o">=&lt;</span><span class="n">key_id</span><span class="o">&gt;</span><span class="p">:</span><span class="n">key</span><span class="o">=&lt;</span><span class="n">key</span><span class="o">&gt;</span><span class="p">[:</span><span class="n">iv</span><span class="o">=&lt;</span><span class="n">initialization_vector</span><span class="o">&gt;</span><span class="p">]</span>
</pre></div>
</div>
<p><em>label</em> can be an arbitrary string or a predefined DRM label like AUDIO,
SD, HD, etc. Label with an empty string indicates the default key and
key_id. The <em>drm_label</em> in <a class="reference internal" href="../options/stream_descriptors.html"><span class="doc">Stream descriptors</span></a>,
which can be implicit, determines which key info is applied to the stream
by matching the <em>drm_label</em> with the <em>label</em> in key info.</p>
<p><em>key_id</em> and <em>key</em> should be 32-digit hex strings.</p>
<p><em>initialization_vector</em> is an optional IV with the same format and semantics
as the parameter for the <em>iv</em> option below. This is mutually exclusive with
that option.</p>
</dd>
<dt><kbd><span class="option">--iv <var>&lt;16-digit or 32-digit hex string&gt;</var></span></kbd></dt>
<dd><p>IV in hex string format. If not specified, a random IV will be generated.
This flag should only be used for testing. IV must be either 8 bytes
(16 digits HEX) or 16 bytes (32 digits in HEX).</p>
</dd>
<dt><kbd><span class="option">--pssh <var>&lt;hex string&gt;</var></span></kbd></dt>
<dd><p>One or more concatenated PSSH boxes in hex string format. If neither this
2018-08-16 00:35:22 +00:00
flag nor protection_systems is specified, a
<a class="reference external" href="https://goo.gl/s8RIhr">v1 common PSSH box</a> will be generated.</p>
</dd>
</dl>
2021-06-22 00:16:40 +00:00
</section>
</section>
<section id="pssh-box-utility-to-generate-pssh-boxes">
<h2>pssh-box (Utility to generate PSSH boxes)<a class="headerlink" href="#pssh-box-utility-to-generate-pssh-boxes" title="Permalink to this headline"></a></h2>
<p><a class="reference external" href="https://github.com/google/shaka-packager/tree/master/packager/tools/pssh">https://github.com/google/shaka-packager/tree/master/packager/tools/pssh</a></p>
2021-06-22 00:16:40 +00:00
</section>
</section>
<div class="clearer"></div>
</div>
</div>
</div>
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<h3><a href="../index.html">Table of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#">Using Raw Key</a><ul>
<li><a class="reference internal" href="#synopsis">Synopsis</a></li>
<li><a class="reference internal" href="#examples">Examples</a><ul>
<li><a class="reference internal" href="#test-vectors-used-in-this-tutorial">Test vectors used in this tutorial</a></li>
</ul>
</li>
<li><a class="reference internal" href="#configuration-options">Configuration options</a><ul>
<li><a class="reference internal" href="#drm-related-stream-descriptor-fields">DRM related Stream descriptor fields</a></li>
<li><a class="reference internal" href="#general-encryption-options">General encryption options</a></li>
<li><a class="reference internal" href="#raw-key-encryption-options">Raw key encryption options</a></li>
</ul>
</li>
<li><a class="reference internal" href="#pssh-box-utility-to-generate-pssh-boxes">pssh-box (Utility to generate PSSH boxes)</a></li>
</ul>
</li>
</ul>
<h4>Previous topic</h4>
<p class="topless"><a href="playready.html"
title="previous chapter">Using PlayReady Key Server</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="text.html"
title="next chapter">Text output formats</a></p>
<div role="note" aria-label="source link">
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="../_sources/tutorials/raw_key.rst.txt"
rel="nofollow">Show Source</a></li>
</ul>
</div>
<div id="searchbox" style="display: none" role="search">
<h3 id="searchlabel">Quick search</h3>
<div class="searchformwrapper">
<form class="search" action="../search.html" method="get">
<input type="text" name="q" aria-labelledby="searchlabel" />
<input type="submit" value="Go" />
</form>
</div>
</div>
<script>$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="text.html" title="Text output formats"
>next</a> |</li>
<li class="right" >
<a href="playready.html" title="Using PlayReady Key Server"
>previous</a> |</li>
<li class="nav-item nav-item-0"><a href="../index.html">Shaka Packager documentation</a> &#187;</li>
<li class="nav-item nav-item-1"><a href="tutorials.html" >Tutorials</a> &#187;</li>
<li class="nav-item nav-item-2"><a href="drm.html" >DRM</a> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Using Raw Key</a></li>
</ul>
</div>
<div class="footer" role="contentinfo">
&#169; Copyright 2017, Google.
2021-06-22 00:16:40 +00:00
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 4.0.2.
</div>
</body>
</html>