mediainfo 0.6.2 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,516 @@
1
+ require "test_helper"
2
+ require "mediainfo_test_helper"
3
+
4
+ class MediainfoMultipleStreamsTest < ActiveSupport::TestCase
5
+ def setup
6
+ @info = mediainfo_mock "multiple-streams"
7
+ end
8
+
9
+ ### GENERAL
10
+
11
+ test_stream_type_queries :expect => [:audio, :video]
12
+
13
+ test "format" do
14
+ assert_equal "MPEG-4", @info.format
15
+ end
16
+
17
+ test "format profile" do
18
+ assert_equal "QuickTime", @info.format_profile
19
+ end
20
+
21
+ test "codec id" do
22
+ assert_equal "qt", @info.codec_id
23
+ end
24
+
25
+ mediainfo_test_size
26
+
27
+ test "duration" do
28
+ assert_equal 85000, @info.duration
29
+ assert_equal "1mn 25s", @info.duration_before_type_cast
30
+ end
31
+
32
+ test "overall bitrate" do
33
+ assert_equal "9 872 Kbps", @info.overall_bit_rate
34
+ end
35
+
36
+ test "mastered date" do
37
+ assert_nil @info.mastered_date
38
+ end
39
+
40
+ test "encoded date" do
41
+ assert_equal Time.parse("UTC 2009-08-18 16:42:50"), @info.encoded_date
42
+ end
43
+
44
+ test "tagged date" do
45
+ assert_equal Time.parse("UTC 2009-08-18 16:42:55"), @info.tagged_date
46
+ end
47
+
48
+ test "writing application" do
49
+ assert_equal "Sorenson Squeeze 5.0", @info.writing_application
50
+ end
51
+
52
+ test "writing library" do
53
+ assert_equal "Apple QuickTime", @info.writing_library
54
+ end
55
+
56
+ ### VIDEO
57
+
58
+ test "video streams count" do
59
+ assert_equal 2, @info.video.count
60
+ end
61
+
62
+ # stream 1
63
+
64
+ test "video 1 stream id" do
65
+ assert_equal "2", @info.video[0].stream_id
66
+ end
67
+
68
+ test "video 1 Format" do
69
+ assert_equal "AVC", @info.video[0].format
70
+ end
71
+
72
+ test "video 1 Format info" do
73
+ assert_equal "Advanced Video Codec", @info.video[0].format_info
74
+ end
75
+
76
+ test "video 1 format profile" do
77
+ assert_equal "Baseline@L3.2", @info.video[0].format_profile
78
+ end
79
+
80
+ test "video 1 format version" do
81
+ assert_nil @info.video[0].format_version
82
+ end
83
+
84
+ test "video 1 format settings Matrix" do
85
+ assert_nil @info.video[0].format_settings_matrix
86
+ end
87
+
88
+ test "video 1 format settings CABAC" do
89
+ assert_equal "No", @info.video[0].format_settings_cabac
90
+ end
91
+
92
+ test "video 1 format settings ReFrames" do
93
+ assert_equal "4 frames", @info.video[0].format_settings_reframes
94
+ end
95
+
96
+ test "video 1 Codec ID" do
97
+ assert_equal "avc1", @info.video[0].codec_id
98
+ end
99
+
100
+ test "video 1 Codec ID info" do
101
+ assert_equal "Advanced Video Coding", @info.video[0].codec_id_info
102
+ end
103
+
104
+ test "video 1 Duration" do
105
+ assert_equal 85000, @info.video[0].duration
106
+ assert_equal "1mn 25s", @info.video[0].duration_before_type_cast
107
+ end
108
+
109
+ test "video 1 Bit rate" do
110
+ assert_equal "9 392 Kbps", @info.video[0].bit_rate
111
+ end
112
+
113
+ test "video 1 nominal bit rate" do
114
+ assert_nil @info.video[0].nominal_bit_rate
115
+ end
116
+
117
+ test "video 1 bit rate mode" do
118
+ assert_equal "Variable", @info.video[0].bit_rate_mode
119
+ assert @info.video[0].vbr?
120
+ assert !@info.video[0].cbr?
121
+ end
122
+
123
+ test "video 1 resolution" do
124
+ assert_equal 24, @info.video[0].resolution
125
+ end
126
+
127
+ test "video 1 Width" do
128
+ assert_equal 1280, @info.video[0].width
129
+ end
130
+
131
+ test "video 1 Height" do
132
+ assert_equal 720, @info.video[0].height
133
+ end
134
+
135
+ test "video 1 frame size" do
136
+ assert_equal "1280x720", @info.video[0].frame_size
137
+ end
138
+
139
+ test "video 1 Display aspect ratio" do
140
+ assert_equal "16:9", @info.video[0].display_aspect_ratio
141
+ end
142
+
143
+ test "video 1 frame rate" do
144
+ assert_equal "29.970 fps", @info.video[0].frame_rate
145
+ assert_equal 29.97, @info.video[0].fps
146
+ assert_equal 29.97, @info.video[0].framerate
147
+
148
+ assert_equal 29.94, @info.video[0].min_fps
149
+ assert_equal 29.97, @info.video[0].max_fps
150
+ end
151
+
152
+ test "video 1 frame rate mode" do
153
+ assert_equal "Variable", @info.video[0].frame_rate_mode
154
+ end
155
+
156
+ test "video 1 Resolution" do
157
+ assert_equal 24, @info.video[0].resolution
158
+ assert_equal "24 bits", @info.video[0].resolution_before_type_cast
159
+ end
160
+
161
+ test "video 1 standard" do
162
+ assert_equal "NTSC", @info.video[0].standard
163
+ end
164
+
165
+ test "video 1 colorimetry" do
166
+ assert_equal "4:2:0", @info.video[0].colorimetry
167
+ assert_equal "4:2:0", @info.video[0].colorspace
168
+ end
169
+
170
+ test "video 1 Scan type" do
171
+ assert_equal "Progressive", @info.video[0].scan_type
172
+ assert !@info.video[0].interlaced?
173
+ assert @info.video[0].progressive?
174
+ end
175
+
176
+ test "video 1 scan order" do
177
+ assert_nil @info.video[0].scan_order
178
+ end
179
+
180
+ test "video 1 Bits/(Pixel*Frame)" do
181
+ assert_equal "0.340", @info.video[0].bits_pixel_frame
182
+ end
183
+
184
+ test "video 1 Stream size" do
185
+ assert_equal "95.6 MiB (95%)", @info.video[0].stream_size
186
+ end
187
+
188
+ # stream 2
189
+
190
+ test "video 2 stream id" do
191
+ assert_equal "6", @info.video[1].stream_id
192
+ end
193
+
194
+ test "video 2 Format" do
195
+ assert_equal "AVC", @info.video[1].format
196
+ end
197
+
198
+ test "video 2 format profile" do
199
+ assert_equal "Baseline@L3.2", @info.video[1].format_profile
200
+ end
201
+
202
+ test "video 2 format version" do
203
+ assert_nil @info.video[1].format_version
204
+ end
205
+
206
+ test "video 2 format settings Matrix" do
207
+ assert_nil @info.video[1].format_settings_matrix
208
+ end
209
+
210
+ test "video 2 format settings CABAC" do
211
+ assert_equal "No", @info.video[1].format_settings_cabac
212
+ end
213
+
214
+ test "video 2 format settings ReFrames" do
215
+ assert_equal "4 frames", @info.video[1].format_settings_reframes
216
+ end
217
+
218
+ test "video 2 Codec ID" do
219
+ assert_equal "avc1", @info.video[1].codec_id
220
+ end
221
+
222
+ test "video 2 Codec ID info" do
223
+ assert_equal "Advanced Video Coding", @info.video[1].codec_id_info
224
+ end
225
+
226
+ test "video 2 Duration" do
227
+ assert_equal 4170, @info.video[1].duration
228
+ assert_equal "4s 170ms", @info.video[1].duration_before_type_cast
229
+ end
230
+
231
+ test "video 2 Bit rate" do
232
+ assert_equal "656 Kbps", @info.video[1].bit_rate
233
+ end
234
+
235
+ test "video 2 nominal bit rate" do
236
+ assert_nil @info.video[1].nominal_bit_rate
237
+ end
238
+
239
+ test "video 2 bit rate mode" do
240
+ assert_equal "Variable", @info.video[1].bit_rate_mode
241
+ assert @info.video[1].vbr?
242
+ assert !@info.video[1].cbr?
243
+ end
244
+
245
+ test "video 2 frame size" do
246
+ assert_equal "1280x720", @info.video[1].frame_size
247
+ end
248
+
249
+ test "video 2 Width" do
250
+ assert_equal 1280, @info.video[1].width
251
+ end
252
+
253
+ test "video 2 Height" do
254
+ assert_equal 720, @info.video[1].height
255
+ end
256
+
257
+ test "video 2 Display aspect ratio" do
258
+ assert_equal "16:9", @info.video[1].display_aspect_ratio
259
+ end
260
+
261
+ test "video 2 frame rate" do
262
+ assert_equal "29.970 fps", @info.video[1].frame_rate
263
+ assert_equal 29.97, @info.video[1].fps
264
+ assert_equal 29.97, @info.video[1].framerate
265
+ end
266
+
267
+ test "video 2 frame rate mode" do
268
+ assert_equal "Constant", @info.video[1].frame_rate_mode
269
+ end
270
+
271
+ test "video 2 Resolution" do
272
+ assert_equal 24, @info.video[1].resolution
273
+ assert_equal "24 bits", @info.video[1].resolution_before_type_cast
274
+ end
275
+
276
+ test "video 2 colorimetry" do
277
+ assert_equal "4:2:0", @info.video[1].colorimetry
278
+ assert_equal "4:2:0", @info.video[1].colorspace
279
+ end
280
+
281
+ test "video 2 Scan type" do
282
+ assert_equal "Progressive", @info.video[1].scan_type
283
+ assert !@info.video[1].interlaced?
284
+ assert @info.video[1].progressive?
285
+ end
286
+
287
+ test "video 2 scan order" do
288
+ assert_nil @info.video[1].scan_order
289
+ end
290
+
291
+ test "video 2 Bits/(Pixel*Frame)" do
292
+ assert_equal "0.024", @info.video[1].bits_pixel_frame
293
+ end
294
+
295
+ test "video 2 Stream size" do
296
+ assert_equal "334 KiB (0%)", @info.video[1].stream_size
297
+ end
298
+
299
+ ### AUDIO
300
+
301
+ test "audio streams count" do
302
+ assert_equal 2, @info.audio.count
303
+ end
304
+
305
+ # stream 1
306
+
307
+ test "audio 1 stream id" do
308
+ assert_equal "1", @info.audio[0].stream_id
309
+ end
310
+
311
+ test "audio 1 Format" do
312
+ assert_equal "AAC", @info.audio[0].format
313
+ end
314
+
315
+ test "audio 1 format info" do
316
+ assert_equal "Advanced Audio Codec", @info.audio[0].format_info
317
+ end
318
+
319
+ test "audio 1 format version" do
320
+ assert_equal "Version 4", @info.audio[0].format_version
321
+ end
322
+
323
+ test "audio 1 format profile" do
324
+ assert_equal "LC", @info.audio[0].format_profile
325
+ end
326
+
327
+ test "audio 1 format settings SBR" do
328
+ assert_equal "No", @info.audio[0].format_settings_sbr
329
+ end
330
+
331
+ test "audio 1 codec id" do
332
+ assert_equal "40", @info.audio[0].codec_id
333
+ end
334
+
335
+ test "audio 1 codec id hint" do
336
+ assert_nil @info.audio[0].codec_id_hint
337
+ end
338
+
339
+ test "audio 1 Format settings, Endianness" do
340
+ assert_nil @info.audio[0].format_settings_endianness
341
+ end
342
+
343
+ test "audio 1 Format settings, Sign" do
344
+ assert_nil @info.audio[0].format_settings_sign
345
+ end
346
+
347
+ test "audio 1 Codec ID" do
348
+ assert_equal "40", @info.audio[0].codec_id
349
+ end
350
+
351
+ test "audio 1 Codec ID/Info" do
352
+ assert_nil @info.audio[0].codec_info
353
+ end
354
+
355
+ test "audio 1 Duration" do
356
+ assert_equal 85000, @info.audio[0].duration
357
+ assert_equal "1mn 25s", @info.audio[0].duration_before_type_cast
358
+ end
359
+
360
+ test "audio 1 Bit rate mode" do
361
+ assert_equal "Variable", @info.audio[0].bit_rate_mode
362
+ end
363
+
364
+ test "audio 1 Bit rate" do
365
+ assert_equal "256 Kbps", @info.audio[0].bit_rate
366
+ end
367
+
368
+ test "audio 1 Channel(s)" do
369
+ assert_equal 2, @info.audio[0].channels
370
+ end
371
+
372
+ test "audio 1 channel positions" do
373
+ assert_equal "L R", @info.audio[0].channel_positions
374
+ end
375
+
376
+ test "audio 1 stereo?" do
377
+ assert @info.audio[0].stereo?
378
+ end
379
+
380
+ test "audio 1 mono?" do
381
+ assert !@info.audio[0].mono?
382
+ end
383
+
384
+ test "audio 1 Sampling rate" do
385
+ assert_equal 48000, @info.audio[0].sample_rate
386
+ assert_equal 48000, @info.audio[0].sampling_rate
387
+ assert_equal "48.0 KHz", @info.audio[0].sampling_rate_before_type_cast
388
+ end
389
+
390
+ test "audio 1 resolution" do
391
+ assert_equal 16, @info.audio[0].resolution
392
+ assert_equal "16 bits", @info.audio[0].resolution_before_type_cast
393
+ end
394
+
395
+ test "audio 1 Stream size" do
396
+ assert_equal "2.61 MiB (3%)", @info.audio[0].stream_size
397
+ end
398
+
399
+ test "audio 1 Interleave, duration" do
400
+ assert_nil @info.audio[0].interleave_duration
401
+ end
402
+
403
+ test "audio 1 tagged date" do
404
+ assert_kind_of Time, @info.audio[0].tagged_date
405
+ end
406
+
407
+ test "audio 1 encoded date" do
408
+ assert_kind_of Time, @info.audio[0].encoded_date
409
+ end
410
+
411
+ # stream 2
412
+
413
+ test "audio 2 stream id" do
414
+ assert_equal "5", @info.audio[1].stream_id
415
+ end
416
+
417
+ test "audio 2 Format" do
418
+ assert_equal "AAC", @info.audio[1].format
419
+ end
420
+
421
+ test "audio 2 Format version" do
422
+ assert_equal "Version 4", @info.audio[1].format_version
423
+ end
424
+
425
+ test "audio 2 Format profile" do
426
+ assert_equal "LC", @info.audio[1].format_profile
427
+ end
428
+
429
+ test "audio 2 format info" do
430
+ assert_equal "Advanced Audio Codec", @info.audio[1].format_info
431
+ end
432
+
433
+ test "audio 2 codec id hint" do
434
+ assert_nil @info.audio[1].codec_id_hint
435
+ end
436
+
437
+ test "audio 2 Format settings, Endianness" do
438
+ assert_nil @info.audio[1].format_settings_endianness
439
+ end
440
+
441
+ test "audio 1 format settings SBR" do
442
+ assert_equal "No", @info.audio[1].format_settings_sbr
443
+ end
444
+
445
+ test "audio 2 Format settings, Sign" do
446
+ assert_nil @info.audio[1].format_settings_sign
447
+ end
448
+
449
+ test "audio 2 Codec ID" do
450
+ assert_equal "40", @info.audio[1].codec_id
451
+ end
452
+
453
+ test "audio 2 Codec ID/Info" do
454
+ assert_nil @info.audio[1].codec_info
455
+ end
456
+
457
+ test "audio 2 Duration" do
458
+ assert_equal 4156, @info.audio[1].duration
459
+ assert_equal "4s 156ms", @info.audio[1].duration_before_type_cast
460
+ end
461
+
462
+ test "audio 2 Bit rate mode" do
463
+ assert_equal "Constant", @info.audio[1].bit_rate_mode
464
+ end
465
+
466
+ test "audio 2 Bit rate" do
467
+ assert_equal "256 Kbps", @info.audio[1].bit_rate
468
+ end
469
+
470
+ test "audio 2 Channel(s)" do
471
+ assert_equal 2, @info.audio[1].channels
472
+ end
473
+
474
+ test "audio 2 channel positions" do
475
+ assert_equal "L R", @info.audio[1].channel_positions
476
+ end
477
+
478
+ test "audio 2 stereo?" do
479
+ assert @info.audio[1].stereo?
480
+ end
481
+
482
+ test "audio 2 mono?" do
483
+ assert !@info.audio[1].mono?
484
+ end
485
+
486
+ test "audio 2 Sampling rate" do
487
+ assert_equal 44100, @info.audio[1].sample_rate
488
+ assert_equal 44100, @info.audio[1].sampling_rate
489
+ assert_equal "44.1 KHz", @info.audio[1].sampling_rate_before_type_cast
490
+ end
491
+
492
+ test "audio 2 resolution" do
493
+ assert_equal 16, @info.audio[1].resolution
494
+ assert_equal "16 bits", @info.audio[1].resolution_before_type_cast
495
+ end
496
+
497
+ test "audio 2 Stream size" do
498
+ assert_equal "130 KiB (0%)", @info.audio[1].stream_size
499
+ end
500
+
501
+ test "audio 2 Interleave, duration" do
502
+ assert_nil @info.audio[1].interleave_duration
503
+ end
504
+
505
+ test "audio 1 tagged date" do
506
+ assert_kind_of Time, @info.audio[1].tagged_date
507
+ end
508
+
509
+ test "audio 1 encoded date" do
510
+ assert_kind_of Time, @info.audio[1].encoded_date
511
+ end
512
+
513
+ ### IMAGE
514
+
515
+ mediainfo_test_not_an_image
516
+ end