2018-02-10 23:37:42 +00:00
|
|
|
|
2020-01-22 00:59:16 +00:00
|
|
|
<!DOCTYPE html>
|
2017-09-20 02:35:05 +00:00
|
|
|
|
2021-04-10 04:00:37 +00:00
|
|
|
<html>
|
2017-09-20 02:35:05 +00:00
|
|
|
<head>
|
2020-01-22 00:59:16 +00:00
|
|
|
<meta charset="utf-8" />
|
2021-04-10 04:00:37 +00:00
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
2017-10-24 22:51:02 +00:00
|
|
|
<title>FFmpeg piping — Shaka Packager documentation</title>
|
2017-09-20 02:35:05 +00:00
|
|
|
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
|
2021-04-10 04:00:37 +00:00
|
|
|
<link rel="stylesheet" href="../_static/sphinxdoc_new.css" type="text/css" />
|
2020-01-22 00:59:16 +00:00
|
|
|
<link rel="stylesheet" type="text/css" href="../_static/graphviz.css" />
|
|
|
|
<link rel="stylesheet" type="text/css" href="../_static/table_styling.css" />
|
2021-04-10 04:00:37 +00:00
|
|
|
<script id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
|
|
|
|
<script src="../_static/jquery.js"></script>
|
|
|
|
<script src="../_static/underscore.js"></script>
|
|
|
|
<script src="../_static/doctools.js"></script>
|
2017-09-20 02:35:05 +00:00
|
|
|
<link rel="index" title="Index" href="../genindex.html" />
|
|
|
|
<link rel="search" title="Search" href="../search.html" />
|
2021-04-10 04:00:37 +00:00
|
|
|
<link rel="next" title="HTTP upload" href="http_upload.html" />
|
2018-08-20 17:47:59 +00:00
|
|
|
<link rel="prev" title="Ad Insertion" href="ads.html" />
|
2020-01-22 00:59:16 +00:00
|
|
|
</head><body>
|
2017-09-20 02:35:05 +00:00
|
|
|
<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" >
|
2021-04-10 04:00:37 +00:00
|
|
|
<a href="http_upload.html" title="HTTP upload"
|
2017-10-24 22:51:02 +00:00
|
|
|
accesskey="N">next</a> |</li>
|
|
|
|
<li class="right" >
|
2018-08-20 17:47:59 +00:00
|
|
|
<a href="ads.html" title="Ad Insertion"
|
2017-09-20 02:35:05 +00:00
|
|
|
accesskey="P">previous</a> |</li>
|
2017-10-24 22:51:02 +00:00
|
|
|
<li class="nav-item nav-item-0"><a href="../index.html">Shaka Packager documentation</a> »</li>
|
2021-04-10 04:00:37 +00:00
|
|
|
<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>
|
2017-09-20 02:35:05 +00:00
|
|
|
</ul>
|
2021-04-10 04:00:37 +00:00
|
|
|
</div>
|
2017-09-20 02:35:05 +00:00
|
|
|
|
|
|
|
<div class="document">
|
|
|
|
<div class="documentwrapper">
|
|
|
|
<div class="bodywrapper">
|
|
|
|
<div class="body" role="main">
|
|
|
|
|
|
|
|
<div class="section" id="ffmpeg-piping">
|
2017-10-24 22:51:02 +00:00
|
|
|
<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>
|
|
|
|
<div class="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>
|
2020-01-22 00:59:16 +00:00
|
|
|
<li><p>UDP socket</p>
|
2017-10-24 22:51:02 +00:00
|
|
|
<blockquote>
|
|
|
|
<div><p><em>FFmpeg</em> supports writing to a UDP socket and <em>packager</em> supports reading
|
2018-06-29 00:34:00 +00:00
|
|
|
from UDP sockets (See <a class="reference internal" href="../options/udp_file_options.html"><span class="doc">UDP file options</span></a>):</p>
|
2020-01-22 00:59:16 +00:00
|
|
|
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ packager 'input=udp://127.0.0.1:40000,...' ...
|
2017-10-24 22:51:02 +00:00
|
|
|
$ 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>
|
2020-01-22 00:59:16 +00:00
|
|
|
<li><p>pipe</p>
|
2017-10-24 22:51:02 +00:00
|
|
|
<blockquote>
|
|
|
|
<div><p>Similarily, pipe is also supported in both <em>FFmpeg</em> and <em>packager</em>:</p>
|
2020-01-22 00:59:16 +00:00
|
|
|
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ mkfifo pipe1
|
2017-10-24 22:51:02 +00:00
|
|
|
$ packager 'input=pipe1,...' ... --io_block_size 65536
|
|
|
|
$ ffmpeg ... -f mpegts pipe: > pipe1
|
2017-09-20 02:35:05 +00:00
|
|
|
</pre></div>
|
|
|
|
</div>
|
2017-10-24 22:51:02 +00:00
|
|
|
</div></blockquote>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
<div class="admonition note">
|
2020-01-22 00:59:16 +00:00
|
|
|
<p class="admonition-title">Note</p>
|
|
|
|
<p>Option -io_block_size 65536 tells packager to use an io_block_size of 65K
|
2017-10-24 22:51:02 +00:00
|
|
|
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>
|
2017-09-20 02:35:05 +00:00
|
|
|
</div>
|
|
|
|
<div class="section" id="encoding-capture-command">
|
|
|
|
<h2>Encoding / capture command<a class="headerlink" href="#encoding-capture-command" title="Permalink to this headline">¶</a></h2>
|
2017-10-24 22:51:02 +00:00
|
|
|
<div class="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>
|
2020-01-22 00:59:16 +00:00
|
|
|
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ ffmpeg -f avfoundation -i "default" -f mpegts udp://127.0.0.1:40000
|
2017-09-20 02:35:05 +00:00
|
|
|
</pre></div>
|
|
|
|
</div>
|
|
|
|
<p>The command starts only after packager starts.</p>
|
|
|
|
<div class="admonition note">
|
2020-01-22 00:59:16 +00:00
|
|
|
<p class="admonition-title">Note</p>
|
|
|
|
<p>After encoding starts, monitor encoding speed carefully. It should always be
|
2017-09-20 02:35:05 +00:00
|
|
|
1x and above. If not, adjust the encoding parameters to recude it.</p>
|
|
|
|
</div>
|
|
|
|
</div>
|
2017-10-24 22:51:02 +00:00
|
|
|
<div class="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>
|
2020-01-22 00:59:16 +00:00
|
|
|
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ ffmpeg -protocol_whitelist "file,rtp,udp" -i saved_sdp_file -vcodec h264 \
|
2017-10-24 22:51:02 +00:00
|
|
|
-tune zerolatency -f mpegts udp://127.0.0.1:40000
|
2017-09-20 02:35:05 +00:00
|
|
|
</pre></div>
|
|
|
|
</div>
|
|
|
|
<div class="admonition note">
|
2020-01-22 00:59:16 +00:00
|
|
|
<p class="admonition-title">Note</p>
|
2017-10-24 22:51:02 +00:00
|
|
|
<p>For testing, you can generate an RTP input from a static media file:</p>
|
2020-01-22 00:59:16 +00:00
|
|
|
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ ffmpeg -re -stream_loop 100 -i <static.mp4> -vcodec copy -acodec \
|
2018-02-10 23:37:42 +00:00
|
|
|
copy -f rtp rtp://239.255.0.1:1234 -sdp_file saved_sdp_file
|
2017-10-24 22:51:02 +00:00
|
|
|
</pre></div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<p>The command starts only after packager starts.</p>
|
|
|
|
<div class="admonition note">
|
2020-01-22 00:59:16 +00:00
|
|
|
<p class="admonition-title">Note</p>
|
|
|
|
<p>After encoding starts, monitor encoding speed carefully. It should always be
|
2018-02-10 23:37:42 +00:00
|
|
|
1x or above. If not, adjust the encoding parameters to increase it.</p>
|
2017-10-24 22:51:02 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="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>
|
2020-01-22 00:59:16 +00:00
|
|
|
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ packager \
|
2017-10-24 22:51:02 +00:00
|
|
|
'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>
|
2017-09-20 02:35:05 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
2021-04-10 04:00:37 +00:00
|
|
|
<div class="clearer"></div>
|
2017-09-20 02:35:05 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2021-04-10 04:00:37 +00:00
|
|
|
<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>
|
2017-09-20 02:35:05 +00:00
|
|
|
<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" >
|
2021-04-10 04:00:37 +00:00
|
|
|
<a href="http_upload.html" title="HTTP upload"
|
2017-10-24 22:51:02 +00:00
|
|
|
>next</a> |</li>
|
|
|
|
<li class="right" >
|
2018-08-20 17:47:59 +00:00
|
|
|
<a href="ads.html" title="Ad Insertion"
|
2017-09-20 02:35:05 +00:00
|
|
|
>previous</a> |</li>
|
2017-10-24 22:51:02 +00:00
|
|
|
<li class="nav-item nav-item-0"><a href="../index.html">Shaka Packager documentation</a> »</li>
|
2021-04-10 04:00:37 +00:00
|
|
|
<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>
|
2017-09-20 02:35:05 +00:00
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
<div class="footer" role="contentinfo">
|
|
|
|
© Copyright 2017, Google.
|
2021-04-10 04:00:37 +00:00
|
|
|
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 3.4.3.
|
2017-09-20 02:35:05 +00:00
|
|
|
</div>
|
|
|
|
</body>
|
|
|
|
</html>
|