shaka-packager/html/tutorials/raw_key.html

356 lines
19 KiB
HTML
Raw Normal View History

2018-02-10 23:37:42 +00:00
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
2018-08-16 00:35:22 +00:00
<title>Using Raw Key &#8212; Shaka Packager documentation</title>
<link rel="stylesheet" href="../_static/sphinxdoc_new.css" type="text/css" />
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="../_static/table_styling.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '../',
VERSION: '',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true,
SOURCELINK_SUFFIX: '.txt'
};
</script>
<script type="text/javascript" src="../_static/jquery.js"></script>
<script type="text/javascript" src="../_static/underscore.js"></script>
<script type="text/javascript" src="../_static/doctools.js"></script>
2018-02-10 23:37:42 +00:00
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
<link rel="index" title="Index" href="../genindex.html" />
<link rel="search" title="Search" href="../search.html" />
2018-08-16 00:35:22 +00:00
<link rel="next" title="Using Widevine Key Server" href="widevine.html" />
<link rel="prev" title="DRM" href="drm.html" />
</head>
2018-02-10 23:37:42 +00:00
<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" >
2018-08-16 00:35:22 +00:00
<a href="widevine.html" title="Using Widevine Key Server"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="drm.html" title="DRM"
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>
</ul>
</div>
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<h3><a href="../index.html">Table Of Contents</a></h3>
<ul>
2018-08-16 00:35:22 +00:00
<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>
<li><a class="reference internal" href="#drm-related-stream-descriptor-fields">DRM related Stream descriptor fields</a></li>
2018-02-10 23:37:42 +00:00
<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>
<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>
</li>
</ul>
<h4>Previous topic</h4>
<p class="topless"><a href="drm.html"
title="previous chapter">DRM</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="widevine.html"
2018-08-16 00:35:22 +00:00
title="next chapter">Using Widevine Key Server</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>Quick search</h3>
<form class="search" action="../search.html" method="get">
<div><input type="text" name="q" /></div>
<div><input type="submit" value="Go" /></div>
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
</div>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
2018-08-16 00:35:22 +00:00
<div class="section" id="using-raw-key">
<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>
<div class="section" id="synopsis">
<h2>Synopsis<a class="headerlink" href="#synopsis" title="Permalink to this headline"></a></h2>
2018-05-23 23:12:00 +00:00
<div class="highlight-default"><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>
2018-05-23 23:12:00 +00:00
<div class="highlight-default"><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>
</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>
</div>
<div class="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 class="first">Example with pre-generated PSSH:</p>
<div class="highlight-default"><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 class="first">Common PSSH is generated if no PSSH or protection system flag is specified:</p>
<div class="highlight-default"><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 class="first">Example with FairPlay using cbcs protection scheme:</p>
<div class="highlight-default"><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,label=SD:key_id=abba271e8bcf552bbd2e86a434a9a5d9:key=69eaa802a6763af979e8d1940fb88392,label=HD:key_id=6d76f25cb17f5e16b8eaef6bbf582d8e:key=cb541084c99731aef4fff74500c12ead \
2018-08-16 00:35:22 +00:00
--protection_systems FairPlay \
--iv 11223344556677889900112233445566
--hls_master_playlist_output h264_master.m3u8 \
--hls_key_uri skd://testAssetID
</pre></div>
</div>
</li>
<li><p class="first">Example with multi-drm (Widevine and PlayReady):</p>
<div class="highlight-default"><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 Widevine,PlayReady \
--mpd_output h264.mpd
</pre></div>
</div>
2018-08-16 00:35:22 +00:00
</li>
</ul>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">Users are responsible for setting up the license servers and managing keys
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>
<div class="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>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Key ID:</th><td class="field-body"><div class="first 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>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Key:</th><td class="field-body"><div class="first 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>
</td>
</tr>
2018-08-16 00:35:22 +00:00
<tr class="field-odd field"><th class="field-name">Widevine PSSH:</th><td class="field-body"><p class="first">000000317073736800000000EDEF8BA979D64ACEA3C827DCD51D21ED00000011220F7465737420636F6E74656E74206964</p>
<p>The PSSH 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="last highlight-default"><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>
</td>
</tr>
</tbody>
</table>
</div>
<div class="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>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name" colspan="2">skip_encryption=0|1:</th></tr>
<tr class="field-odd field"><td>&#160;</td><td class="field-body">Optional. Defaults to 0 if not specified. If it is set to 1, no encryption
of the stream will be made.</td>
</tr>
<tr class="field-even field"><th class="field-name">drm_label:</th><td class="field-body">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.</td>
</tr>
</tbody>
</table>
</div>
2018-02-10 23:37:42 +00:00
<div class="section" id="general-encryption-options">
<h3>General encryption options<a class="headerlink" href="#general-encryption-options" title="Permalink to this headline"></a></h3>
<table class="docutils option-list" frame="void" rules="none">
<col class="option" />
<col class="description" />
<tbody valign="top">
<tr><td class="option-group" colspan="2">
<kbd><span class="option">--protection_scheme <var>&lt;scheme&gt;</var></span></kbd></td>
</tr>
<tr><td>&#160;</td><td>Specify a protection scheme, cenc or cbc1 or pattern-based protection
schemes cens or cbcs.</td></tr>
<tr><td class="option-group" colspan="2">
<kbd><span class="option">--vp9_subsample_encryption</span>, <span class="option">--novp9_subsample_encryption</span></kbd></td>
</tr>
<tr><td>&#160;</td><td>Enable / disable VP9 subsample encryption. Enabled by default.</td></tr>
<tr><td class="option-group" colspan="2">
<kbd><span class="option">--clear_lead <var>&lt;seconds&gt;</var></span></kbd></td>
</tr>
<tr><td>&#160;</td><td>Clear lead in seconds if encryption is enabled.</td></tr>
2018-08-16 00:35:22 +00:00
<tr><td class="option-group" colspan="2">
<kbd><span class="option">--protection_systems</span></kbd></td>
</tr>
<tr><td>&#160;</td><td>Protection systems to be generated. Supported protection systems include
Widevine, PlayReady, FairPlay, and CommonSystem (<a class="reference external" href="https://goo.gl/s8RIhr">https://goo.gl/s8RIhr</a>).</td></tr>
2018-02-10 23:37:42 +00:00
</tbody>
</table>
</div>
<div class="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>
<table class="docutils option-list" frame="void" rules="none">
<col class="option" />
<col class="description" />
<tbody valign="top">
<tr><td class="option-group" colspan="2">
<kbd><span class="option">--enable_raw_key_encryption</span></kbd></td>
</tr>
2018-08-16 00:35:22 +00:00
<tr><td>&#160;</td><td>Enable encryption with raw key (keys provided in command line)). This
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.</td></tr>
<tr><td class="option-group" colspan="2">
<kbd><span class="option">--enable_raw_key_decryption</span></kbd></td>
</tr>
<tr><td>&#160;</td><td>Enable decryption with raw key (keys provided in command line).</td></tr>
<tr><td class="option-group" colspan="2">
2018-02-10 23:37:42 +00:00
<kbd><span class="option">--keys <var>&lt;key_info_string[,key_info_string][,key_info_string]…&gt;</var></span></kbd></td>
</tr>
<tr><td>&#160;</td><td><p class="first"><strong>key_info_string</strong> is of the form:</p>
2018-05-23 23:12:00 +00:00
<div class="highlight-default"><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>
</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 class="last"><em>key_id</em> and <em>key</em> should be 32-digit hex strings.</p>
</td></tr>
<tr><td class="option-group" colspan="2">
<kbd><span class="option">--iv <var>&lt;16-digit or 32-digit hex string&gt;</var></span></kbd></td>
</tr>
<tr><td>&#160;</td><td>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).</td></tr>
<tr><td class="option-group" colspan="2">
<kbd><span class="option">--pssh <var>&lt;hex string&gt;</var></span></kbd></td>
</tr>
2018-08-16 00:35:22 +00:00
<tr><td>&#160;</td><td>One or more concatenated PSSH boxes in hex string format. If neither this
flag nor protection_systems is specified, a
<a class="reference external" href="https://goo.gl/s8RIhr">v1 common PSSH box</a> will be generated.</td></tr>
</tbody>
</table>
</div>
<div class="section" id="pssh-box-utility-to-generate-pssh-boxes">
<h3>pssh-box (Utility to generate PSSH boxes)<a class="headerlink" href="#pssh-box-utility-to-generate-pssh-boxes" title="Permalink to this headline"></a></h3>
<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>
</div>
</div>
</div>
</div>
</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" >
2018-08-16 00:35:22 +00:00
<a href="widevine.html" title="Using Widevine Key Server"
>next</a> |</li>
<li class="right" >
<a href="drm.html" title="DRM"
>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>
</ul>
</div>
<div class="footer" role="contentinfo">
&#169; Copyright 2017, Google.
2018-02-10 23:37:42 +00:00
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.6.7.
</div>
</body>
</html>