mediainfo 0.7.2 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/Manifest DELETED
@@ -1,10 +0,0 @@
1
- Changelog
2
- LICENSE
3
- Manifest
4
- README.markdown
5
- Rakefile
6
- index.html.template
7
- lib/mediainfo.rb
8
- lib/mediainfo/attr_readers.rb
9
- lib/mediainfo/string.rb
10
- mediainfo.gemspec
data/README.markdown DELETED
@@ -1,84 +0,0 @@
1
- # Mediainfo
2
-
3
- Mediainfo is a class wrapping [the mediainfo CLI](http://mediainfo.sourceforge.net).
4
-
5
- ## Installation
6
-
7
- $ gem install mediainfo
8
-
9
- ## Usage
10
-
11
- info = Mediainfo.new "/path/to/file"
12
-
13
- That will issue the system call to `mediainfo` and parse the output.
14
- You can specify an alternate path if necessary:
15
-
16
- Mediainfo.path = "/opt/local/bin/mediainfo"
17
-
18
- Once you have an info object, you can start inspecting streams and general metadata.
19
-
20
- info.streams.count # 2
21
- info.audio? # true
22
- info.video? # true
23
- info.image? # false
24
-
25
- When inspecting specific types of streams, you have a couple general API options. The
26
- first approach assumes one stream of a given type, a common scenario in many video files,
27
- for example.
28
-
29
- info.video.count # 1
30
- info.audio.count # 1
31
- info.video.duration # 120 (seconds)
32
-
33
- Sometimes you'll have more than one stream of a given type. Quicktime files can often
34
- contain artifacts like this from somebody editing a more 'normal' file.
35
-
36
- info = Mediainfo.new "funky.mov"
37
-
38
- info.video? # true
39
- info.video.count # 2
40
- info.video.duration # raises SingleStreamAPIError !
41
- info.video[0].duration # 120
42
- info.video[1].duration # 10
43
-
44
- For some more usage examples, please see the very reasonable test suite accompanying the source code
45
- for this library. It contains a bunch of relevant usage examples. More docs in the future.. contributions
46
- *very* welcome!
47
-
48
- Moving on, REXML is used as the XML parser by default. If you'd like, you can
49
- configure Mediainfo to use Hpricot or Nokogiri instead using one of
50
- the following approaches:
51
-
52
- * define the `MEDIAINFO_XML_PARSER` environment variable to be the
53
- name of the parser as you'd pass to a :gem or :require call.
54
-
55
- e.g. `export MEDIAINFO_XML_PARSER=nokogiri`
56
-
57
- * assign to Mediainfo.xml_parser after you've loaded the gem,
58
- following the same naming conventions mentioned previously.
59
-
60
- e.g. `Mediainfo.xml_parser = "hpricot"`
61
-
62
-
63
- Once you've got an instance setup, you can call numerous methods to get
64
- a variety of information about a file. Some attributes may be present
65
- for some files where others are not, but any supported attribute
66
- should at least return `nil`.
67
-
68
- ## Requirements
69
-
70
- This requires at least the following version of the Mediainfo CLI:
71
-
72
- MediaInfo Command line,
73
- MediaInfoLib - v0.7.25
74
-
75
- Previous versions of this gem(<= 0.5.1) worked against v0.7.11, which did not
76
- generate XML output, and is no longer supported.
77
-
78
- ## Contributors
79
-
80
- * Seth Thomas Rasmussen - [http://greatseth.com](http://greatseth.com)
81
- * Peter Vandenberk - [http://github.com/pvdb](http://github.com/pvdb)
82
- * Ned Campion - [http://github.com/nedcampion](http://github.com/nedcampion)
83
- * Daniel Jagszent - [http://github.com/d--j](http://github.com/d--j)
84
- * Robert Mrasek - [http://github.com/derobo](http://github.com/derobo)
data/index.html.template DELETED
@@ -1,9 +0,0 @@
1
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4
- <head>
5
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
6
- <title>mediainfo</title>
7
- </head>
8
- <body>body</body>
9
- </html>
@@ -1,75 +0,0 @@
1
- require "time"
2
- require "mediainfo/string"
3
-
4
- class Mediainfo
5
- module AttrReaders
6
- def mediainfo_attr_reader(method_name, mediainfo_key = nil)
7
- # NOTE explicit self necessary here until we rename local var 'name'
8
- stream_class_type = name[/::([^:]+)Stream$/, 1]
9
-
10
- before_type_cast_method_name = "#{method_name}_before_type_cast"
11
- mediainfo_key = mediainfo_key.gsub(/\W+/, "_").downcase if mediainfo_key
12
-
13
- if m = stream_class_type.match(/^#{Regexp.union *Mediainfo::NON_GENERAL_SECTIONS.map { |x| x.to_s.capitalize }}$/)
14
- k1 = stream_class_type.downcase.to_sym
15
- else
16
- k1 = :general
17
- end
18
-
19
- define_method before_type_cast_method_name do
20
- if v = instance_variable_get("@#{before_type_cast_method_name}")
21
- v
22
- else
23
- k2 = mediainfo_key ? mediainfo_key : method_name.to_s
24
- v = @parsed_response[k1][k2]
25
-
26
- instance_variable_set "@#{before_type_cast_method_name}", v
27
- instance_variable_get "@#{before_type_cast_method_name}"
28
- end
29
- end
30
-
31
- define_method method_name do
32
- if v = instance_variable_get("@#{method_name}")
33
- v
34
- else
35
- v = send(before_type_cast_method_name)
36
- v = yield v if v and block_given?
37
-
38
- instance_variable_set "@#{method_name}", v
39
- instance_variable_get "@#{method_name}"
40
- end
41
- end
42
-
43
- supported_attribute = method_name
44
- supported_attribute = "#{stream_class_type.downcase}_#{method_name}".to_sym unless k1 == :general
45
- Mediainfo.supported_attributes << supported_attribute
46
- end
47
-
48
- def mediainfo_duration_reader(*a)
49
- mediainfo_attr_reader *a do |v|
50
- t = 0
51
- v.split(/\s+/).each do |tf|
52
- case tf
53
- # XXX haven't actually seen hot they represent hours yet
54
- # but hopefully this is ok.. :\
55
- when /\d+h/ then t += tf.to_i * 60 * 60 * 1000
56
- when /\d+mn/ then t += tf.to_i * 60 * 1000
57
- when /\d+ms/ then t += tf.to_i
58
- when /\d+s/ then t += tf.to_i * 1000
59
- else
60
- raise "unexpected time fragment! please report bug!"
61
- end
62
- end
63
- t
64
- end
65
- end
66
-
67
- def mediainfo_date_reader(*a)
68
- mediainfo_attr_reader(*a) { |v| Time.parse v }
69
- end
70
-
71
- def mediainfo_int_reader(*a)
72
- mediainfo_attr_reader(*a) { |v| v.gsub(/\D+/, "").to_i }
73
- end
74
- end
75
- end
@@ -1,284 +0,0 @@
1
- require "test_helper"
2
- require "mediainfo_test_helper"
3
-
4
- class MediainfoAwaywegoTest < ActiveSupport::TestCase
5
- def setup
6
- @info = mediainfo_mock "AwayWeGo_24fps.mov"
7
- end
8
-
9
- ### GENERAL
10
-
11
- test "audio?" do
12
- assert @info.audio?
13
- end
14
-
15
- test "video?" do
16
- assert @info.video?
17
- end
18
-
19
- test "format" do
20
- assert_equal "MPEG-4", @info.format
21
- end
22
-
23
- test "format profile" do
24
- assert_equal "QuickTime", @info.format_profile
25
- end
26
-
27
- test "codec id" do
28
- assert_equal "qt", @info.codec_id
29
- end
30
-
31
- mediainfo_test_size
32
-
33
- test "duration" do
34
- assert_equal 36286, @info.duration
35
- assert_equal "36s 286ms", @info.duration_before_type_cast
36
- end
37
-
38
- test "overall bitrate" do
39
- assert_equal "42.7 Mbps", @info.overall_bit_rate
40
- end
41
-
42
- test "encoded date" do
43
- assert_kind_of Time, @info.encoded_date
44
- # assert_equal "UTC 2009-03-30 19:49:13", @info.encoded_date
45
- end
46
-
47
- test "tagged date" do
48
- assert_kind_of Time, @info.tagged_date
49
- # assert_equal "UTC 2009-03-30 19:57:57", @info.tagged_date
50
- end
51
-
52
- test "writing application" do
53
- assert_nil @info.writing_application
54
- end
55
-
56
- test "writing library" do
57
- assert_equal "Apple QuickTime", @info.writing_library
58
- end
59
-
60
- ### VIDEO
61
-
62
- test "video stream id" do
63
- assert_equal "2", @info.video.stream_id
64
- end
65
-
66
- test "video Format" do
67
- assert_equal "AVC", @info.video.format
68
- end
69
-
70
- test "video format profile" do
71
- assert_equal "Main@L4.1", @info.video.format_profile
72
- end
73
-
74
- test "video format version" do
75
- assert_nil @info.video.format_version
76
- end
77
-
78
- test "video format settings Matrix" do
79
- assert_nil @info.video.format_settings_matrix
80
- end
81
-
82
- test "video format settings CABAC" do
83
- assert_equal "No", @info.video.format_settings_cabac
84
- end
85
-
86
- test "video format settings ReFrames" do
87
- assert_equal "2 frames", @info.video.format_settings_reframes
88
- end
89
-
90
- test "video Codec ID" do
91
- assert_equal "avc1", @info.video.codec_id
92
- end
93
-
94
- test "video codec info" do
95
- assert_equal "Advanced Video Coding", @info.video.codec_info
96
- end
97
-
98
- test "video Duration" do
99
- assert_equal 36286, @info.video.duration
100
- assert_equal "36s 286ms", @info.video.duration_before_type_cast
101
- end
102
-
103
- test "video bit rate mode" do
104
- assert_equal "Variable", @info.video.bit_rate_mode
105
- assert @info.video.vbr?
106
- assert !@info.video.cbr?
107
- end
108
-
109
- test "video Bit rate" do
110
- assert_equal "41.2 Mbps", @info.video.bit_rate
111
- end
112
-
113
- test "video nominal bit rate" do
114
- assert_nil @info.video.nominal_bit_rate
115
- end
116
-
117
- test "frame size" do
118
- assert_equal "1920x840", @info.video.frame_size
119
- end
120
-
121
- test "video Width" do
122
- assert_equal 1920, @info.video.width
123
- end
124
-
125
- test "video Height" do
126
- assert_equal 840, @info.video.height
127
- end
128
-
129
- test "video Display aspect ratio" do
130
- assert_equal "2.25:1", @info.video.display_aspect_ratio
131
- end
132
-
133
- test "video frame rate" do
134
- assert_equal "23.976 fps", @info.video.frame_rate
135
- assert_equal 23.976, @info.video.fps
136
- assert_equal 23.976, @info.video.framerate
137
- end
138
-
139
- test "video frame rate mode" do
140
- assert_equal "Constant", @info.video.frame_rate_mode
141
- end
142
-
143
- test "video Resolution" do
144
- assert_equal 24, @info.video.resolution
145
- assert_equal "24 bits", @info.video.resolution_before_type_cast
146
- end
147
-
148
- test "video colorimetry" do
149
- assert_equal "4:2:0", @info.video.colorimetry
150
- assert_equal "4:2:0", @info.video.colorspace
151
- end
152
-
153
- test "video Scan type" do
154
- assert_equal "Progressive", @info.video.scan_type
155
- assert !@info.video.interlaced?
156
- assert @info.video.progressive?
157
- end
158
-
159
- test "video scan order" do
160
- assert_nil @info.video.scan_order
161
- end
162
-
163
- test "video Bits/(Pixel*Frame)" do
164
- assert_equal "1.065", @info.video.bits_pixel_frame
165
- end
166
-
167
- test "video Stream size" do
168
- assert_equal "178 MiB (96%)", @info.video.stream_size
169
- end
170
-
171
- test "video encoded date" do
172
- assert_kind_of Time, @info.video.encoded_date
173
- end
174
-
175
- test "video tagged date" do
176
- assert_kind_of Time, @info.video.tagged_date
177
- end
178
-
179
- test "video color primaries" do
180
- assert_equal \
181
- "BT.709-5, BT.1361, IEC 61966-2-4, SMPTE RP177",
182
- @info.video.color_primaries
183
- end
184
-
185
- test "video transfer characteristics" do
186
- assert_equal "BT.709-5, BT.1361", @info.video.transfer_characteristics
187
- end
188
-
189
- test "video matrix coefficients" do
190
- assert_equal \
191
- "BT.709-5, BT.1361, IEC 61966-2-4 709, SMPTE RP177",
192
- @info.video.matrix_coefficients
193
- end
194
-
195
- ### AUDIO
196
-
197
- test "audio stream id" do
198
- assert_equal "1", @info.audio.stream_id
199
- end
200
-
201
- test "audio Format" do
202
- assert_equal "PCM", @info.audio.format
203
- end
204
-
205
- test "audio format info" do
206
- assert_nil @info.audio.format_info
207
- end
208
-
209
- test "audio Format settings, Endianness" do
210
- assert_equal "Little", @info.audio.format_settings_endianness
211
- end
212
-
213
- test "audio Format settings, Sign" do
214
- assert_equal "Signed", @info.audio.format_settings_sign
215
- end
216
-
217
- test "audio Codec ID" do
218
- assert_equal "sowt", @info.audio.codec_id
219
- end
220
-
221
- test "audio Codec ID/Info" do
222
- assert_nil @info.audio.codec_info
223
- end
224
-
225
- test "audio Duration" do
226
- assert_equal 36286, @info.audio.duration
227
- assert_equal "36s 286ms", @info.audio.duration_before_type_cast
228
- end
229
-
230
- test "audio Bit rate mode" do
231
- assert_equal "Constant", @info.audio.bit_rate_mode
232
- end
233
-
234
- test "audio Bit rate" do
235
- assert_equal "1 536 Kbps", @info.audio.bit_rate
236
- end
237
-
238
- test "audio Channel(s)" do
239
- assert_equal 2, @info.audio.channels
240
- end
241
-
242
- test "audio channel positions" do
243
- assert_nil @info.audio.channel_positions
244
- end
245
-
246
- test "stereo?" do
247
- assert @info.audio.stereo?
248
- end
249
-
250
- test "mono?" do
251
- assert !@info.audio.mono?
252
- end
253
-
254
- test "audio Sampling rate" do
255
- assert_equal 48000, @info.audio.sample_rate
256
- assert_equal 48000, @info.audio.sampling_rate
257
- assert_equal "48.0 KHz", @info.audio.sampling_rate_before_type_cast
258
- end
259
-
260
- test "audio resolution" do
261
- assert_equal 16, @info.audio.resolution
262
- assert_equal "16 bits", @info.audio.resolution_before_type_cast
263
- end
264
-
265
- test "audio Stream size" do
266
- assert_equal "6.64 MiB (4%)", @info.audio.stream_size
267
- end
268
-
269
- test "audio Interleave, duration" do
270
- assert_nil @info.audio.interleave_duration
271
- end
272
-
273
- test "audio encoded date" do
274
- assert_kind_of Time, @info.audio.encoded_date
275
- end
276
-
277
- test "audio tagged date" do
278
- assert_kind_of Time, @info.audio.tagged_date
279
- end
280
-
281
- ### IMAGE
282
-
283
- mediainfo_test_not_an_image
284
- end