How to split media file into several parts and then merge them using Windows batch scripting

At first, we need ffmpeg package which could be downloaded from here: https://www.ffmpeg.org/

The sample batch script file (e.g. split-and-merge.cmd) might look like:

REM prepare first video part
ffmpeg -i myvideo.mp4 -codec copy -ss 00:00:10 -to 00:00:20 first-cut.mp4


REM prepare second video part
ffmpeg -i myvideo.mp4 -codec copy -ss 00:00:30.15 -to 00:00:40.00 second-cut.mp4

REM export files names into temporary file:
(echo file first-cut.mp4 & echo file second-cut.mp4)>list.txt

REM and finally, merge them:
ffmpeg -safe 0 -f concat -i list.txt -c copy final-output.mp4

REM lastly, delete temporary file:
del list.txt

Leave a Reply