How to concatenate two or more video files using ffmpeg from Windows command line or Powershell?
1 Answer
If you have multiple video files with exactly the same codec and codec parameters you can concatenate them with ffmpeg.
First, you have to create a text file that contains the names of input files. The example below works with mp4 files, but you can use any ffmpeg compatible formats instead of mp4.
It's easy to create the list of files on Windows command line (CMD) with this command:
(for %i in (*.mp4) do @echo file '%i') > files.txtLinux terminal (bash shell):
printf "file '%s'\n" * > files.txtOr Powershell:
foreach ($i in Get-ChildItem .\*.mp4) {echo "file '$i'" >> files.txt}Once your text file is ready it should contain all the names of files you want to concatenate in this format:
file 'file1.mp4'
file 'file2.mp4'
file 'file3.mp4'Now you can enter the following command to concatenate the files:
ffmpeg -f concat -safe 0 -i files.txt -c copy output.mp4 0