Combining Multiple Video Files

Rather than send me a single set of video files, my client’s vendor sent me… 149 separate MP4 files, ranging from a few seconds to about 11 minutes long.  I have no interest in sorting through dozens of video files, cataloging them individually, and then trying to review them in order.

While I would have thought VLC would have been a good drag-n’-drop way to stitch them all together, the version I had and the newest version available both weren’t letting me save multiple files into a single file.

A bit of googling and I stumbled across an old friend – ffmpeg!  I hadn’t used this program to transcode video since the early days of DIVX, backing up DVD’s back in the late 1990’s / early aughts.

Here’s the process I settled on for my Windows machine:

  • Created a batch file to create a list of the video files (which included spaces, commas, and all kinds of nonsense command line tools hate).  The entire contents of the batch file was:
    • dir *.mp4 /b > list.txt
  • Since I’m using Notepad++, I used the find/replace function to search / replace on “list.txt”:
    • /r/n
    • ‘/r/nfile ‘
  • Even using some find/replace magic, I still needed to adjust the first and last lines, but that wasn’t so bad.
  • Then, the videos which had been named in semi-logical pattern, were not in strictly alphanumeric order.  I re-ordered them in the text list to the order I’d wanted to view them in.
  • I dropped the FFMPEG executable, downloaded from this mirror, into the folder with the video files and list.txt, then made a new batchfile which contained the following:
    • ffmpeg -f concat -safe 0 -i list.txt -c copy combinedfilename.mp4
  • Now, I could have typed this into the command line, but since I wanted to batch certain files together, it was just easier for my purposes to have the batch file.  Plus, now I have the executable and the batch file for future use.

Anyhow, I hope this helps save someone, perhaps even myself, a few minutes of hair pulling and searching.  :)