Using ffmpeg to convert videos for import into iPhoto

If iPhoto is unable to import a video, you can convert it into a format it understands using e.g.

$ ffmpeg -i "$input_path" -vcodec libx264 -preset medium \
   -acodec aac -pix_fmt yuv420p "$output_path"
$ timestamp=`GetFileInfo -m "$input_path"`
$ SetFile -d "$timestamp" -m "$timestamp" "$output_path"

You can set the preset to slow, if you want more compression, or fast if you want it to convert faster.

The GetFileInfo and SetFile utilities are part of ffmpeg and are used to extract and add metadata. In this case, I’m using it to make sure that timestamp of when the input video was created is written to the output video. iPhoto uses that timestamp to make sure the video is in the correct place in your timeline. Alternatively, you can look at the -map_metadata option in ffmpeg, although I couldn’t get it to work correctly.

comments powered by Disqus