Skip to content

Instantly share code, notes, and snippets.

@carlzulauf
Forked from asm/mvimg_convert.rb
Last active June 13, 2019 08:05
Show Gist options
  • Save carlzulauf/341db0b070977f233f738c46e0fc4d3d to your computer and use it in GitHub Desktop.
Save carlzulauf/341db0b070977f233f738c46e0fc4d3d to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
# Tool to convert Google motion JPGs (MVIMG) to MP4 video files.
#
# requires exiftool utility (ie: `apt install exiftool`)
# requires exiftool gem (ie: `gem install exiftool`)
#
require 'exiftool'
files = Dir['*.jpg']
files.each do |file|
exif = Exiftool.new(file)
offset = exif[:micro_video_offset]
next unless offset
file_size = File.new(file).size
start = file_size - offset
out_file = File.basename(file, '.jpg') + '.mp4'
puts "Writing " + out_file
IO.copy_stream(file, out_file, file_size, start)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment