| | 27 | |
| | 28 | == Description == |
| | 29 | |
| | 30 | The concat filter is available in recent versions of ffmpeg. [http://ffmpeg.org/ffmpeg-filters.html#concat Here] is the official documentation. |
| | 31 | |
| | 32 | == Instructions == |
| | 33 | |
| | 34 | This is easiest to explain using an example: |
| | 35 | |
| | 36 | {{{ |
| | 37 | ffmpeg -i input1.mp4 -i input2.webm \ |
| | 38 | -filter_complex '[0:0] [0:1] [1:0] [1:1] concat=n=2:v=1:a=1 [v] [a]' \ |
| | 39 | -map '[v]' -map '[a]' <encoding options> output.mkv |
| | 40 | }}} |
| | 41 | |
| | 42 | On the -filter_complex line, the following: |
| | 43 | |
| | 44 | {{{ |
| | 45 | '[0:0] [0:1] [1:0] [1:1] |
| | 46 | }}} |
| | 47 | |
| | 48 | tells ffmpeg what streams to send to the concat filter; in this case, streams 0 and 1 from input 0 (input1.mp4 in this example), and streams 0 and 1 from input 1 (input2.webm). |
| | 49 | |
| | 50 | {{{ |
| | 51 | concat=n=2:v=1:a=1 [v] [a]' |
| | 52 | }}} |
| | 53 | |
| | 54 | This is the concat filter itself. n=2 is telling the filter that there are two input files; v=1 is telling it that there will be one video stream; a=1 is telling it that there will be one audio stream. [v] and [a] are names for the output streams, to allow the rest of the ffmpeg line to use the output of the concat filter. |
| | 55 | |
| | 56 | Note that the single quotes ' ' around the whole filter section are required. |
| | 57 | |
| | 58 | {{{ |
| | 59 | -map '[v]' -map '[a]' |
| | 60 | }}} |
| | 61 | |
| | 62 | This tells ffmpeg to use the results of the concat filter rather than the streams directly from the input files. |
| | 63 | |
| | 64 | Note that filters are incompatible with stream copying; you can't use -c copy with this method. Also, I'm not sure whether softsubs are supported. |
| | 65 | |
| | 66 | As you can infer from this example, multiple types of input are supported, anything readable by ffmpeg should work. The inputs have to be of the same frame size, and a handful of other attributes have to match. |
| | 67 | |
| | 68 | = 3. Concatenation of files with different codecs using an external script = |