shaka-packager/html/tutorials/live.html

304 lines
15 KiB
HTML
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />
<title>Live &#8212; Shaka Packager documentation</title>
<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" />
<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="DRM" href="drm.html" />
<link rel="prev" title="HLS" href="hls.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="drm.html" title="DRM"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="hls.html" title="HLS"
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" accesskey="U">Tutorials</a> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Live</a></li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<section id="live">
<h1>Live<a class="headerlink" href="#live" title="Permalink to this headline"></a></h1>
<p>A typical live source is UDP multicast, which is the only live protocol
packager supports directly right now.</p>
<p>For other unsupported protocols, you can use FFmpeg to pipe the input.
See <a class="reference internal" href="ffmpeg_piping.html"><span class="doc">FFmpeg piping</span></a> for details.</p>
<section id="examples">
<h2>Examples<a class="headerlink" href="#examples" title="Permalink to this headline"></a></h2>
<p>The command is similar to the on-demand, see <a class="reference internal" href="dash.html"><span class="doc">DASH</span></a> and <a class="reference internal" href="hls.html"><span class="doc">HLS</span></a>.</p>
<p>Here are some examples.</p>
<ul>
<li><p>DASH:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ packager \
&#39;in=udp://225.1.1.8:8001?interface=172.29.46.122,stream=audio,init_segment=audio_init.mp4,segment_template=audio_$Number$.m4s&#39; \
&#39;in=udp://225.1.1.8:8001?interface=172.29.46.122,stream=video,init_segment=h264_360p_init.mp4,segment_template=h264_360p_$Number$.m4s&#39; \
&#39;in=udp://225.1.1.8:8002?interface=172.29.46.122,stream=video,init_segment=h264_480p_init.mp4,segment_template=h264_480p_$Number$.m4s&#39; \
&#39;in=udp://225.1.1.8:8003?interface=172.29.46.122,stream=video,init_segment=h264_720p_init.mp4,segment_template=h264_720p_$Number$.m4s&#39; \
&#39;in=udp://225.1.1.8:8004?interface=172.29.46.122,stream=video,init_segment=h264_1080p_init.mp4,segment_template=h264_1080p_$Number$.m4s&#39; \
--mpd_output h264.mpd
</pre></div>
</div>
</li>
<li><p>HLS:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ packager \
&#39;in=udp://225.1.1.8:8001?interface=172.29.46.122,stream=audio,init_segment=audio_init.mp4,segment_template=audio_$Number$.m4s,playlist_name=audio.m3u8,hls_group_id=audio,hls_name=ENGLISH&#39; \
&#39;in=udp://225.1.1.8:8001?interface=172.29.46.122,stream=video,init_segment=h264_360p_init.mp4,segment_template=h264_360p_$Number$.m4s,playlist_name=h264_360p.m3u8&#39; \
&#39;in=udp://225.1.1.8:8002?interface=172.29.46.122,stream=video,init_segment=h264_480p_init.mp4,segment_template=h264_480p_$Number$.m4s,playlist_name=h264_480p.m3u8&#39; \
&#39;in=udp://225.1.1.8:8003?interface=172.29.46.122,stream=video,init_segment=h264_720p_init.mp4,segment_template=h264_720p_$Number$.m4s,playlist_name=h264_720p.m3u8&#39; \
&#39;in=udp://225.1.1.8:8004?interface=172.29.46.122,stream=video,init_segment=h264_1080p_init.mp4,segment_template=h264_1080p_$Number$.m4s,playlist_name=h264_1080p.m3u8&#39; \
--hls_master_playlist_output h264_master.m3u8 \
--hls_playlist_type LIVE
</pre></div>
</div>
</li>
</ul>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>Packager supports removing old segments automatically. See
<cite>preserved_segments_outside_live_window</cite> option in
<a class="reference internal" href="../options/dash_options.html"><span class="doc">DASH options</span></a> or <a class="reference internal" href="../options/hls_options.html"><span class="doc">HLS options</span></a> for details.</p>
</div>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>Shaka Packager ensures all segments referenced in DASH manifest / HLS
playlists are available, by updating the manifest / playlists only after a
segment is completed.</p>
<p>However, if content is not served directly from packaging output location,
extra care must be taken outside of packager to avoid updating manifest /
playlists without updating media segments.</p>
<p>Here is an example flow that avoids potential race condition. The following
steps should be done SERIALLY AND IN ORDER in every sync loop when uploading
manifest / playlists and media segments to content server:</p>
<blockquote>
<div><ol class="arabic simple">
<li><p>Upload manifest / playlists under different names</p></li>
<li><p>Upload / Sync media segments</p></li>
<li><p>Rename uploaded manifest / playlists back to the original names</p></li>
</ol>
</div></blockquote>
</div>
</section>
<section id="configuration-options">
<h2>Configuration options<a class="headerlink" href="#configuration-options" title="Permalink to this headline"></a></h2>
<section id="udp-file-options">
<h3>UDP file options<a class="headerlink" href="#udp-file-options" title="Permalink to this headline"></a></h3>
<p>UDP file is of the form:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>udp://&lt;ip&gt;:&lt;port&gt;[?&lt;option&gt;[&amp;&lt;option&gt;]...]
</pre></div>
</div>
<p>Here is the list of supported options:</p>
<dl class="field-list simple">
<dt class="field-odd">buffer_size=&lt;size_in_bytes&gt;</dt>
<dd class="field-odd"><p>UDP maximum receive buffer size in bytes. Note that although it can be set
to any value, the actual value is capped by maximum allowed size defined by
the underlying operating system. On linux, the maximum size allowed can be
retrieved using <cite>sysctl net.core.rmem_max</cite> and configured using
<cite>sysctl -w net.core.rmem_max=&lt;size_in_bytes&gt;</cite>.</p>
</dd>
<dt class="field-even">interface=&lt;addr&gt;</dt>
<dd class="field-even"><p>Multicast group interface address. Only the packets sent to this address are
received. Default to “0.0.0.0” if not specified.</p>
</dd>
<dt class="field-odd">reuse=0|1</dt>
<dd class="field-odd"><p>Allow or disallow reusing UDP sockets.</p>
</dd>
<dt class="field-even">source=&lt;addr&gt;</dt>
<dd class="field-even"><p>Multicast source ip address. Only the packets sent from this source address
are received. Enables Source Specific Multicast (SSM) if set.</p>
</dd>
<dt class="field-odd">timeout=&lt;microseconds&gt;</dt>
<dd class="field-odd"><p>UDP timeout in microseconds.</p>
</dd>
</dl>
<p>Example:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>udp://224.1.2.30:88?interface=10.11.12.13&amp;reuse=1
</pre></div>
</div>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>UDP is by definition unreliable. There could be packets dropped.</p>
<p>UDP packets do not get lost magically. There are things you can do to
minimize the packet loss. A common cause of packet loss is buffer overrun,
either in send buffer or receive buffer.</p>
<p>On Linux, you can check UDP errors by monitoring the output from
<cite>netstat -suna</cite> command.</p>
<p>If there is an increase in <cite>send buffer errors</cite> from the <cite>netstat</cite> output,
then try increasing <cite>buffer_size</cite> in
[FFmpeg](<a class="reference external" href="https://ffmpeg.org/ffmpeg-protocols.html#udp">https://ffmpeg.org/ffmpeg-protocols.html#udp</a>).</p>
<p>If there is an increase in <cite>receive buffer errors</cite>, then try increasing
<cite>buffer_size</cite> in UDP options (See above) or increasing <cite>io_cache_size</cite>.
<cite>buffer_size</cite> in UDP options defines the UDP buffer size of the underlying
system while <cite>io_cache_size</cite> defines the size of the internal circular
buffer managed by <cite>Shaka Packager</cite>.</p>
</div>
</section>
<section id="segment-template-formatting">
<h3>Segment template formatting<a class="headerlink" href="#segment-template-formatting" title="Permalink to this headline"></a></h3>
<p>The implementation is based on <em>Template-based Segment URL construction</em>
described in ISO/IEC 23009-1:2014.</p>
<table class="styled-table docutils align-default" id="id1">
<caption><span class="caption-text">Supported identifiers</span><a class="headerlink" href="#id1" title="Permalink to this table"></a></caption>
<colgroup>
<col style="width: 19%" />
<col style="width: 41%" />
<col style="width: 41%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="left-align head"><p>$&lt;Identifier&gt;$</p></th>
<th class="left-align head"><p>Substitution parameter</p></th>
<th class="left-align head"><p>Format</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td class="left-align"><p>$$</p></td>
<td class="left-align"><p>is an escape sequence, i.e.
“$$” is replaced with a single
“$”.</p></td>
<td class="left-align"><p>Not applicable.</p></td>
</tr>
<tr class="row-odd"><td class="left-align"><p>$Number$</p></td>
<td class="left-align"><p>This identifier is substitued
with the <em>number</em> of the
corresponding Segment.</p></td>
<td class="left-align"><p>The format tag may be present.</p>
<p>If no format tag is present, a
default format tag with
<em>width</em>=1 shall be used.</p>
</td>
</tr>
<tr class="row-even"><td class="left-align"><p>$Time$</p></td>
<td class="left-align"><p>This identifier is substituted
with the value of the
<strong>SegmentTimeline&#64;t</strong>
attribute for the Segment
being accessed. Either
$Number$ or $Time$ may be used
but not both at the same time.</p></td>
<td class="left-align"><p>The format tag may be present.</p>
<p>If no format tag is present, a
default format tag with
<em>width</em>=1 shall be used.</p>
</td>
</tr>
</tbody>
</table>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>Identifiers $RepresentationID$ and $Bandwidth$ are not supported in this
version. Please file an <a class="reference external" href="https://github.com/google/shaka-packager/issues">issue</a> if you want it to be
supported.</p>
</div>
<p>In each URL, the identifiers shall be replaced by the substitution parameter
per the definition in the above table. Identifier matching is case-sensitive.</p>
<p>Each identifier may be suffixed, within the enclosing $ characters, with an
additional format tag aligned with the <em>printf</em> format tag as defined in IEEE
1003.1-2008 following this prototype:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">%</span><span class="mi">0</span><span class="p">[</span><span class="n">width</span><span class="p">]</span><span class="n">d</span>
</pre></div>
</div>
<p>The <em>width</em> parameter is an unsigned integer that provides the minimum number
of characters to be printed. If the value to be printed is shorter than this
number, the result shall be padded with zeros. The value is not truncated even
if the result is larger.</p>
<p>Strings outside identifiers shall only contain characters that are permitted
within URLs according to RFC 3986.</p>
</section>
</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="#">Live</a><ul>
<li><a class="reference internal" href="#examples">Examples</a></li>
<li><a class="reference internal" href="#configuration-options">Configuration options</a><ul>
<li><a class="reference internal" href="#udp-file-options">UDP file options</a></li>
<li><a class="reference internal" href="#segment-template-formatting">Segment template formatting</a></li>
</ul>
</li>
</ul>
</li>
</ul>
<h4>Previous topic</h4>
<p class="topless"><a href="hls.html"
title="previous chapter">HLS</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="drm.html"
title="next chapter">DRM</a></p>
<div role="note" aria-label="source link">
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="../_sources/tutorials/live.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="drm.html" title="DRM"
>next</a> |</li>
<li class="right" >
<a href="hls.html" title="HLS"
>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-this"><a href="">Live</a></li>
</ul>
</div>
<div class="footer" role="contentinfo">
&#169; Copyright 2017, Google.
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 4.0.2.
</div>
</body>
</html>