Skip to content

How to Concatenate Video Clips in FFMPEG

George Stoyanov edited this page Aug 23, 2017 · 1 revision

FFMPEG has the ability to concatenate video clips, this could be done using the following command:

ffmpeg -f concat -safe 0 -i mylist.txt -c copy output

The -safe 0 above is not required if the paths are relative.<br >

And the format of the mylist.txt should be:

# this is a comment
file '/path/to/file1'
file '/path/to/file2'
file '/path/to/file3'
I have written a small

I have written a small script which is appending the file ' and also the extension and the closing apostrophe using two sed commands and then execute the concatenation itself using ffmpeg.

#!/bin/bash
# Script that concatenates all the files defined in concat_files.txt
path=/path/to/video/clips
sed -i "s@^@file '$path@" concat_files.txt
sed -i "s/$/.MXF'/" concat_files.txt
cat concat_files.txt
ffmpeg -f concat -safe 0 -i concat_files.txt -c copy output.mxf

References:

Concatenate in FFMPEG