Using ffmpeg to Convert Video Files

Recently, my wife had students in her library create Photostory projects. This wasn’t her first choice of applications for a student project, but the Mac lab was in use for testing. Photostory outputs .wmv files, but my wife wanted to be able to merge the files using iMovie so that teachers could cue up one movie on their classroom presentation stations, which are Macs.

My wife thought she would need to use a service such as Zamzar to convert the files from .wmv into a format that iMovie could import, which seemed like a tedious, impractical task. I thought that perhaps ffmpeg, a command line tool, could help.

I found a Stack Exchange article that suggested this syntax to convert .wmv to mp4:

ffmpeg -i input.wmv -c:v libx264 -crf 23 -c:a libfaac -q:a 100 output.mp4  

I then created the following script to automate the process:


for x in $@
    ffmpeg -i $x -c:v libx264 -crf 23 -c:a libfaac -q:a 100 ${x}.mp4

Thus, using wmv-convert * would loop through all of the files in a directory, converting all .wmv files to .mp4, while keeping the same base filenames.

Each file took several minutes to convert, but I was able run the loop during dinner. Then my wife was able to merge the files using iMovie later that evening.