Last Updated: February 25, 2016
·
670
· gokuu

Ruby script to convert Panasonic videos to iPhoto

Just a small Ruby script that converts Panasonic DMC-TZ10 videos to MP4, to import into iPhoto. Keeps the original file's timestamps. Requires ffmpeg (for converting) running on a Mac (for the GetFileInfo and SetFile utilities to maintain timestamps)

def convert_panasonic_video(*files)
  files.flatten.each do |file|
    original_file = file.gsub(/\s/, "\\ ")
    converted_file = original_file.gsub(/\.MTS$/i, ".mp4")
    `ffmpeg -y -i #{original_file} -vcodec copy -acodec libfaac #{converted_file}`
    timestamp = `GetFileInfo -m #{original_file}`.chomp
    `SetFile -d "#{timestamp}" -m "#{timestamp}" #{converted_file}`
  end
end