shaka-packager/tutorials/ffmpeg_piping.html

163 lines
7.2 KiB
HTML

<!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" />
<title>ffmpeg piping &#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>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
<link rel="index" title="Index" href="../genindex.html" />
<link rel="search" title="Search" href="../search.html" />
<link rel="prev" title="Media Encoding" href="encoding.html" />
</head>
<body role="document">
<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="encoding.html" title="Media Encoding"
accesskey="P">previous</a> |</li>
<li class="nav-item nav-item-0"><a href="../index.html">Shaka Packager documentation</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>
<li><a class="reference internal" href="#">ffmpeg piping</a><ul>
<li><a class="reference internal" href="#ffmpeg-camera-capture">ffmpeg camera capture</a></li>
<li><a class="reference internal" href="#create-pipe">Create pipe</a></li>
<li><a class="reference internal" href="#encoding-capture-command">Encoding / capture command</a></li>
<li><a class="reference internal" href="#packaging-command-dash">Packaging command (DASH)</a></li>
</ul>
</li>
</ul>
<h4>Previous topic</h4>
<p class="topless"><a href="encoding.html"
title="previous chapter">Media Encoding</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>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">
<div class="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. The example below uses
webcam input device. The concept depicted here can be applied to
other <em>ffmpeg</em> supported capture device.</p>
<div class="section" id="ffmpeg-camera-capture">
<h2>ffmpeg camera capture<a class="headerlink" href="#ffmpeg-camera-capture" title="Permalink to this headline"></a></h2>
<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 examples below assumes Mac OS X 10.7 (Lion) or later. It is similar on
other platforms. Refer to the above link for details.</p>
</div>
<div class="section" id="create-pipe">
<h2>Create pipe<a class="headerlink" href="#create-pipe" title="Permalink to this headline"></a></h2>
<p>We use pipe to connect <em>ffmpeg</em> and <em>packager</em>:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span>$ mkfifo pipe1
</pre></div>
</div>
</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>
<p>The below command captures from the default audio / video devices on the
machine:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span>$ ffmpeg -f avfoundation -i &quot;default&quot; -f mpegts pipe: &gt; pipe1
</pre></div>
</div>
<p>The command starts only after packager starts.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">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>
</div>
<div class="section" id="packaging-command-dash">
<h2>Packaging command (DASH)<a class="headerlink" href="#packaging-command-dash" title="Permalink to this headline"></a></h2>
<div class="highlight-default"><div class="highlight"><pre><span></span>$ packager \
&#39;in=pipe1,stream=audio,init_segment=live_cam_audio.mp4,segment_template=live_cam_audio_$Number$.m4s&#39; \
&#39;in=pipe1,stream=video,init_segment=live_cam_video.mp4,segment_template=live_cam_video_$Number$.m4s&#39; \
--mpd_output live_cam.mpd \
--io_block_size 65536
</pre></div>
</div>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">Option -io_block_size 65536 tells packager to use an io_block_size of 65K
for threaded io file. This is necessary 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>
</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" >
<a href="encoding.html" title="Media Encoding"
>previous</a> |</li>
<li class="nav-item nav-item-0"><a href="../index.html">Shaka Packager documentation</a> &#187;</li>
</ul>
</div>
<div class="footer" role="contentinfo">
&#169; Copyright 2017, Google.
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.5.3.
</div>
</body>
</html>