This gem is a wrapper for the MediaInfo command-line interface.
It calls the MediaInfo command-line interface, and parses the XML output (obtained with mediainfo file.mp4 --Output=XML
). Excepted for the MediaInfo CLI, it's 100% Ruby.
MediaInfo CLI. Installation:
brew install mediainfo
sudo apt-get install mediainfo
gem install mediainfo-simple
require 'mediainfo-simple'
info = MediaInfo.new "/path/to/file"
That will issue the system call to mediainfo
and parse the output.
# check if there is a stream of some type
info.video? # true
info.audio? # true
info.image? # false
# check the number of streams of some type
info.audio.count # 2
# get metadata about a stream
info.audio[0].language # "English"
info.audio[1].language # "French"
See all the metadata attributes supported for each stream type in the corresponding classes in lib/mediainfo-simple/streams.
Inspired by: