Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>FFmpeg has three concatenation methods.</p> <h1>1. <a href="https://ffmpeg.org/ffmpeg-filters.html#concat" rel="noreferrer">concat video filter</a></h1> <pre class="lang-sh prettyprint-override"><code>ffmpeg -i opening.mkv -i episode.mkv -i ending.mkv \ -filter_complex "[0:v] [0:a] [1:v] [1:a] [2:v] [2:a] concat=n=3:v=1:a=1 [v] [a]" \ -map "[v]" -map "[a]" output.mkv </code></pre> <p>Note that this method performs a re-encode.</p> <h1>2. <a href="https://ffmpeg.org/ffmpeg-formats.html#concat-1" rel="noreferrer">concat demuxer</a></h1> <pre class="lang-sh prettyprint-override"><code>$ cat mylist.txt file '/path/to/file1' file '/path/to/file2' file '/path/to/file3' $ ffmpeg -f concat -i mylist.txt -c copy output </code></pre> <p><em>for Windows</em>:</p> <pre class="lang-sh prettyprint-override"><code>(echo file 'first file.mp4' &amp; echo file 'second file.mp4' )&gt;list.txt ffmpeg -safe 0 -f concat -i list.txt -c copy output.mp4 </code></pre> <h1>3. <a href="https://ffmpeg.org/ffmpeg-protocols.html#concat" rel="noreferrer">concat protocol</a></h1> <pre class="lang-sh prettyprint-override"><code>ffmpeg -i "concat:input1|input2" -codec copy output </code></pre> <p>This method does not work for many formats, including MP4, due to the nature of these formats and the simplistic concatenation performed by this method.</p> <h2>Which one to use</h2> <ul> <li><p><strong>concat filter</strong>: Use if your inputs do not have the same parameters (width, height, etc), or are not the same formats/codecs, or if you want to perform any filtering. (You could re-encode just the inputs that don't match so they share the same codec and other parameters, then use the concat demuxer to avoid re-encoding the other inputs).</p></li> <li><p><strong>concat demuxer</strong>: Use when you want to avoid a re-encode and your format does not support file level concatenation (most files used by general users do not support file level concatenation).</p></li> <li><p><strong>concat protocol</strong>: Use with formats that support file level concatenation (MPEG-1, MPEG-2 PS, DV). Do not use with MP4.</p></li> </ul> <p>If in doubt try the concat demuxer.</p> <h3>Also see</h3> <ul> <li><a href="https://ffmpeg.org/faq.html#How-can-I-join-video-files_003f" rel="noreferrer">FFmpeg FAQ: How can I join video files?</a></li> <li><a href="https://trac.ffmpeg.org/wiki/Concatenate" rel="noreferrer">FFmpeg Wiki: How to concatenate (join, merge) media files</a></li> </ul>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload