-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
amietn
committed
May 5, 2015
1 parent
ac49cd4
commit e76814a
Showing
3 changed files
with
216 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,163 @@ | ||
{ | ||
"streams": [ | ||
{ | ||
"index": 0, | ||
"codec_name": "h264", | ||
"codec_long_name": "H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10", | ||
"profile": "High", | ||
"codec_type": "video", | ||
"codec_time_base": "1/120", | ||
"codec_tag_string": "avc1", | ||
"codec_tag": "0x31637661", | ||
"width": 1920, | ||
"height": 1080, | ||
"has_b_frames": 2, | ||
"sample_aspect_ratio": "1:1", | ||
"display_aspect_ratio": "16:9", | ||
"pix_fmt": "yuv420p", | ||
"level": 42, | ||
"chroma_location": "left", | ||
"refs": 4, | ||
"is_avc": "1", | ||
"nal_length_size": "4", | ||
"r_frame_rate": "60/1", | ||
"avg_frame_rate": "60/1", | ||
"time_base": "1/60000", | ||
"start_pts": 2000, | ||
"start_time": "0.033333", | ||
"duration_ts": 38072000, | ||
"duration": "634.533333", | ||
"bit_rate": "4001453", | ||
"bits_per_raw_sample": "8", | ||
"nb_frames": "38072", | ||
"disposition": { | ||
"default": 1, | ||
"dub": 0, | ||
"original": 0, | ||
"comment": 0, | ||
"lyrics": 0, | ||
"karaoke": 0, | ||
"forced": 0, | ||
"hearing_impaired": 0, | ||
"visual_impaired": 0, | ||
"clean_effects": 0, | ||
"attached_pic": 0 | ||
}, | ||
"tags": { | ||
"creation_time": "2013-12-16 17:59:32", | ||
"language": "und", | ||
"handler_name": "GPAC ISO Video Handler" | ||
} | ||
}, | ||
{ | ||
"index": 1, | ||
"codec_name": "mp3", | ||
"codec_long_name": "MP3 (MPEG audio layer 3)", | ||
"codec_type": "audio", | ||
"codec_time_base": "1/48000", | ||
"codec_tag_string": "mp4a", | ||
"codec_tag": "0x6134706d", | ||
"sample_fmt": "s16p", | ||
"sample_rate": "48000", | ||
"channels": 2, | ||
"channel_layout": "stereo", | ||
"bits_per_sample": 0, | ||
"r_frame_rate": "0/0", | ||
"avg_frame_rate": "0/0", | ||
"time_base": "1/48000", | ||
"start_pts": 0, | ||
"start_time": "0.000000", | ||
"duration_ts": 30441600, | ||
"duration": "634.200000", | ||
"bit_rate": "160000", | ||
"nb_frames": "26425", | ||
"disposition": { | ||
"default": 1, | ||
"dub": 0, | ||
"original": 0, | ||
"comment": 0, | ||
"lyrics": 0, | ||
"karaoke": 0, | ||
"forced": 0, | ||
"hearing_impaired": 0, | ||
"visual_impaired": 0, | ||
"clean_effects": 0, | ||
"attached_pic": 0 | ||
}, | ||
"tags": { | ||
"creation_time": "2013-12-16 17:59:37", | ||
"language": "und", | ||
"handler_name": "GPAC ISO Audio Handler" | ||
} | ||
}, | ||
{ | ||
"index": 2, | ||
"codec_name": "ac3", | ||
"codec_long_name": "ATSC A/52A (AC-3)", | ||
"codec_type": "audio", | ||
"codec_time_base": "1/48000", | ||
"codec_tag_string": "ac-3", | ||
"codec_tag": "0x332d6361", | ||
"sample_fmt": "fltp", | ||
"sample_rate": "48000", | ||
"channels": 6, | ||
"channel_layout": "5.1(side)", | ||
"bits_per_sample": 0, | ||
"dmix_mode": "-1", | ||
"ltrt_cmixlev": "-1.000000", | ||
"ltrt_surmixlev": "-1.000000", | ||
"loro_cmixlev": "-1.000000", | ||
"loro_surmixlev": "-1.000000", | ||
"r_frame_rate": "0/0", | ||
"avg_frame_rate": "0/0", | ||
"time_base": "1/48000", | ||
"start_pts": 0, | ||
"start_time": "0.000000", | ||
"duration_ts": 30438912, | ||
"duration": "634.144000", | ||
"bit_rate": "320000", | ||
"nb_frames": "19817", | ||
"disposition": { | ||
"default": 1, | ||
"dub": 0, | ||
"original": 0, | ||
"comment": 0, | ||
"lyrics": 0, | ||
"karaoke": 0, | ||
"forced": 0, | ||
"hearing_impaired": 0, | ||
"visual_impaired": 0, | ||
"clean_effects": 0, | ||
"attached_pic": 0 | ||
}, | ||
"tags": { | ||
"creation_time": "2013-12-16 17:59:37", | ||
"language": "und", | ||
"handler_name": "GPAC ISO Audio Handler" | ||
} | ||
} | ||
], | ||
"format": { | ||
"filename": "bbb_sunflower_1080p_60fps_normal.mp4", | ||
"nb_streams": 3, | ||
"nb_programs": 0, | ||
"format_name": "mov,mp4,m4a,3gp,3g2,mj2", | ||
"format_long_name": "QuickTime / MOV", | ||
"start_time": "0.000000", | ||
"duration": "634.533333", | ||
"size": "355856562", | ||
"bit_rate": "4486529", | ||
"probe_score": 100, | ||
"tags": { | ||
"major_brand": "isom", | ||
"minor_version": "1", | ||
"compatible_brands": "isomavc1", | ||
"creation_time": "2013-12-16 17:59:32", | ||
"title": "Big Buck Bunny, Sunflower version", | ||
"artist": "Blender Foundation 2008, Janus Bager Kristensen 2013", | ||
"comment": "Creative Commons Attribution 3.0 - http://bbb3d.renderfarming.net", | ||
"genre": "Animation", | ||
"composer": "Sacha Goedegebure" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import json | ||
|
||
from nose.tools import assert_raises | ||
from nose.tools import assert_equals | ||
|
||
from vcsi.vcsi import MediaInfo | ||
|
||
|
||
FFPROBE_EXAMPLE_JSON_PATH = "tests/data/bbb_ffprobe.json" | ||
|
||
|
||
class MediaInfoForTest(MediaInfo): | ||
|
||
def __init__(self, json_path): | ||
self.ffprobe_dict = self.mock_dict(json_path) | ||
self.find_video_stream() | ||
self.compute_display_resolution() | ||
self.compute_format() | ||
|
||
def mock_dict(self, json_path): | ||
with open(json_path) as f: | ||
return json.loads(f.read()) | ||
|
||
|
||
def test_compute_display_resolution(): | ||
mi = MediaInfoForTest(FFPROBE_EXAMPLE_JSON_PATH) | ||
assert_equals(mi.display_width, 1920) | ||
assert_equals(mi.display_height, 1080) | ||
|
||
|
||
def test_filename(): | ||
mi = MediaInfoForTest(FFPROBE_EXAMPLE_JSON_PATH) | ||
assert_equals(mi.filename, "bbb_sunflower_1080p_60fps_normal.mp4") | ||
|
||
|
||
def test_duration(): | ||
mi = MediaInfoForTest(FFPROBE_EXAMPLE_JSON_PATH) | ||
assert_equals(mi.duration_seconds, 634.533333) | ||
|
||
|
||
def test_pretty_duration(): | ||
mi = MediaInfoForTest(FFPROBE_EXAMPLE_JSON_PATH) | ||
assert_equals(mi.duration, "10:34") | ||
|
||
|
||
def test_size_bytes(): | ||
mi = MediaInfoForTest(FFPROBE_EXAMPLE_JSON_PATH) | ||
assert_equals(mi.size_bytes, 355856562) | ||
|
||
|
||
def test_size(): | ||
mi = MediaInfoForTest(FFPROBE_EXAMPLE_JSON_PATH) | ||
assert_equals(mi.size, "339.4 MiB") |