211 lines
9.7 KiB
HTML
211 lines
9.7 KiB
HTML
|
|
<!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>FFmpeg piping — 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="HTTP upload" href="http_upload.html" />
|
|
<link rel="prev" title="Ad Insertion" href="ads.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="http_upload.html" title="HTTP upload"
|
|
accesskey="N">next</a> |</li>
|
|
<li class="right" >
|
|
<a href="ads.html" title="Ad Insertion"
|
|
accesskey="P">previous</a> |</li>
|
|
<li class="nav-item nav-item-0"><a href="../index.html">Shaka Packager documentation</a> »</li>
|
|
<li class="nav-item nav-item-1"><a href="tutorials.html" accesskey="U">Tutorials</a> »</li>
|
|
<li class="nav-item nav-item-this"><a href="">FFmpeg piping</a></li>
|
|
</ul>
|
|
</div>
|
|
|
|
<div class="document">
|
|
<div class="documentwrapper">
|
|
<div class="bodywrapper">
|
|
<div class="body" role="main">
|
|
|
|
<section id="ffmpeg-piping">
|
|
<h1>FFmpeg piping<a class="headerlink" href="#ffmpeg-piping" title="Permalink to this headline">¶</a></h1>
|
|
<p>We can use <em>FFmpeg</em> to redirect / pipe input not supported by <em>packager</em>
|
|
to <em>packager</em>, for example, input from webcam devices, or rtp input. The concept
|
|
depicted here can be applied to other <em>FFmpeg</em> supported device or protocols.</p>
|
|
<section id="piping-data-to-packager">
|
|
<h2>Piping data to packager<a class="headerlink" href="#piping-data-to-packager" title="Permalink to this headline">¶</a></h2>
|
|
<p>There are two options to pipe data to packager.</p>
|
|
<ul>
|
|
<li><p>UDP socket</p>
|
|
<blockquote>
|
|
<div><p><em>FFmpeg</em> supports writing to a UDP socket and <em>packager</em> supports reading
|
|
from UDP sockets (See <a class="reference internal" href="../options/udp_file_options.html"><span class="doc">UDP file options</span></a>):</p>
|
|
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ packager 'input=udp://127.0.0.1:40000,...' ...
|
|
$ ffmpeg ... -f mpegts udp://127.0.0.1:40000
|
|
</pre></div>
|
|
</div>
|
|
<p>VP9 cannot be carried in mpegts. Another container, e.g. webm needs to be
|
|
used when outputs VP9. In this case, transcoding has to be started after
|
|
starting packager as the initialization segment is only transmitted in the
|
|
beginning of WebM output.</p>
|
|
</div></blockquote>
|
|
</li>
|
|
<li><p>pipe</p>
|
|
<blockquote>
|
|
<div><p>Similarily, pipe is also supported in both <em>FFmpeg</em> and <em>packager</em>:</p>
|
|
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ mkfifo pipe1
|
|
$ packager 'input=pipe1,...' ... --io_block_size 65536
|
|
$ ffmpeg ... -f mpegts pipe: > pipe1
|
|
</pre></div>
|
|
</div>
|
|
</div></blockquote>
|
|
</li>
|
|
</ul>
|
|
<div class="admonition note">
|
|
<p class="admonition-title">Note</p>
|
|
<p>Option -io_block_size 65536 tells packager to use an io_block_size of 65K
|
|
for threaded io file. This is necessary when using pipe as reading from pipe
|
|
blocks until the specified number of bytes, which is specified in
|
|
io_block_size for threaded io file, thus the value of io_block_size cannot
|
|
be too large.</p>
|
|
</div>
|
|
</section>
|
|
<section id="encoding-capture-command">
|
|
<h2>Encoding / capture command<a class="headerlink" href="#encoding-capture-command" title="Permalink to this headline">¶</a></h2>
|
|
<section id="camera-capture">
|
|
<h3>Camera capture<a class="headerlink" href="#camera-capture" title="Permalink to this headline">¶</a></h3>
|
|
<p>Refer to <a class="reference external" href="https://trac.ffmpeg.org/wiki/Capture/Webcam">FFmpeg Capture/Webcam</a>
|
|
on how to use <em>FFmpeg</em> to capture webmcam inputs.</p>
|
|
<p>The example assumes Mac OS X 10.7 (Lion) or later. It captures from the default
|
|
audio / video devices on the machine:</p>
|
|
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ ffmpeg -f avfoundation -i "default" -f mpegts udp://127.0.0.1:40000
|
|
</pre></div>
|
|
</div>
|
|
<p>The command starts only after packager starts.</p>
|
|
<div class="admonition note">
|
|
<p class="admonition-title">Note</p>
|
|
<p>After encoding starts, monitor encoding speed carefully. It should always be
|
|
1x and above. If not, adjust the encoding parameters to recude it.</p>
|
|
</div>
|
|
</section>
|
|
<section id="rtp-input">
|
|
<h3>RTP input<a class="headerlink" href="#rtp-input" title="Permalink to this headline">¶</a></h3>
|
|
<p>Assume there is an RTP input described by <cite>saved_sdp_file</cite>:</p>
|
|
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ ffmpeg -protocol_whitelist "file,rtp,udp" -i saved_sdp_file -vcodec h264 \
|
|
-tune zerolatency -f mpegts udp://127.0.0.1:40000
|
|
</pre></div>
|
|
</div>
|
|
<div class="admonition note">
|
|
<p class="admonition-title">Note</p>
|
|
<p>For testing, you can generate an RTP input from a static media file:</p>
|
|
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ ffmpeg -re -stream_loop 100 -i <static.mp4> -vcodec copy -acodec \
|
|
copy -f rtp rtp://239.255.0.1:1234 -sdp_file saved_sdp_file
|
|
</pre></div>
|
|
</div>
|
|
</div>
|
|
<p>The command starts only after packager starts.</p>
|
|
<div class="admonition note">
|
|
<p class="admonition-title">Note</p>
|
|
<p>After encoding starts, monitor encoding speed carefully. It should always be
|
|
1x or above. If not, adjust the encoding parameters to increase it.</p>
|
|
</div>
|
|
</section>
|
|
</section>
|
|
<section id="example-packaging-command-in-dash">
|
|
<h2>Example packaging command in DASH<a class="headerlink" href="#example-packaging-command-in-dash" title="Permalink to this headline">¶</a></h2>
|
|
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ packager \
|
|
'in=udp://127.0.0.1:40000,stream=audio,init_segment=live_cam_audio.mp4,segment_template=live_cam_audio_$Number$.m4s' \
|
|
'in=udp://127.0.0.1:40000,stream=video,init_segment=live_cam_video.mp4,segment_template=live_cam_video_$Number$.m4s' \
|
|
--mpd_output live_cam.mpd
|
|
</pre></div>
|
|
</div>
|
|
</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="#">FFmpeg piping</a><ul>
|
|
<li><a class="reference internal" href="#piping-data-to-packager">Piping data to packager</a></li>
|
|
<li><a class="reference internal" href="#encoding-capture-command">Encoding / capture command</a><ul>
|
|
<li><a class="reference internal" href="#camera-capture">Camera capture</a></li>
|
|
<li><a class="reference internal" href="#rtp-input">RTP input</a></li>
|
|
</ul>
|
|
</li>
|
|
<li><a class="reference internal" href="#example-packaging-command-in-dash">Example packaging command in DASH</a></li>
|
|
</ul>
|
|
</li>
|
|
</ul>
|
|
|
|
<h4>Previous topic</h4>
|
|
<p class="topless"><a href="ads.html"
|
|
title="previous chapter">Ad Insertion</a></p>
|
|
<h4>Next topic</h4>
|
|
<p class="topless"><a href="http_upload.html"
|
|
title="next chapter">HTTP upload</a></p>
|
|
<div role="note" aria-label="source link">
|
|
<h3>This Page</h3>
|
|
<ul class="this-page-menu">
|
|
<li><a href="../_sources/tutorials/ffmpeg_piping.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="http_upload.html" title="HTTP upload"
|
|
>next</a> |</li>
|
|
<li class="right" >
|
|
<a href="ads.html" title="Ad Insertion"
|
|
>previous</a> |</li>
|
|
<li class="nav-item nav-item-0"><a href="../index.html">Shaka Packager documentation</a> »</li>
|
|
<li class="nav-item nav-item-1"><a href="tutorials.html" >Tutorials</a> »</li>
|
|
<li class="nav-item nav-item-this"><a href="">FFmpeg piping</a></li>
|
|
</ul>
|
|
</div>
|
|
<div class="footer" role="contentinfo">
|
|
© Copyright 2017, Google.
|
|
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 4.0.2.
|
|
</div>
|
|
</body>
|
|
</html> |