The Robservatory

Robservations on everything…

 

Merge multiple movies into one while minimizing file size

I had two short video clips I wanted to merge into one, each about 8MB in size. I first did this using QuickTime Player's Clips feature, but the end result was over 100MB in size. For my second try, I switched to ffmpeg, which can be installed via Homebrew, MacPorts, or some other method.

This isn't quite as simple as typing one command, as ffmpeg wants to process a list of files to merge—it can't, without some Unix wizardry, accept a list on the command line. So step one is to create a text file (list.txt in my example) in the same directory as your video files. The file contains a list of each movie to be merged, one entry per row, like this:

file '/full/path/to/movie1.mp4'
file '/full/path/to/movie2.mp4'
file '/full/path/to/movie3.mp4'
etc.

Save the text file, then use this command to merge the movies into one:

ffmpeg -f concat -safe 0 -i list.txt -codec copy merged_movie.mp4

When done, you'll have one new movie with all of the listed movies, in the order in which you listed them. And best of all, the size won't balloon when you do so—using the same movies as I used in QuickTime Player, the finished file was just 28MB in size. This isn't limited to mp4s; you can merge any type of video that ffmpeg can handle.

And yes, this is another entry in my series of "remind myself" posts; I originally found the answer on Stack Overflow.

1 Comment

Add a Comment

Leave a Reply

Your email address will not be published. Required fields are marked *

The Robservatory © 2022 • Privacy Policy Built from the Frontier theme