Created
November 5, 2017 23:45
-
-
Save dagezi/942953436e84814bcce7f3b4e7d1b873 to your computer and use it in GitHub Desktop.
For Panasonic Videos.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://en.wikipedia.org/wiki/MOI_(file_format) | |
def get_date_from_moi(moi) | |
File.open(moi, "rb") { |file| | |
file.seek(6) | |
bytes = file.read(10) | |
y, mon, d, h, min, ms = bytes.unpack('nCCCCn') | |
return Time.new(y, mon, d, h, min, ms/1000) | |
} | |
end | |
def change_mtime_of_mpeg(mpeg_file) | |
moi_file = mpeg_file.gsub(/mpg$/, 'moi') | |
if File.exist?(moi_file) | |
mtime = get_date_from_moi(moi_file) | |
File.utime(mtime, mtime, mpeg_file) | |
else | |
puts "#{mpeg_file}: no #{moi_file}" | |
end | |
end | |
ARGV.each {|mpeg_file| | |
change_mtime_of_mpeg(mpeg_file) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment