Concatenate videos in Windows with a batch file.

Website, builds, or other suggestions.
Post Reply
0012012
Posts: 1
Joined: Mon Aug 17, 2015 3:43 pm

Concatenate videos in Windows with a batch file.

Post by 0012012 » Mon Aug 17, 2015 4:03 pm

I am posting this here because I see no way of contacting the people maintaining the official ffmpeg wiki.

There you can find a very good article which explains how to concatenate videos. There is some code presented, but it only works for Linux.

I did some research and came up with a .bat executable which allows for batch concatenation in Windows. Just copy the following code into a .bat file and put it in the folder with the videos (mp4 files, in this case).

Code: Select all

:: Edit the line below to match your path to the ffmpeg executable.
set path2exe=C:\example\ffmpeg.exe
(for %%i in (*.mp4) do @echo file '%%i') > list.txt
%path2exe% -f concat -i list.txt -c copy output.mp4
del list.txt
After editing the path2exe variable once, it should work in any folder. I suggest to add this code to the wiki in the 'Instructions' section.

llogan
Posts: 323
Joined: Fri Mar 14, 2014 3:29 am

Re: Concatenate videos in Windows with a batch file.

Post by llogan » Wed Aug 19, 2015 5:15 pm

Anybody can edit the wiki articles.

CoRoNe
Posts: 22
Joined: Thu Aug 22, 2013 5:14 pm
Contact:

Re: Concatenate videos in Windows with a batch file.

Post by CoRoNe » Fri Mar 31, 2017 1:47 pm

0012012,

Code: Select all

(FOR %%A IN (*.mp4) DO @ECHO file '%%A') > list.txt
This way all mp4-files will be sorted alphabetically. It's no problem if you have named your mp4-files 1.mp4, 2.mp4, 3.mp4, or a.mp4, b.mp4, c.mp4. But if your mp4-files have random names and you need to concatenate them in chronological order, then sorting them by date is the best thing to do (provided you've also created/downloaded them in chronological order):

Code: Select all

(FOR /F "delims=" %%A IN ('DIR *.mp4 /O:D /B /S') DO @ECHO file '%%A') > list.txt

Post Reply