Module: FFMpeg::MetaData

Included in:
FFMpeg
Defined in:
lib/ffmpeg/meta_data.rb

Constant Summary collapse

EXIF_UTILITY =
'exiftool'

Instance Method Summary collapse

Instance Method Details

#metaObject

Retrieves meta data from the file using exiftool, and returned in a hash allowing for complex conversion rules.

video_bitrate "300k" if meta[:video_bitrate].to_f > 300


11
12
13
14
15
16
17
18
19
# File 'lib/ffmpeg/meta_data.rb', line 11

def meta
  if `which #{EXIF_UTILITY}`.empty?
    {}
  else
    @meta_data ||= `#{EXIF_UTILITY} #{@from_file}`.split("\n").inject({}) {|hash, element| 
      hash.merge(((split = element.split(':')) && split.first.strip.downcase.gsub(/[^a-zA-Z0-9]/, "_").to_sym) => (split.shift && split).join(':').strip)
    }
  end
end