Convert MPG videos to MP4 (to edit them in iMovie)

Leo Soto
Leo Soto
Jul 19, 2012 · 1 min read

Posted by Leo Soto on July 19th, 2012.


I just filmed a couple of clips to edit them later in iMovie. Surprisingly, the MPG files generated by my (consumer, low end) camera were not importable in iMovie.

Armed with ffmpeg $ brew install ffmpeg if you don't have it already installed) and bash, it wasn't that difficult to solve the problem, once I figured out the particular incantation that ffmpeg required. Therefore, to hopefully save someone else time if he/she has the same need, here it is:

for x in *.MPG; do ffmpeg -i $x -strict experimental -f mp4 \ -vcodec libx264 -acodec aac \ -ab 160000 -ac 2 -preset slow \ -crf 22 ${x/.MPG/.mp4}; done

And voila, all the *.MPG files in the current directory will be converted to *.mp4 files, importable in iMovie.


Originally published at techblog.leosoto.com on July 19, 2012.

Leo’s Tech Blog

A personal blog on tech stuff.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch

Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore

Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store