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

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 on July 19, 2012.