Merge pull request #255 from kfrn/gh-pages

More reorg
This commit is contained in:
Ashley 2017-10-13 19:41:41 -04:00 committed by GitHub
commit 132a00f9e7

View File

@ -42,6 +42,7 @@
<a href="#test-files"><button type="button" class="btn contents-list">Generate test files</button></a>
<a href="#repair"><button type="button" class="btn contents-list">Repair a file</button></a>
<a href="#ocr"><button type="button" class="btn contents-list">Use OCR</button></a>
<a href="#perceptual-similarity"><button type="button" class="btn contents-list">Compare similarity of videos</button></a>
<a href="#other"><button type="button" class="btn contents-list">Something else</button></a>
</nav>
@ -125,47 +126,6 @@
</div>
<!-- End Filtergraph explanation -->
<!-- Record and Live-Stream simultaneously -->
<span data-toggle="collapse" data-target="#record-and-stream"><button type="button" class="btn btn-default" data-toggle="tooltip" data-placement="bottom" title="Record and Live-Stream simultaneously">Record and Live-Stream simultaneously</button></span>
<div id="record-and-stream" class="collapse">
<h3>Record and Live-Stream simultaneously</h3>
<p class="link"></p>
<p><code>ffmpeg -re -i <i>${INPUTFILE}</i> -map 0 -flags +global_header -vf scale="1280:-1,format=yuv420p" -pix_fmt yuv420p -level 3.1 -vsync passthrough -crf 26 -g 50 -bufsize 3500k -maxrate 1800k -c:v libx264 -c:a aac -b:a 128000 -r:a 44100 -ac 2 -t ${STREAMDURATION} -f tee <i>"[movflags=+faststart]${TARGETFILE}|[f=flv]${STREAMTARGET}"</i></code></p>
<p>I use this script to stream to a RTMP target and record the stream locally as .mp4 with only one ffmpeg-instance.</p>
<p>As input, I use <code>bmdcapture</code> which is piped to ffmpeg. But it can also be used with a static videofile as input.</p>
<p>The input will be scaled to 1280px width, maintaining height. Also the stream will stop after a given time (see <code>-t</code> option.)</p>
<h4>Notes</h4>
<ol>
<li>I recommend to use this inside a shell script. then you can define the variables <code>${INPUTFILE}</code>, <code>${STREAMDURATION}</code>, <code>${TARGETFILE}</code>, <code>${STREAMTARGET}</code>.</li>
<li>This is in daily use to live-stream a real-world TV show. No errors for nearly 4 years. Some parameters were found by trial-and-error or empiric testing. So suggestions / questions are welcome.</li>
</ol>
<dl>
<dt>ffmpeg </dt><dd>starts the command</dd>
<dt>-re </dt><dd>Read input at native framerate</dd>
<dt>-i input.mov </dt><dd>The input file. Can also be a <code>-</code> to use STDIN if you pipe in from webcam or SDI.</dd>
<dt>-map 0 </dt><dd>map ALL streams from input file to output</dd>
<dt>-flags +global_header </dt><dd>Don't place extra data in every keyframe</dd>
<dt>-vf scale="1280:-1" </dt><dd>Scale to 1280 width, maintain aspect ratio.</dd>
<dt>-pix_fmt yuv420p </dt><dd>convert to 420p chroma subsampling scheme</dd>
<dt>-level 3.1 </dt><dd>H264 Level (defines some thresholds for bitrate)</dd>
<dt>-vsync passthrough </dt><dd>Each frame is passed with its timestamp from the demuxer to the muxer.</dd>
<dt>-crf 26 </dt><dd>Constant rate factor - basically the quality</dd>
<dt>-g 50 </dt><dd>GOP size.</dd>
<dt>-bufsize 3500k </dt><dd>Ratecontrol buffer size (~ maxrate x2)</dd>
<dt>-maxrate 1800k </dt><dd>Maximum bit rate</dd>
<dt>-c:v libx264 </dt><dd>encode output video stream using H.264</dd>
<dt>-c:a aac </dt><dd>encode output audio stream using AAC</dd>
<dt>-b:a 128000 </dt><dd>The audio bitrate</dd>
<dt>-r:a 44100 </dt><dd>The audio samplerate</dd>
<dt>-ac 2 </dt><dd>Two audio channels</dd>
<dt>-t ${STREAMDURATION} </dt><dd>Time (in seconds) after which the stream should automatically end.</dd>
<dt>-f tee </dt><dd>Use multiple outputs. Outputs defined below.</dd>
<dt>"[movflags=+faststart]target-file.mp4|[f=flv]rtmp://stream-url/stream-id"</dt><dd>The output divided by pipe (|). First is local file. Second is Live Stream. Options for each target in square brackets before the target.</dd>
</dl>
</div>
<!-- END Record and Live-Stream at the same time -->
</div>
<div class="well">
<h2 id="rewrap">Change container (rewrap)</h2>
@ -1772,6 +1732,43 @@ ffmpeg -i $file -map 0 -c copy $output
</div>
<!-- ends Exports OCR -->
</div>
<div class="well">
<h2 id="perceptual-similarity">Compare perceptual similarity of videos</h2>
<!-- Compare Video Fingerprints -->
<span data-toggle="collapse" data-target="#compare_video_fingerprints"><button type="button" class="btn btn-default" data-toggle="tooltip" data-placement="bottom" title="Compare Video Fingerprints">Compare Video Fingerprints</button></span>
<div id="compare_video_fingerprints" class="collapse">
<h3>Compare two video files for content similarity using perceptual hashing</h3>
<p class="link"></p>
<p><code>ffmpeg -i <i>input_one</i> -i <i>input_two</i> -filter_complex signature=detectmode=full:nb_inputs=2 -f null -</code></p>
<dl>
<dt>ffmpeg</dt><dd>starts the command</dd>
<dt>-i <i>input_one</i> -i <i>input_two</i></dt><dd>assigns the input files</dd>
<dt>-filter_complex</dt><dd>enables using more than one input file to the filter</dd>
<dt>signature=detectmode=full</dt><dd>Applies the signature filter to the inputs in 'full' mode. The other option is 'fast'.</dd>
<dt>nb_inputs=2</dt><dd>tells the filter to expect two input files</dd>
<dt>-f null -</dt><dd>Sets the output of FFmpeg to a null stream (since we are not creating a transcoded file, just viewing metadata).</dd>
</dl>
</div>
<!-- ends Compare Video Fingerprints -->
<!-- Generate Video Fingerprint -->
<span data-toggle="collapse" data-target="#generate_video_fingerprint"><button type="button" class="btn btn-default" data-toggle="tooltip" data-placement="bottom" title="Generate Video Fingerprint">Generate Video Fingerprint</button></span>
<div id="generate_video_fingerprint" class="collapse">
<h3>Generate a perceptual hash for an input video file</h3>
<p class="link"></p>
<p><code>ffmpeg -i <i>input</i> -vf signature=format=xml:filename="output.xml" -an -f null -</code></p>
<dl>
<dt>ffmpeg -i <i>input</i></dt><dd>starts the command using your input file</dd>
<dt>-vf signature=format=xml</dt><dd>applies the signature filter to the input file and sets the output format for the fingerprint to xml</dd>
<dt>filename="output.xml"</dt><dd>sets the output for the signature filter</dd>
<dt>-an</dt><dd>tells FFmpeg to ignore the audio stream of the input file</dd>
<dt>-f null -</dt><dd>Sets the FFmpeg output to a null stream (since we are only interested in the output generated by the filter).</dd>
</dl>
</div>
<!-- ends Generate Video Fingerprint -->
</div>
<div class="well">
<h2 id="other">Other</h2>
@ -1915,39 +1912,6 @@ ffmpeg -i $file -map 0 -c copy $output
</div>
<!-- ends Create ISO -->
<!-- Compare Video Fingerprints -->
<span data-toggle="collapse" data-target="#compare_video_fingerprints"><button type="button" class="btn btn-default" data-toggle="tooltip" data-placement="bottom" title="Compare Video Fingerprints">Compare Video Fingerprints</button></span>
<div id="compare_video_fingerprints" class="collapse">
<h3>Compare two video files for content similarity using perceptual hashing</h3>
<p class="link"></p>
<p><code>ffmpeg -i <i>input_one</i> -i <i>input_two</i> -filter_complex signature=detectmode=full:nb_inputs=2 -f null -</code></p>
<dl>
<dt>ffmpeg</dt><dd>starts the command</dd>
<dt>-i <i>input_one</i> -i <i>input_two</i></dt><dd>assigns the input files</dd>
<dt>-filter_complex</dt><dd>enables using more than one input file to the filter</dd>
<dt>signature=detectmode=full</dt><dd>Applies the signature filter to the inputs in 'full' mode. The other option is 'fast'.</dd>
<dt>nb_inputs=2</dt><dd>tells the filter to expect two input files</dd>
<dt>-f null -</dt><dd>Sets the output of FFmpeg to a null stream (since we are not creating a transcoded file, just viewing metadata).</dd>
</dl>
</div>
<!-- ends Compare Video Fingerprints -->
<!-- Generate Video Fingerprint -->
<span data-toggle="collapse" data-target="#generate_video_fingerprint"><button type="button" class="btn btn-default" data-toggle="tooltip" data-placement="bottom" title="Generate Video Fingerprint">Generate Video Fingerprint</button></span>
<div id="generate_video_fingerprint" class="collapse">
<h3>Generate a perceptual hash for an input video file</h3>
<p class="link"></p>
<p><code>ffmpeg -i <i>input</i> -vf signature=format=xml:filename="output.xml" -an -f null -</code></p>
<dl>
<dt>ffmpeg -i <i>input</i></dt><dd>starts the command using your input file</dd>
<dt>-vf signature=format=xml</dt><dd>applies the signature filter to the input file and sets the output format for the fingerprint to xml</dd>
<dt>filename="output.xml"</dt><dd>sets the output for the signature filter</dd>
<dt>-an</dt><dd>tells FFmpeg to ignore the audio stream of the input file</dd>
<dt>-f null -</dt><dd>Sets the FFmpeg output to a null stream (since we are only interested in the output generated by the filter).</dd>
</dl>
</div>
<!-- ends Generate Video Fingerprint -->
<!-- Scene Detection using YDIF -->
<span data-toggle="collapse" data-target="#csv-ydif"><button type="button" class="btn btn-default" data-toggle="tooltip" data-placement="bottom" title="Exports CSV for scene detection using YDIF">CSV with timecodes and YDIF</button></span>
<div id="csv-ydif" class="collapse">
@ -1992,6 +1956,46 @@ ffmpeg -i $file -map 0 -c copy $output
</div>
<!-- ends Cover head switching noise -->
<!-- Record and live-stream simultaneously -->
<span data-toggle="collapse" data-target="#record-and-stream"><button type="button" class="btn btn-default" data-toggle="tooltip" data-placement="bottom" title="Record and live-stream simultaneously">Record and live-stream simultaneously</button></span>
<div id="record-and-stream" class="collapse">
<h3>Record and live-stream simultaneously</h3>
<p class="link"></p>
<p><code>ffmpeg -re -i <i>${INPUTFILE}</i> -map 0 -flags +global_header -vf scale="1280:-1,format=yuv420p" -pix_fmt yuv420p -level 3.1 -vsync passthrough -crf 26 -g 50 -bufsize 3500k -maxrate 1800k -c:v libx264 -c:a aac -b:a 128000 -r:a 44100 -ac 2 -t ${STREAMDURATION} -f tee <i>"[movflags=+faststart]${TARGETFILE}|[f=flv]${STREAMTARGET}"</i></code></p>
<p>I use this script to stream to a RTMP target and record the stream locally as .mp4 with only one ffmpeg-instance.</p>
<p>As input, I use <code>bmdcapture</code> which is piped to ffmpeg. But it can also be used with a static videofile as input.</p>
<p>The input will be scaled to 1280px width, maintaining height. Also the stream will stop after a given time (see <code>-t</code> option.)</p>
<h4>Notes</h4>
<ol>
<li>I recommend to use this inside a shell script - then you can define the variables <code>${INPUTFILE}</code>, <code>${STREAMDURATION}</code>, <code>${TARGETFILE}</code>, and <code>${STREAMTARGET}</code>.</li>
<li>This is in daily use to live-stream a real-world TV show. No errors for nearly 4 years. Some parameters were found by trial-and-error or empiric testing. So suggestions/questions are welcome.</li>
</ol>
<dl>
<dt>ffmpeg </dt><dd>starts the command</dd>
<dt>-re </dt><dd>Read input at native framerate</dd>
<dt>-i input.mov </dt><dd>The input file. Can also be a <code>-</code> to use STDIN if you pipe in from webcam or SDI.</dd>
<dt>-map 0 </dt><dd>map ALL streams from input file to output</dd>
<dt>-flags +global_header </dt><dd>Don't place extra data in every keyframe</dd>
<dt>-vf scale="1280:-1" </dt><dd>Scale to 1280 width, maintain aspect ratio.</dd>
<dt>-pix_fmt yuv420p </dt><dd>convert to 4:2:0 chroma subsampling scheme</dd>
<dt>-level 3.1 </dt><dd>H264 Level (defines some thresholds for bitrate)</dd>
<dt>-vsync passthrough </dt><dd>Each frame is passed with its timestamp from the demuxer to the muxer.</dd>
<dt>-crf 26 </dt><dd>Constant rate factor - basically the quality</dd>
<dt>-g 50 </dt><dd>GOP size.</dd>
<dt>-bufsize 3500k </dt><dd>Ratecontrol buffer size (~ maxrate x2)</dd>
<dt>-maxrate 1800k </dt><dd>Maximum bit rate</dd>
<dt>-c:v libx264 </dt><dd>encode output video stream as H.264</dd>
<dt>-c:a aac </dt><dd>encode output audio stream as AAC</dd>
<dt>-b:a 128000 </dt><dd>The audio bitrate</dd>
<dt>-r:a 44100 </dt><dd>The audio samplerate</dd>
<dt>-ac 2 </dt><dd>Two audio channels</dd>
<dt>-t ${STREAMDURATION} </dt><dd>Time (in seconds) after which the stream should automatically end.</dd>
<dt>-f tee </dt><dd>Use multiple outputs. Outputs defined below.</dd>
<dt>"[movflags=+faststart]target-file.mp4|[f=flv]rtmp://stream-url/stream-id"</dt><dd>The outputs, separated by a pipe (|). The first is the local file, the second is the live stream. Options for each target are given in square brackets before the target.</dd>
</dl>
</div>
<!-- END Record and live-stream at the same time -->
<!-- View Subprogram Info -->
<span data-toggle="collapse" data-target="#view_subprogram_info"><button type="button" class="btn btn-default" data-toggle="tooltip" data-placement="bottom" title="View FFmpeg subprogram information">View FFmpeg subprogram information</button></span>
<div id="view_subprogram_info" class="collapse">