Module: MediaInfoRubyisms_Streams

Included in:
MediaInfoLib::MediaInfo
Defined in:
lib/mediainfo-ruby.rb

Constant Summary collapse

ThingsWithMultipleStreams =
[:video, :audio]
StreamKindSymbolsMap =

A symbol map to translate from the Rubyisms we use on mediainfo-ruby to the constants libmediainfo uses.

{
		:general=>MediaInfoLib_StreamKind::General,
		:video=>MediaInfoLib_StreamKind::Video,
		:audio=>MediaInfoLib_StreamKind::Audio,
		:text=>MediaInfoLib_StreamKind::Text,
		:chapters=>MediaInfoLib_StreamKind::Chapters,
		:image=>MediaInfoLib_StreamKind::Image,
		:menu=>MediaInfoLib_StreamKind::Menu,
		:max=>MediaInfoLib_StreamKind::Max
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#empty_valuesObject (readonly)

Set to true if you want empty values



11
12
13
# File 'lib/mediainfo-ruby.rb', line 11

def empty_values
  @empty_values
end

#include_deprecatedObject (readonly)

Returns the value of attribute include_deprecated.



13
14
15
# File 'lib/mediainfo-ruby.rb', line 13

def include_deprecated
  @include_deprecated
end

#include_informObject (readonly)

Returns the value of attribute include_inform.



15
16
17
# File 'lib/mediainfo-ruby.rb', line 15

def include_inform
  @include_inform
end

Instance Method Details

#audio_streamsObject

Returns how many streams are audio streams



40
# File 'lib/mediainfo-ruby.rb', line 40

def audio_streams ; self.count_get(MediaInfoLib_StreamKind::Audio, -1) ; end

#chapter_streamsObject

Returns how many streams are chapter streams



46
# File 'lib/mediainfo-ruby.rb', line 46

def chapter_streams ; self.count_get(MediaInfoLib_StreamKind::Chapters, -1); end

#image_streamsObject

Returns how many streams are image streams



49
# File 'lib/mediainfo-ruby.rb', line 49

def image_streams ; self.count_get(MediaInfoLib_StreamKind::Image, -1); end

#informObject

Call inform and remove the DOS-linefeeds. Useful for quick printout of a bunch of media information



32
33
34
# File 'lib/mediainfo-ruby.rb', line 32

def inform
	self._inform.split("\r")
end

#introspectObject

It introspects a video. This means returning a map of all the values for a definition. By default empty values are not returned. Send with true to return empty values



98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/mediainfo-ruby.rb', line 98

def introspect
	results = {}
	self.option_definitions.each{|topic, topic_parameters|
		kind_constant = StreamKindSymbolsMap[topic]
		if ! kind_constant.nil?
			if ThingsWithMultipleStreams.include?(topic)
				streams = self.send("#{topic.to_s}_streams".to_sym)
				results[topic] = (0..(streams-1)).collect{|ix| introspect_topic(kind_constant, topic_parameters, ix) }
			else
				results[topic] = introspect_topic(kind_constant, topic_parameters)
			end
		end
	}
	results
end

Returns how many streams are menu streams



52
# File 'lib/mediainfo-ruby.rb', line 52

def menu_streams ; self.count_get(MediaInfoLib_StreamKind::Menu, -1); end

#option_definitionsObject

Returns a map of all the possible option definitions, where the key is the option we can ask for and the value is the help for that option. By default, anything marked as deprecated in the underlying library is removed.



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/mediainfo-ruby.rb', line 59

def option_definitions
	option_map = {:general=>{}}
	current = :general
	switching = true
	current_map = option_map[:general]

	option_defs = parameters_csv.each_line{|row| 
		if row.strip == ""
			switching = true
		else
			kv = row.split(";")
			if kv.length == 1 && switching
				topic = kv[0].chomp.downcase.to_sym
				current_map = option_map[topic]
				if current_map.nil?
					option_map[topic] = current_map = {}
				end
				switching = false
			else
				key   = kv[0]
				value = kv[1].nil? ? nil : kv[1].chomp
				current_map[key] = value unless ! (self.include_deprecated ) && kv[1].nil? ? false : kv[1].include?("Deprecated")
			end
		end
	}
	option_map
end

#parameters_csvObject



87
88
89
90
91
92
93
# File 'lib/mediainfo-ruby.rb', line 87

def parameters_csv
	params_csv = self.option("Info_Parameters_CSV", "")
	if RUBY_PLATFORM =~ /darwin/
		params_csv = params_csv.gsub("\r", "\n")
	end
	params_csv
end

#streamsObject

Returns how many streams in total this file has.



37
# File 'lib/mediainfo-ruby.rb', line 37

def streams; self.count_get(MediaInfoLib_StreamKind::General, -1) ; end

#video_streamsObject

Returns how many streams are video streams



43
# File 'lib/mediainfo-ruby.rb', line 43

def video_streams ; self.count_get(MediaInfoLib_StreamKind::Video, -1); end