Merge pull request #105 from kfrn/gh-pages

Expand batch processing command.
Resolves https://github.com/amiaopensource/ffmprovisr/issues/77
This commit is contained in:
Reto Kromer 2016-11-01 08:56:58 +01:00 committed by GitHub
commit 86fe53b0c2

View File

@ -702,17 +702,28 @@
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="well">
<h3>Create Bash Script named “Rewrap-MXF.sh” to do Batch FFmpeg Processing</h3>
<p><code>for f in *.MXF; do ffmpeg -i "$f" -map 0 -c copy "${f%.MXF}.mov"; done</code></p>
<p>Re-wrap <code>.MFX</code> files in a specified directory to <code>.mov</code> files by using this code within a <code>.sh</code> file. The shell script (.sh file) and all MXF files must be contained in the same directory, and the script must be run from the directory itself (cd ~/Desktop/MXF_file_directory). Execute <code>.sh</code> file with the command <code>sh Rewrap-MXF.sh</code></p>
<h3>Create Bash script to batch process with ffmpeg</h3>
<p>Bash scripts are plain texts files saved with a .sh extension. This entry explains how they work with the example of a bash script named “Rewrap-MXF.sh”, which rewraps .MXF files in a given directory to .MOV files.</p>
<p>“Rewrap-MXF.sh” contains the following text:</p>
<p><code>for file in *.MXF; do ffmpeg -i "$file" -map 0 -c copy "${file%.MXF}.mov"; done</code></p>
<dl>
<dt>-map 0</dt><dd>select all input streams to map to output</dd>
<dt>-c copy</dt><dd>enable stream copy. This will re-mux wihout re-encoding, so quality is preserved</dd>
<dt>for file in *.MXF</dt><dd>starts the loop, and states what the input files will be. Here, the ffmpeg command within the loop will be applied to all files with an extension of .MXF.<br/>
The word file is an arbitrary variable which will represent each .MXF file in turn as it is looped over.</dd>
<dt>do ffmpeg -i "$file"</dt><dd>carry out the following ffmpeg command for each input file.<br/>
Per Bash syntax, within the command the variable is referred to by <strong>“$file”</strong>. The dollar sign is used to reference the variable file, and the enclosing quotation marks prevents reinterpretation of any special characters that may occur within the filename, ensuring that the original filename is retained.</dd>
<dt>-map 0</dt><dd>retain all streams</dd>
<dt>-c copy</dt><dd>enable stream copy (no re-encode)</dd>
<dt>"${file%.MXF}.mov";</dt><dd>retaining the original file name, set the output file wrapper as .mov</dd>
<dt>done</dt><dd>complete; all items have been processed.</dd>
</dl>
<p>Modify the ffmpeg script as needed to perform different transcodes :)</p>
<p><strong>Note</strong>: the shell script (.sh file) and all .MXF files to be processed must be contained within the same directory, and the script must be run from that directory.<br/>
Execute the .sh file with the command <code>sh Rewrap-MXF.sh</code>.</p>
<p>Modify the script as needed to perform different transcodes, or to use with ffprobe. :)</p>
<p>The basic pattern will look similar to this:<br/>
<code>for item in *.ext; do ffmpeg -i $item <i>(ffmpeg options here)</i> "${item%.ext}_suffix.ext"</code></p>
<p>e.g., if an input file is bestmovie002.avi, its output will be bestmovie002_suffix.avi.</p>
<p class="link"></p>
</div>
</div>
</div>
</div>