mediainfo 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,12 @@
1
+ require "test_helper"
2
+ require "mediainfo_test_helper"
3
+
4
+ class MediainfoStringTest < ActiveSupport::TestCase
5
+ test "escaping slashes" do
6
+ assert_equal '$\'foo\\\bar\'', 'foo\bar'.shell_escape
7
+ end
8
+
9
+ test "escaping quotes" do
10
+ assert_equal '$\'foo\\\'bar\'', "foo'bar".shell_escape
11
+ end
12
+ end
@@ -0,0 +1,112 @@
1
+ require "test_helper"
2
+ require "mediainfo_test_helper"
3
+
4
+ class MediainfoTest < ActiveSupport::TestCase
5
+ supported_attributes = [
6
+ :codec_id,
7
+ :duration,
8
+ :format,
9
+ :format_profile,
10
+ :format_info,
11
+ :overall_bit_rate,
12
+ :writing_application,
13
+ :writing_library,
14
+
15
+ :mastered_date,
16
+ :tagged_date,
17
+ :encoded_date,
18
+
19
+ ### VIDEO
20
+
21
+ :video_stream_id,
22
+ :video_duration,
23
+ :video_stream_size,
24
+ :video_bit_rate,
25
+ :video_nominal_bit_rate,
26
+ :video_bit_rate_mode,
27
+ :video_scan_order,
28
+ :video_scan_type,
29
+ :video_resolution,
30
+ :video_colorimetry,
31
+ :video_format,
32
+ :video_format_profile,
33
+ :video_format_version,
34
+ :video_format_settings_cabac,
35
+ :video_format_settings_reframes,
36
+ :video_format_settings_matrix,
37
+ :video_codec_id,
38
+ :video_codec_info,
39
+ :video_frame_rate,
40
+ :video_frame_rate_mode,
41
+ :video_display_aspect_ratio,
42
+ :video_bits_pixel_frame,
43
+ :video_width,
44
+ :video_height,
45
+ :video_encoded_date,
46
+ :video_tagged_date,
47
+
48
+ ### AUDIO
49
+
50
+ :audio_stream_id,
51
+ :audio_sampling_rate,
52
+ :audio_duration,
53
+ :audio_stream_size,
54
+ :audio_bit_rate,
55
+ :audio_bit_rate_mode,
56
+ :audio_interleave_duration,
57
+ :audio_resolution,
58
+ :audio_format,
59
+ :audio_format_info,
60
+ :audio_format_settings_endianness,
61
+ :audio_format_settings_sign,
62
+ :audio_codec_id,
63
+ :audio_codec_info,
64
+ :audio_channel_positions,
65
+ :audio_channels,
66
+ :audio_encoded_date,
67
+ :audio_tagged_date,
68
+
69
+ ### IMAGE
70
+
71
+ :image_resolution,
72
+ :image_format,
73
+
74
+ :image_width,
75
+ :image_height
76
+ ]
77
+
78
+ Mediainfo.supported_attributes.each do |attribute|
79
+ test "supports #{attribute} attribute" do
80
+ assert supported_attributes.include?(attribute),
81
+ "#{attribute} is not supported"
82
+ end
83
+ end
84
+
85
+ def setup
86
+ Mediainfo.default_mediainfo_path!
87
+ end
88
+
89
+ test "retains last system command generated" do
90
+ m = Mediainfo.new "/dev/null"
91
+ assert_equal "mediainfo $'/dev/null'", m.last_command
92
+ end
93
+
94
+ test "allows customization of path to mediainfo binary" do
95
+ Mediainfo.any_instance.stubs(:run_last_command!)
96
+
97
+ assert_equal "mediainfo", Mediainfo.path
98
+
99
+ Mediainfo.path = "/opt/local/bin/mediainfo"
100
+ assert_equal "/opt/local/bin/mediainfo", Mediainfo.path
101
+
102
+ m = Mediainfo.new "/dev/null"
103
+ assert_equal "/opt/local/bin/mediainfo $'/dev/null'", m.last_command
104
+ end
105
+
106
+ test "can be initialized with a raw response" do
107
+ m = Mediainfo.new
108
+ m.raw_response = mediainfo_fixture("AwayWeGo_24fps.mov")
109
+ assert m.video?
110
+ assert m.audio?
111
+ end
112
+ end
@@ -0,0 +1,257 @@
1
+ require "test_helper"
2
+ require "mediainfo_test_helper"
3
+
4
+ class MediainfoVimeoTest < ActiveSupport::TestCase
5
+ def setup
6
+ @info = mediainfo_mock "vimeo.57652.avi"
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 "AVI", @info.format
21
+ end
22
+
23
+ test "format profile" do
24
+ assert_nil @info.format_profile
25
+ end
26
+
27
+ test "codec id" do
28
+ assert_nil @info.codec_id
29
+ end
30
+
31
+ mediainfo_test_size
32
+
33
+ test "duration" do
34
+ assert_equal 15164, @info.duration
35
+ assert_equal "15s 164ms", @info.duration_before_type_cast
36
+ end
37
+
38
+ test "overall bitrate" do
39
+ assert_equal "2 078 Kbps", @info.overall_bit_rate
40
+ end
41
+
42
+ test "encoded date" do
43
+ assert_nil @info.encoded_date
44
+ end
45
+
46
+ test "tagged date" do
47
+ assert_nil @info.tagged_date
48
+ end
49
+
50
+ test "writing application" do
51
+ assert_equal "CASIO EX-Z55", @info.writing_application
52
+ end
53
+
54
+ test "writing library" do
55
+ assert_nil @info.writing_library
56
+ end
57
+
58
+ ### VIDEO
59
+
60
+ test "video stream id" do
61
+ assert_nil @info.video_stream_id
62
+ end
63
+
64
+ test "video Format" do
65
+ assert_equal "M-JPEG", @info.video_format
66
+ end
67
+
68
+ test "video format profile" do
69
+ assert_nil @info.video_format_profile
70
+ end
71
+
72
+ test "video format version" do
73
+ assert_nil @info.video_format_version
74
+ end
75
+
76
+ test "video format settings Matrix" do
77
+ assert_nil @info.video_format_settings_matrix
78
+ end
79
+
80
+ test "video format settings CABAC" do
81
+ assert_nil @info.video_format_settings_cabac
82
+ end
83
+
84
+ test "video format settings ReFrames" do
85
+ assert_nil @info.video_format_settings_reframes
86
+ end
87
+
88
+ test "video Codec ID" do
89
+ assert_equal "MJPG", @info.video_codec_id
90
+ end
91
+
92
+ test "video Duration" do
93
+ assert_equal 15164, @info.video_duration
94
+ assert_equal "15s 164ms", @info.video_duration_before_type_cast
95
+ end
96
+
97
+ test "video Bit rate" do
98
+ assert_equal "2 019 Kbps", @info.video_bit_rate
99
+ end
100
+
101
+ test "video nominal bit rate" do
102
+ assert_nil @info.video_nominal_bit_rate
103
+ end
104
+
105
+ test "video bit rate mode" do
106
+ assert_nil @info.video_bit_rate_mode
107
+ assert @info.vbr?
108
+ assert !@info.cbr?
109
+ end
110
+
111
+ test "resolution" do
112
+ assert_equal "320x240", @info.resolution
113
+ end
114
+
115
+ test "video Width" do
116
+ assert_equal 320, @info.video_width
117
+ assert_equal 320, @info.width
118
+ end
119
+
120
+ test "video Height" do
121
+ assert_equal 240, @info.video_height
122
+ assert_equal 240, @info.height
123
+ end
124
+
125
+ test "video Display aspect ratio" do
126
+ assert_equal "4/3", @info.video_display_aspect_ratio
127
+ assert_equal "4/3", @info.display_aspect_ratio
128
+ end
129
+
130
+ test "video frame rate" do
131
+ assert_equal "15.102 fps", @info.video_frame_rate
132
+ assert_equal 15.102, @info.fps
133
+ assert_equal 15.102, @info.framerate
134
+ end
135
+
136
+ test "video frame rate mode" do
137
+ assert_nil @info.video_frame_rate_mode
138
+ end
139
+
140
+ test "video Resolution" do
141
+ assert_equal 24, @info.video_resolution
142
+ assert_equal "24 bits", @info.video_resolution_before_type_cast
143
+ end
144
+
145
+ test "video colorimetry" do
146
+ assert_nil @info.video_colorimetry
147
+ assert_nil @info.video_colorspace
148
+ end
149
+
150
+ test "video Scan type" do
151
+ assert_equal "Progressive", @info.video_scan_type
152
+ assert !@info.interlaced?
153
+ assert @info.progressive?
154
+ end
155
+
156
+ test "video scan order" do
157
+ assert_nil @info.video_scan_order
158
+ end
159
+
160
+ test "video Bits/(Pixel*Frame)" do
161
+ assert_equal "1.741", @info.video_bits_pixel_frame
162
+ end
163
+
164
+ test "video Stream size" do
165
+ assert_equal "3.65 MiB (97%)", @info.video_stream_size
166
+ end
167
+
168
+ ### AUDIO
169
+
170
+ test "audio stream id" do
171
+ assert_nil @info.audio_stream_id
172
+ end
173
+
174
+ test "audio Format" do
175
+ assert_equal "ADPCM", @info.audio_format
176
+ end
177
+
178
+ test "audio format info" do
179
+ assert_nil @info.audio_format_info
180
+ end
181
+
182
+ test "audio Format settings, Endianness" do
183
+ assert_nil @info.audio_format_settings_endianness
184
+ end
185
+
186
+ test "audio Format settings, Sign" do
187
+ assert_nil @info.audio_format_settings_sign
188
+ end
189
+
190
+ test "audio Codec ID" do
191
+ assert_equal "11", @info.audio_codec_id
192
+ end
193
+
194
+ test "audio Codec ID/Info" do
195
+ assert_equal "Intel ADPCM", @info.audio_codec_info
196
+ end
197
+
198
+ test "audio Duration" do
199
+ assert_equal 15164, @info.audio_duration
200
+ assert_equal "15s 164ms", @info.audio_duration_before_type_cast
201
+ end
202
+
203
+ test "audio Bit rate mode" do
204
+ assert_equal "Constant", @info.audio_bit_rate_mode
205
+ end
206
+
207
+ test "audio Bit rate" do
208
+ assert_equal "44.1 Kbps", @info.audio_bit_rate
209
+ end
210
+
211
+ test "audio Channel(s)" do
212
+ assert_equal 1, @info.audio_channels
213
+ end
214
+
215
+ test "audio channel positions" do
216
+ assert_nil @info.audio_channel_positions
217
+ end
218
+
219
+ test "stereo?" do
220
+ assert !@info.stereo?
221
+ end
222
+
223
+ test "mono?" do
224
+ assert @info.mono?
225
+ end
226
+
227
+ test "audio Sampling rate" do
228
+ assert_equal 11025, @info.audio_sample_rate
229
+ assert_equal 11025, @info.audio_sampling_rate
230
+ assert_equal "11.025 KHz", @info.audio_sampling_rate_before_type_cast
231
+ end
232
+
233
+ test "audio resolution" do
234
+ assert_equal 4, @info.audio_resolution
235
+ assert_equal "4 bits", @info.audio_resolution_before_type_cast
236
+ end
237
+
238
+ test "audio Stream size" do
239
+ assert_equal "82.8 KiB (2%)", @info.audio_stream_size
240
+ end
241
+
242
+ test "audio Interleave, duration" do
243
+ assert_equal "67 ms (1.00 video frame)", @info.audio_interleave_duration
244
+ end
245
+
246
+ test "audio encoded date" do
247
+ assert_nil @info.audio_encoded_date
248
+ end
249
+
250
+ test "audio tagged date" do
251
+ assert_nil @info.audio_tagged_date
252
+ end
253
+
254
+ ### IMAGE
255
+
256
+ mediainfo_test_not_an_image
257
+ end
@@ -0,0 +1,234 @@
1
+ require "test_helper"
2
+ require "mediainfo_test_helper"
3
+
4
+ class MediainfoVimeoimageTest < ActiveSupport::TestCase
5
+ def setup
6
+ @info = mediainfo_mock "vimeo.57652_55_500.jpg"
7
+ end
8
+
9
+ ### GENERAL
10
+
11
+ test "image?" do
12
+ assert @info.image?
13
+ end
14
+
15
+ test "audio?" do
16
+ assert !@info.audio?
17
+ end
18
+
19
+ test "video?" do
20
+ assert !@info.video?
21
+ end
22
+
23
+ test "format" do
24
+ assert_equal "JPEG", @info.format
25
+ end
26
+
27
+ test "format profile" do
28
+ assert_nil @info.format_profile
29
+ end
30
+
31
+ test "codec id" do
32
+ assert_nil @info.codec_id
33
+ end
34
+
35
+ mediainfo_test_size
36
+
37
+ test "duration" do
38
+ assert_nil @info.duration
39
+ end
40
+
41
+ test "overall bitrate" do
42
+ assert_nil @info.overall_bit_rate
43
+ end
44
+
45
+ test "encoded date" do
46
+ assert_nil @info.encoded_date
47
+ end
48
+
49
+ test "tagged date" do
50
+ assert_nil @info.tagged_date
51
+ end
52
+
53
+ test "writing application" do
54
+ assert_nil @info.writing_application
55
+ end
56
+
57
+ test "writing library" do
58
+ assert_nil @info.writing_library
59
+ end
60
+
61
+ ### VIDEO
62
+
63
+ test "video Format" do
64
+ assert_nil @info.video_format
65
+ end
66
+
67
+ test "video format profile" do
68
+ assert_nil @info.video_format_profile
69
+ end
70
+
71
+ test "video format settings CABAC" do
72
+ assert_nil @info.video_format_settings_cabac
73
+ end
74
+
75
+ test "video format settings ReFrames" do
76
+ assert_nil @info.video_format_settings_cabac
77
+ end
78
+
79
+ test "video Codec ID" do
80
+ assert_nil @info.video_codec_id
81
+ end
82
+
83
+ test "video Duration" do
84
+ assert_nil @info.video_duration
85
+ end
86
+
87
+ test "video Bit rate" do
88
+ assert_nil @info.video_bit_rate
89
+ end
90
+
91
+ test "video bit rate mode" do
92
+ assert_nil @info.video_bit_rate_mode
93
+ end
94
+
95
+ test "resolution" do
96
+ assert_equal "640x360", @info.resolution
97
+ end
98
+
99
+ test "video Width" do
100
+ assert_nil @info.video_width
101
+ end
102
+
103
+ test "video Height" do
104
+ assert_nil @info.video_height
105
+ end
106
+
107
+ test "video Display aspect ratio" do
108
+ assert_nil @info.video_display_aspect_ratio
109
+ assert_nil @info.display_aspect_ratio
110
+ end
111
+
112
+ test "video Frame rate" do
113
+ assert_nil @info.video_frame_rate
114
+ assert_nil @info.fps
115
+ assert_nil @info.framerate
116
+ end
117
+
118
+ test "video frame rate mode" do
119
+ assert_nil @info.video_frame_rate_mode
120
+ end
121
+
122
+ test "video Resolution" do
123
+ assert_nil @info.video_resolution
124
+ end
125
+
126
+ test "video colorimetry" do
127
+ assert_nil @info.video_colorimetry
128
+ assert_nil @info.video_colorspace
129
+ end
130
+
131
+ test "video Scan type" do
132
+ assert_nil @info.video_scan_type
133
+ assert !@info.interlaced?
134
+ assert !@info.progressive?
135
+ end
136
+
137
+ test "video Bits/(Pixel*Frame)" do
138
+ assert_nil @info.video_bits_pixel_frame
139
+ end
140
+
141
+ test "video Stream size" do
142
+ assert_nil @info.video_stream_size
143
+ end
144
+
145
+ ### AUDIO
146
+
147
+ test "audio Format" do
148
+ assert_nil @info.audio_format
149
+ end
150
+
151
+ test "audio Format settings, Endianness" do
152
+ assert_nil @info.audio_format_settings_endianness
153
+ end
154
+
155
+ test "audio Format settings, Sign" do
156
+ assert_nil @info.audio_format_settings_sign
157
+ end
158
+
159
+ test "audio Codec ID" do
160
+ assert_nil @info.audio_codec_id
161
+ end
162
+
163
+ test "audio Codec ID/Info" do
164
+ assert_nil @info.audio_codec_info
165
+ end
166
+
167
+ test "audio Duration" do
168
+ assert_nil @info.audio_duration
169
+ end
170
+
171
+ test "audio Bit rate mode" do
172
+ assert_nil @info.audio_bit_rate_mode
173
+ end
174
+
175
+ test "audio Bit rate" do
176
+ assert_nil @info.audio_bit_rate
177
+ end
178
+
179
+ test "audio Channel(s)" do
180
+ assert_nil @info.audio_channels
181
+ end
182
+
183
+ test "stereo?" do
184
+ assert !@info.stereo?
185
+ end
186
+
187
+ test "mono?" do
188
+ assert !@info.mono?
189
+ end
190
+
191
+ test "audio Sampling rate" do
192
+ assert_nil @info.audio_sampling_rate
193
+ end
194
+
195
+ test "audio Resolution" do
196
+ assert_nil @info.audio_resolution
197
+ end
198
+
199
+ test "audio Stream size" do
200
+ assert_nil @info.audio_stream_size
201
+ end
202
+
203
+ test "audio Interleave, duration" do
204
+ assert_nil @info.audio_interleave_duration
205
+ end
206
+
207
+ test "audio encoded date" do
208
+ assert_nil @info.audio_encoded_date
209
+ end
210
+
211
+ test "audio tagged date" do
212
+ assert_nil @info.audio_tagged_date
213
+ end
214
+
215
+ ### IMAGE
216
+
217
+ test "image format" do
218
+ assert_equal "JPEG", @info.image_format
219
+ end
220
+
221
+ test "image width" do
222
+ assert_equal 640, @info.image_width
223
+ assert_equal 640, @info.width
224
+ end
225
+
226
+ test "image height" do
227
+ assert_equal 360, @info.image_height
228
+ assert_equal 360, @info.height
229
+ end
230
+
231
+ test "image resolution" do
232
+ assert_equal "24 bits", @info.image_resolution
233
+ end
234
+ end