bmff 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +25 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +183 -0
- data/Rakefile +9 -0
- data/bmff.gemspec +25 -0
- data/lib/bmff/binary_accessor.rb +186 -0
- data/lib/bmff/box/audio_sample_entry.rb +16 -0
- data/lib/bmff/box/base.rb +66 -0
- data/lib/bmff/box/bit_rate.rb +14 -0
- data/lib/bmff/box/chunk_large_offset.rb +16 -0
- data/lib/bmff/box/chunk_offset.rb +16 -0
- data/lib/bmff/box/clean_aperture.rb +20 -0
- data/lib/bmff/box/colour_information.rb +27 -0
- data/lib/bmff/box/compact_sample_size.rb +32 -0
- data/lib/bmff/box/composition_offset.rb +25 -0
- data/lib/bmff/box/composition_to_decode.rb +17 -0
- data/lib/bmff/box/container.rb +70 -0
- data/lib/bmff/box/copyright.rb +13 -0
- data/lib/bmff/box/data_entry_url.rb +12 -0
- data/lib/bmff/box/data_entry_urn.rb +13 -0
- data/lib/bmff/box/data_information.rb +12 -0
- data/lib/bmff/box/data_reference.rb +14 -0
- data/lib/bmff/box/degradation_priority.rb +19 -0
- data/lib/bmff/box/edit.rb +12 -0
- data/lib/bmff/box/edit_list.rb +27 -0
- data/lib/bmff/box/file_type.rb +17 -0
- data/lib/bmff/box/free_space.rb +6 -0
- data/lib/bmff/box/full.rb +11 -0
- data/lib/bmff/box/handler.rb +15 -0
- data/lib/bmff/box/hint_media_header.rb +16 -0
- data/lib/bmff/box/hint_sample_entry.rb +14 -0
- data/lib/bmff/box/level_assignment.rb +35 -0
- data/lib/bmff/box/map.rb +15 -0
- data/lib/bmff/box/media.rb +12 -0
- data/lib/bmff/box/media_data.rb +6 -0
- data/lib/bmff/box/media_header.rb +25 -0
- data/lib/bmff/box/media_information.rb +12 -0
- data/lib/bmff/box/meta_data_sample_entry.rb +5 -0
- data/lib/bmff/box/movie.rb +12 -0
- data/lib/bmff/box/movie_extends.rb +12 -0
- data/lib/bmff/box/movie_extends_header.rb +16 -0
- data/lib/bmff/box/movie_fragment.rb +12 -0
- data/lib/bmff/box/movie_fragment_header.rb +12 -0
- data/lib/bmff/box/movie_fragment_random_access.rb +12 -0
- data/lib/bmff/box/movie_fragment_random_access_offset.rb +12 -0
- data/lib/bmff/box/movie_header.rb +36 -0
- data/lib/bmff/box/null_media_header.rb +6 -0
- data/lib/bmff/box/padding_bits.rb +23 -0
- data/lib/bmff/box/pixel_aspect_ratio.rb +13 -0
- data/lib/bmff/box/progressive_download_info.rb +17 -0
- data/lib/bmff/box/sample_auxiliary_information_offsets.rb +24 -0
- data/lib/bmff/box/sample_auxiliary_information_sizes.rb +23 -0
- data/lib/bmff/box/sample_dependency_type.rb +26 -0
- data/lib/bmff/box/sample_description.rb +27 -0
- data/lib/bmff/box/sample_entry.rb +15 -0
- data/lib/bmff/box/sample_size.rb +19 -0
- data/lib/bmff/box/sample_table.rb +12 -0
- data/lib/bmff/box/sample_to_chunk.rb +20 -0
- data/lib/bmff/box/shadow_sync_sample.rb +18 -0
- data/lib/bmff/box/sound_media_header.rb +13 -0
- data/lib/bmff/box/sub_sample_information.rb +41 -0
- data/lib/bmff/box/sync_sample.rb +16 -0
- data/lib/bmff/box/text_meta_data_sample_entry.rb +18 -0
- data/lib/bmff/box/time_to_sample.rb +18 -0
- data/lib/bmff/box/track.rb +12 -0
- data/lib/bmff/box/track_extends.rb +17 -0
- data/lib/bmff/box/track_fragment.rb +12 -0
- data/lib/bmff/box/track_fragment_base_media_decode_time.rb +16 -0
- data/lib/bmff/box/track_fragment_header.rb +18 -0
- data/lib/bmff/box/track_fragment_random_access.rb +54 -0
- data/lib/bmff/box/track_group.rb +12 -0
- data/lib/bmff/box/track_group_type.rb +12 -0
- data/lib/bmff/box/track_header.rb +36 -0
- data/lib/bmff/box/track_reference.rb +12 -0
- data/lib/bmff/box/track_reference_type.rb +15 -0
- data/lib/bmff/box/track_run.rb +31 -0
- data/lib/bmff/box/track_selection.rb +16 -0
- data/lib/bmff/box/unknown.rb +5 -0
- data/lib/bmff/box/uri.rb +12 -0
- data/lib/bmff/box/uri_init.rb +15 -0
- data/lib/bmff/box/uri_meta_sample_entry.rb +24 -0
- data/lib/bmff/box/user_data.rb +12 -0
- data/lib/bmff/box/video_media_header.rb +13 -0
- data/lib/bmff/box/visual_sample_entry.rb +37 -0
- data/lib/bmff/box/xml_meta_data_sample_entry.rb +19 -0
- data/lib/bmff/box.rb +115 -0
- data/lib/bmff/file_container.rb +20 -0
- data/lib/bmff/version.rb +3 -0
- data/lib/bmff.rb +7 -0
- data/test/bmff/box/test_audio_sample_entry.rb +46 -0
- data/test/bmff/box/test_base.rb +37 -0
- data/test/bmff/box/test_bit_rate.rb +30 -0
- data/test/bmff/box/test_chunk_large_offset.rb +35 -0
- data/test/bmff/box/test_chunk_offset.rb +35 -0
- data/test/bmff/box/test_clean_aperture.rb +40 -0
- data/test/bmff/box/test_colour_information.rb +73 -0
- data/test/bmff/box/test_compact_sample_size.rb +99 -0
- data/test/bmff/box/test_composition_offset.rb +64 -0
- data/test/bmff/box/test_composition_to_decode.rb +38 -0
- data/test/bmff/box/test_copyright.rb +55 -0
- data/test/bmff/box/test_data_entry_url.rb +30 -0
- data/test/bmff/box/test_data_entry_urn.rb +32 -0
- data/test/bmff/box/test_data_information.rb +26 -0
- data/test/bmff/box/test_data_reference.rb +58 -0
- data/test/bmff/box/test_degradation_priority.rb +62 -0
- data/test/bmff/box/test_edit.rb +26 -0
- data/test/bmff/box/test_edit_list.rb +72 -0
- data/test/bmff/box/test_file_type.rb +30 -0
- data/test/bmff/box/test_free_space.rb +42 -0
- data/test/bmff/box/test_handler.rb +67 -0
- data/test/bmff/box/test_hint_media_header.rb +38 -0
- data/test/bmff/box/test_hint_sample_entry.rb +38 -0
- data/test/bmff/box/test_level_assignment.rb +50 -0
- data/test/bmff/box/test_media.rb +26 -0
- data/test/bmff/box/test_media_data.rb +25 -0
- data/test/bmff/box/test_media_header.rb +72 -0
- data/test/bmff/box/test_media_information.rb +26 -0
- data/test/bmff/box/test_movie.rb +26 -0
- data/test/bmff/box/test_movie_extends.rb +26 -0
- data/test/bmff/box/test_movie_extends_header.rb +52 -0
- data/test/bmff/box/test_movie_fragment.rb +26 -0
- data/test/bmff/box/test_movie_fragment_header.rb +30 -0
- data/test/bmff/box/test_movie_fragment_random_access.rb +26 -0
- data/test/bmff/box/test_movie_fragment_random_access_offset.rb +30 -0
- data/test/bmff/box/test_movie_header.rb +110 -0
- data/test/bmff/box/test_null_media_header.rb +28 -0
- data/test/bmff/box/test_padding_bits.rb +38 -0
- data/test/bmff/box/test_pixel_aspect_ratio.rb +28 -0
- data/test/bmff/box/test_progressive_download_info.rb +36 -0
- data/test/bmff/box/test_sample_auxiliary_information_offsets.rb +94 -0
- data/test/bmff/box/test_sample_auxiliary_information_sizes.rb +70 -0
- data/test/bmff/box/test_sample_dependency_type.rb +70 -0
- data/test/bmff/box/test_sample_description.rb +355 -0
- data/test/bmff/box/test_sample_size.rb +61 -0
- data/test/bmff/box/test_sample_table.rb +26 -0
- data/test/bmff/box/test_sample_to_chunk.rb +39 -0
- data/test/bmff/box/test_shadow_sync_sample.rb +36 -0
- data/test/bmff/box/test_sound_media_header.rb +32 -0
- data/test/bmff/box/test_sub_sample_information.rb +90 -0
- data/test/bmff/box/test_sync_sample.rb +34 -0
- data/test/bmff/box/test_text_meta_data_sample_entry.rb +49 -0
- data/test/bmff/box/test_time_to_sample.rb +36 -0
- data/test/bmff/box/test_track.rb +26 -0
- data/test/bmff/box/test_track_extends.rb +38 -0
- data/test/bmff/box/test_track_fragment.rb +26 -0
- data/test/bmff/box/test_track_fragment_base_media_decode_time.rb +52 -0
- data/test/bmff/box/test_track_fragment_header.rb +200 -0
- data/test/bmff/box/test_track_fragment_random_access.rb +96 -0
- data/test/bmff/box/test_track_group.rb +26 -0
- data/test/bmff/box/test_track_group_type.rb +30 -0
- data/test/bmff/box/test_track_header.rb +118 -0
- data/test/bmff/box/test_track_reference.rb +26 -0
- data/test/bmff/box/test_track_reference_type.rb +100 -0
- data/test/bmff/box/test_track_run.rb +282 -0
- data/test/bmff/box/test_track_selection.rb +33 -0
- data/test/bmff/box/test_uri.rb +30 -0
- data/test/bmff/box/test_uri_init.rb +32 -0
- data/test/bmff/box/test_uri_meta_sample_entry.rb +74 -0
- data/test/bmff/box/test_user_data.rb +26 -0
- data/test/bmff/box/test_video_media_header.rb +34 -0
- data/test/bmff/box/test_visual_sample_entry.rb +95 -0
- data/test/bmff/box/test_xml_meta_data_sample_entry.rb +51 -0
- data/test/bmff/test_binary_accessor.rb +805 -0
- data/test/bmff/test_file_container.rb +58 -0
- data/test/minitest_helper.rb +7 -0
- metadata +323 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
# vim: set expandtab tabstop=2 shiftwidth=2 softtabstop=2 autoindent:
|
|
3
|
+
|
|
4
|
+
require_relative '../../minitest_helper'
|
|
5
|
+
require 'bmff/box'
|
|
6
|
+
require 'stringio'
|
|
7
|
+
|
|
8
|
+
class TestBMFFBoxTrackSelection < MiniTest::Unit::TestCase
|
|
9
|
+
def test_parse
|
|
10
|
+
io = StringIO.new("", "r+:ascii-8bit")
|
|
11
|
+
io.extend(BMFF::BinaryAccessor)
|
|
12
|
+
io.write_uint32(0)
|
|
13
|
+
io.write_ascii("tsel")
|
|
14
|
+
io.write_uint8(0) # version
|
|
15
|
+
io.write_uint24(0) # flags
|
|
16
|
+
io.write_int32(0) # switch_group
|
|
17
|
+
io.write_ascii("tesc") # attribute_list
|
|
18
|
+
io.write_ascii("cdec") # attribute_list
|
|
19
|
+
size = io.pos
|
|
20
|
+
io.pos = 0
|
|
21
|
+
io.write_uint32(size)
|
|
22
|
+
io.pos = 0
|
|
23
|
+
|
|
24
|
+
box = BMFF::Box.get_box(io, nil)
|
|
25
|
+
assert_instance_of(BMFF::Box::TrackSelection, box)
|
|
26
|
+
assert_equal(size, box.actual_size)
|
|
27
|
+
assert_equal("tsel", box.type)
|
|
28
|
+
assert_equal(0, box.version)
|
|
29
|
+
assert_equal(0, box.flags)
|
|
30
|
+
assert_equal(0, box.switch_group)
|
|
31
|
+
assert_equal(["tesc", "cdec"], box.attribute_list)
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
# vim: set expandtab tabstop=2 shiftwidth=2 softtabstop=2 autoindent:
|
|
3
|
+
|
|
4
|
+
require_relative '../../minitest_helper'
|
|
5
|
+
require 'bmff/box'
|
|
6
|
+
require 'stringio'
|
|
7
|
+
|
|
8
|
+
class TestBMFFBoxURI < MiniTest::Unit::TestCase
|
|
9
|
+
def test_parse
|
|
10
|
+
io = StringIO.new("", "r+:ascii-8bit")
|
|
11
|
+
io.extend(BMFF::BinaryAccessor)
|
|
12
|
+
io.write_uint32(0)
|
|
13
|
+
io.write_ascii("uri ")
|
|
14
|
+
io.write_uint8(0) # version
|
|
15
|
+
io.write_uint24(0) # flags
|
|
16
|
+
io.write_null_terminated_string("http://example.com/") # the_uri
|
|
17
|
+
size = io.pos
|
|
18
|
+
io.pos = 0
|
|
19
|
+
io.write_uint32(size)
|
|
20
|
+
io.pos = 0
|
|
21
|
+
|
|
22
|
+
box = BMFF::Box.get_box(io, nil)
|
|
23
|
+
assert_instance_of(BMFF::Box::URI, box)
|
|
24
|
+
assert_equal(size, box.actual_size)
|
|
25
|
+
assert_equal("uri ", box.type)
|
|
26
|
+
assert_equal(0, box.version)
|
|
27
|
+
assert_equal(0, box.flags)
|
|
28
|
+
assert_equal("http://example.com/", box.the_uri)
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
# vim: set expandtab tabstop=2 shiftwidth=2 softtabstop=2 autoindent:
|
|
3
|
+
|
|
4
|
+
require_relative '../../minitest_helper'
|
|
5
|
+
require 'bmff/box'
|
|
6
|
+
require 'stringio'
|
|
7
|
+
|
|
8
|
+
class TestBMFFBoxURIInit < MiniTest::Unit::TestCase
|
|
9
|
+
def test_parse
|
|
10
|
+
io = StringIO.new("", "r+:ascii-8bit")
|
|
11
|
+
io.extend(BMFF::BinaryAccessor)
|
|
12
|
+
io.write_uint32(0)
|
|
13
|
+
io.write_ascii("uriI")
|
|
14
|
+
io.write_uint8(0) # version
|
|
15
|
+
io.write_uint24(0) # flags
|
|
16
|
+
io.write_uint8(0) # uri_initialization_data
|
|
17
|
+
io.write_uint8(1) # uri_initialization_data
|
|
18
|
+
io.write_uint8(2) # uri_initialization_data
|
|
19
|
+
size = io.pos
|
|
20
|
+
io.pos = 0
|
|
21
|
+
io.write_uint32(size)
|
|
22
|
+
io.pos = 0
|
|
23
|
+
|
|
24
|
+
box = BMFF::Box.get_box(io, nil)
|
|
25
|
+
assert_instance_of(BMFF::Box::URIInit, box)
|
|
26
|
+
assert_equal(size, box.actual_size)
|
|
27
|
+
assert_equal("uriI", box.type)
|
|
28
|
+
assert_equal(0, box.version)
|
|
29
|
+
assert_equal(0, box.flags)
|
|
30
|
+
assert_equal([0, 1, 2], box.uri_initialization_data)
|
|
31
|
+
end
|
|
32
|
+
end
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
# vim: set expandtab tabstop=2 shiftwidth=2 softtabstop=2 autoindent:
|
|
3
|
+
|
|
4
|
+
require_relative '../../minitest_helper'
|
|
5
|
+
require 'bmff/box'
|
|
6
|
+
require 'stringio'
|
|
7
|
+
|
|
8
|
+
class TestBMFFBoxURIMetaSampleEntry < MiniTest::Unit::TestCase
|
|
9
|
+
def test_parse
|
|
10
|
+
io = StringIO.new("", "r+:ascii-8bit")
|
|
11
|
+
io.extend(BMFF::BinaryAccessor)
|
|
12
|
+
io.write_uint32(0)
|
|
13
|
+
io.write_ascii("urim")
|
|
14
|
+
io.write_uint8(0) # reserved1
|
|
15
|
+
io.write_uint8(0) # reserved1
|
|
16
|
+
io.write_uint8(0) # reserved1
|
|
17
|
+
io.write_uint8(0) # reserved1
|
|
18
|
+
io.write_uint8(0) # reserved1
|
|
19
|
+
io.write_uint8(0) # reserved1
|
|
20
|
+
io.write_uint16(0) # data_reference_index
|
|
21
|
+
# uri_box
|
|
22
|
+
io.write_uint32(32)
|
|
23
|
+
io.write_ascii("uri ")
|
|
24
|
+
io.write_uint8(0) # version
|
|
25
|
+
io.write_uint24(0) # flags
|
|
26
|
+
io.write_null_terminated_string("http://example.com/") # the_uri
|
|
27
|
+
# uri_init_box
|
|
28
|
+
io.write_uint32(15)
|
|
29
|
+
io.write_ascii("uriI")
|
|
30
|
+
io.write_uint8(0) # version
|
|
31
|
+
io.write_uint24(0) # flags
|
|
32
|
+
io.write_uint8(0) # uri_initialization_data
|
|
33
|
+
io.write_uint8(1) # uri_initialization_data
|
|
34
|
+
io.write_uint8(2) # uri_initialization_data
|
|
35
|
+
# mpeg4_bit_rate_box
|
|
36
|
+
io.write_uint32(20)
|
|
37
|
+
io.write_ascii("btrt")
|
|
38
|
+
io.write_uint32(65535) # buffer_size_db
|
|
39
|
+
io.write_uint32(1000000) # max_bitrate
|
|
40
|
+
io.write_uint32(500000) # avg_bitrate
|
|
41
|
+
size = io.pos
|
|
42
|
+
io.pos = 0
|
|
43
|
+
io.write_uint32(size)
|
|
44
|
+
io.pos = 0
|
|
45
|
+
|
|
46
|
+
box = BMFF::Box.get_box(io, nil)
|
|
47
|
+
assert_instance_of(BMFF::Box::URIMetaSampleEntry, box)
|
|
48
|
+
assert_equal(size, box.actual_size)
|
|
49
|
+
assert_equal("urim", box.type)
|
|
50
|
+
assert_equal([0, 0, 0, 0, 0, 0], box.reserved1)
|
|
51
|
+
assert_equal(0, box.data_reference_index)
|
|
52
|
+
|
|
53
|
+
assert_instance_of(BMFF::Box::URI, box.uri_box)
|
|
54
|
+
assert_equal(32, box.uri_box.actual_size)
|
|
55
|
+
assert_equal("uri ", box.uri_box.type)
|
|
56
|
+
assert_equal(0, box.uri_box.version)
|
|
57
|
+
assert_equal(0, box.uri_box.flags)
|
|
58
|
+
assert_equal("http://example.com/", box.uri_box.the_uri)
|
|
59
|
+
|
|
60
|
+
assert_instance_of(BMFF::Box::URIInit, box.uri_init_box)
|
|
61
|
+
assert_equal(15, box.uri_init_box.actual_size)
|
|
62
|
+
assert_equal("uriI", box.uri_init_box.type)
|
|
63
|
+
assert_equal(0, box.uri_init_box.version)
|
|
64
|
+
assert_equal(0, box.uri_init_box.flags)
|
|
65
|
+
assert_equal([0, 1, 2], box.uri_init_box.uri_initialization_data)
|
|
66
|
+
|
|
67
|
+
assert_instance_of(BMFF::Box::BitRate, box.mpeg4_bit_rate_box)
|
|
68
|
+
assert_equal(20, box.mpeg4_bit_rate_box.actual_size)
|
|
69
|
+
assert_equal("btrt", box.mpeg4_bit_rate_box.type)
|
|
70
|
+
assert_equal(65535, box.mpeg4_bit_rate_box.buffer_size_db)
|
|
71
|
+
assert_equal(1000000, box.mpeg4_bit_rate_box.max_bitrate)
|
|
72
|
+
assert_equal(500000, box.mpeg4_bit_rate_box.avg_bitrate)
|
|
73
|
+
end
|
|
74
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
# vim: set expandtab tabstop=2 shiftwidth=2 softtabstop=2 autoindent:
|
|
3
|
+
|
|
4
|
+
require_relative '../../minitest_helper'
|
|
5
|
+
require 'bmff/box'
|
|
6
|
+
require 'stringio'
|
|
7
|
+
|
|
8
|
+
class TestBMFFBoxUserData < MiniTest::Unit::TestCase
|
|
9
|
+
def test_parse
|
|
10
|
+
io = StringIO.new("", "r+:ascii-8bit")
|
|
11
|
+
io.extend(BMFF::BinaryAccessor)
|
|
12
|
+
io.write_uint32(0)
|
|
13
|
+
io.write_ascii("udta")
|
|
14
|
+
size = io.pos
|
|
15
|
+
io.pos = 0
|
|
16
|
+
io.write_uint32(size)
|
|
17
|
+
io.pos = 0
|
|
18
|
+
|
|
19
|
+
box = BMFF::Box.get_box(io, nil)
|
|
20
|
+
assert_instance_of(BMFF::Box::UserData, box)
|
|
21
|
+
assert_equal(size, box.actual_size)
|
|
22
|
+
assert_equal("udta", box.type)
|
|
23
|
+
assert_equal([], box.children)
|
|
24
|
+
assert(box.container?)
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
# vim: set expandtab tabstop=2 shiftwidth=2 softtabstop=2 autoindent:
|
|
3
|
+
|
|
4
|
+
require_relative '../../minitest_helper'
|
|
5
|
+
require 'bmff/box'
|
|
6
|
+
require 'stringio'
|
|
7
|
+
|
|
8
|
+
class TestBMFFBoxVideoMediaHeader < MiniTest::Unit::TestCase
|
|
9
|
+
def test_parse
|
|
10
|
+
io = StringIO.new("", "r+:ascii-8bit")
|
|
11
|
+
io.extend(BMFF::BinaryAccessor)
|
|
12
|
+
io.write_uint32(0)
|
|
13
|
+
io.write_ascii("vmhd")
|
|
14
|
+
io.write_uint8(0) # version
|
|
15
|
+
io.write_uint24(1) # flags
|
|
16
|
+
io.write_uint16(0) # graphicsmode
|
|
17
|
+
io.write_uint16(0) # opcolor
|
|
18
|
+
io.write_uint16(0) # opcolor
|
|
19
|
+
io.write_uint16(0) # opcolor
|
|
20
|
+
size = io.pos
|
|
21
|
+
io.pos = 0
|
|
22
|
+
io.write_uint32(size)
|
|
23
|
+
io.pos = 0
|
|
24
|
+
|
|
25
|
+
box = BMFF::Box.get_box(io, nil)
|
|
26
|
+
assert_instance_of(BMFF::Box::VideoMediaHeader, box)
|
|
27
|
+
assert_equal(size, box.actual_size)
|
|
28
|
+
assert_equal("vmhd", box.type)
|
|
29
|
+
assert_equal(0, box.version)
|
|
30
|
+
assert_equal(1, box.flags)
|
|
31
|
+
assert_equal(0, box.graphicsmode)
|
|
32
|
+
assert_equal([0, 0, 0], box.opcolor)
|
|
33
|
+
end
|
|
34
|
+
end
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
# vim: set expandtab tabstop=2 shiftwidth=2 softtabstop=2 autoindent:
|
|
3
|
+
|
|
4
|
+
require_relative '../../minitest_helper'
|
|
5
|
+
require 'bmff/box'
|
|
6
|
+
require 'stringio'
|
|
7
|
+
|
|
8
|
+
class TestBMFFBoxVisualSampleEntry < MiniTest::Unit::TestCase
|
|
9
|
+
def test_parse
|
|
10
|
+
io = StringIO.new("", "r+:ascii-8bit")
|
|
11
|
+
io.extend(BMFF::BinaryAccessor)
|
|
12
|
+
io.write_uint32(0)
|
|
13
|
+
io.write_ascii("mp4v")
|
|
14
|
+
io.write_uint8(0) # reserved1
|
|
15
|
+
io.write_uint8(0) # reserved1
|
|
16
|
+
io.write_uint8(0) # reserved1
|
|
17
|
+
io.write_uint8(0) # reserved1
|
|
18
|
+
io.write_uint8(0) # reserved1
|
|
19
|
+
io.write_uint8(0) # reserved1
|
|
20
|
+
io.write_uint16(1) # data_reference_index
|
|
21
|
+
io.write_uint16(0) # pre_defined1
|
|
22
|
+
io.write_uint16(0) # reserved2
|
|
23
|
+
io.write_uint32(0) # pre_defined2
|
|
24
|
+
io.write_uint32(0) # pre_defined2
|
|
25
|
+
io.write_uint32(0) # pre_defined2
|
|
26
|
+
io.write_uint16(320) # width
|
|
27
|
+
io.write_uint16(180) # height
|
|
28
|
+
io.write_uint32(4718592) # horizresolution
|
|
29
|
+
io.write_uint32(4718592) # vertresolution
|
|
30
|
+
io.write_uint32(0) # reserved3
|
|
31
|
+
io.write_uint16(1) # frame_count
|
|
32
|
+
io.write_byte("\x04") # compressorname (size)
|
|
33
|
+
io.write_ascii("bmff") # compressorname
|
|
34
|
+
io.write_byte("\x00" * 27) # compressorname (padding)
|
|
35
|
+
io.write_uint16(24) # depth
|
|
36
|
+
io.write_int16(-1) # pre_defined3
|
|
37
|
+
# clean_aperture_box
|
|
38
|
+
io.write_uint32(40)
|
|
39
|
+
io.write_ascii("clap")
|
|
40
|
+
io.write_uint32(160) # clean_aperture_width_n
|
|
41
|
+
io.write_uint32(161) # clean_aperture_width_d
|
|
42
|
+
io.write_uint32(90) # clean_aperture_height_n
|
|
43
|
+
io.write_uint32(91) # clean_aperture_height_d
|
|
44
|
+
io.write_uint32(320) # horiz_off_n
|
|
45
|
+
io.write_uint32(321) # horiz_off_d
|
|
46
|
+
io.write_uint32(180) # vert_off_n
|
|
47
|
+
io.write_uint32(181) # vert_off_d
|
|
48
|
+
# pixel_aspect_ratio_box
|
|
49
|
+
io.write_uint32(16)
|
|
50
|
+
io.write_ascii("pasp")
|
|
51
|
+
io.write_uint32(16) # h_spacing
|
|
52
|
+
io.write_uint32(9) # v_spacing
|
|
53
|
+
size = io.pos
|
|
54
|
+
io.pos = 0
|
|
55
|
+
io.write_uint32(size)
|
|
56
|
+
io.pos = 0
|
|
57
|
+
|
|
58
|
+
box = BMFF::Box.get_box(io, nil, BMFF::Box::VisualSampleEntry)
|
|
59
|
+
assert_instance_of(BMFF::Box::VisualSampleEntry, box)
|
|
60
|
+
assert_equal(size, box.actual_size)
|
|
61
|
+
assert_equal("mp4v", box.type)
|
|
62
|
+
assert_equal([0, 0, 0, 0, 0, 0], box.reserved1)
|
|
63
|
+
assert_equal(1, box.data_reference_index)
|
|
64
|
+
assert_equal(0, box.pre_defined1)
|
|
65
|
+
assert_equal(0, box.reserved2)
|
|
66
|
+
assert_equal([0, 0, 0], box.pre_defined2)
|
|
67
|
+
assert_equal(320, box.width)
|
|
68
|
+
assert_equal(180, box.height)
|
|
69
|
+
assert_equal(4718592, box.horizresolution)
|
|
70
|
+
assert_equal(4718592, box.vertresolution)
|
|
71
|
+
assert_equal(0, box.reserved3)
|
|
72
|
+
assert_equal(1, box.frame_count)
|
|
73
|
+
assert_equal("bmff", box.compressorname)
|
|
74
|
+
assert_equal(24, box.depth)
|
|
75
|
+
assert_equal(-1, box.pre_defined3)
|
|
76
|
+
|
|
77
|
+
assert_instance_of(BMFF::Box::CleanAperture, box.clean_aperture_box)
|
|
78
|
+
assert_equal(40, box.clean_aperture_box.actual_size)
|
|
79
|
+
assert_equal("clap", box.clean_aperture_box.type)
|
|
80
|
+
assert_equal(160, box.clean_aperture_box.clean_aperture_width_n)
|
|
81
|
+
assert_equal(161, box.clean_aperture_box.clean_aperture_width_d)
|
|
82
|
+
assert_equal(90, box.clean_aperture_box.clean_aperture_height_n)
|
|
83
|
+
assert_equal(91, box.clean_aperture_box.clean_aperture_height_d)
|
|
84
|
+
assert_equal(320, box.clean_aperture_box.horiz_off_n)
|
|
85
|
+
assert_equal(321, box.clean_aperture_box.horiz_off_d)
|
|
86
|
+
assert_equal(180, box.clean_aperture_box.vert_off_n)
|
|
87
|
+
assert_equal(181, box.clean_aperture_box.vert_off_d)
|
|
88
|
+
|
|
89
|
+
assert_instance_of(BMFF::Box::PixelAspectRatio, box.pixel_aspect_ratio_box)
|
|
90
|
+
assert_equal(16, box.pixel_aspect_ratio_box.actual_size)
|
|
91
|
+
assert_equal("pasp", box.pixel_aspect_ratio_box.type)
|
|
92
|
+
assert_equal(16, box.pixel_aspect_ratio_box.h_spacing)
|
|
93
|
+
assert_equal(9, box.pixel_aspect_ratio_box.v_spacing)
|
|
94
|
+
end
|
|
95
|
+
end
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
# vim: set expandtab tabstop=2 shiftwidth=2 softtabstop=2 autoindent:
|
|
3
|
+
|
|
4
|
+
require_relative '../../minitest_helper'
|
|
5
|
+
require 'bmff/box'
|
|
6
|
+
require 'stringio'
|
|
7
|
+
|
|
8
|
+
class TestBMFFBoxXMLMetaDataSampleEntry < MiniTest::Unit::TestCase
|
|
9
|
+
def test_parse
|
|
10
|
+
io = StringIO.new("", "r+:ascii-8bit")
|
|
11
|
+
io.extend(BMFF::BinaryAccessor)
|
|
12
|
+
io.write_uint32(0)
|
|
13
|
+
io.write_ascii("metx")
|
|
14
|
+
io.write_uint8(0) # reserved1
|
|
15
|
+
io.write_uint8(0) # reserved1
|
|
16
|
+
io.write_uint8(0) # reserved1
|
|
17
|
+
io.write_uint8(0) # reserved1
|
|
18
|
+
io.write_uint8(0) # reserved1
|
|
19
|
+
io.write_uint8(0) # reserved1
|
|
20
|
+
io.write_uint16(0) # data_reference_index
|
|
21
|
+
io.write_null_terminated_string("application/zip") # content_encoding
|
|
22
|
+
io.write_null_terminated_string("NS") # namespace
|
|
23
|
+
io.write_null_terminated_string("http://example.com/schema") # schema_location
|
|
24
|
+
# bit_rate_box
|
|
25
|
+
io.write_uint32(20)
|
|
26
|
+
io.write_ascii("btrt")
|
|
27
|
+
io.write_uint32(65535) # buffer_size_db
|
|
28
|
+
io.write_uint32(1000000) # max_bitrate
|
|
29
|
+
io.write_uint32(500000) # avg_bitrate
|
|
30
|
+
size = io.pos
|
|
31
|
+
io.pos = 0
|
|
32
|
+
io.write_uint32(size)
|
|
33
|
+
io.pos = 0
|
|
34
|
+
|
|
35
|
+
box = BMFF::Box.get_box(io, nil)
|
|
36
|
+
assert_instance_of(BMFF::Box::XMLMetaDataSampleEntry, box)
|
|
37
|
+
assert_equal(size, box.actual_size)
|
|
38
|
+
assert_equal("metx", box.type)
|
|
39
|
+
assert_equal([0, 0, 0, 0, 0, 0], box.reserved1)
|
|
40
|
+
assert_equal(0, box.data_reference_index)
|
|
41
|
+
assert_equal("application/zip", box.content_encoding)
|
|
42
|
+
assert_equal("NS", box.namespace)
|
|
43
|
+
assert_equal("http://example.com/schema", box.schema_location)
|
|
44
|
+
assert_instance_of(BMFF::Box::BitRate, box.bit_rate_box)
|
|
45
|
+
assert_equal(20, box.bit_rate_box.actual_size)
|
|
46
|
+
assert_equal("btrt", box.bit_rate_box.type)
|
|
47
|
+
assert_equal(65535, box.bit_rate_box.buffer_size_db)
|
|
48
|
+
assert_equal(1000000, box.bit_rate_box.max_bitrate)
|
|
49
|
+
assert_equal(500000, box.bit_rate_box.avg_bitrate)
|
|
50
|
+
end
|
|
51
|
+
end
|