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,13 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
# vim: set expandtab tabstop=2 shiftwidth=2 softtabstop=2 autoindent:
|
|
3
|
+
|
|
4
|
+
class BMFF::Box::VideoMediaHeader < BMFF::Box::Full
|
|
5
|
+
attr_accessor :graphicsmode, :opcolor
|
|
6
|
+
register_box "vmhd"
|
|
7
|
+
|
|
8
|
+
def parse_data
|
|
9
|
+
super
|
|
10
|
+
@graphicsmode = io.get_uint16
|
|
11
|
+
@opcolor = [io.get_uint16, io.get_uint16, io.get_uint16]
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
# vim: set expandtab tabstop=2 shiftwidth=2 softtabstop=2 autoindent:
|
|
3
|
+
|
|
4
|
+
class BMFF::Box::VisualSampleEntry < BMFF::Box::SampleEntry
|
|
5
|
+
attr_accessor :pre_defined1, :reserved2, :pre_defined2, :width, :height, :horizresolution, :vertresolution,
|
|
6
|
+
:reserved3, :frame_count, :compressorname, :depth, :pre_defined3,
|
|
7
|
+
:clean_aperture_box, :pixel_aspect_ratio_box
|
|
8
|
+
include(BMFF::Box::Container)
|
|
9
|
+
|
|
10
|
+
def parse_data
|
|
11
|
+
super
|
|
12
|
+
@pre_defined1 = io.get_uint16
|
|
13
|
+
@reserved2 = io.get_uint16
|
|
14
|
+
@pre_defined2 = [io.get_uint32, io.get_uint32, io.get_uint32]
|
|
15
|
+
@width = io.get_uint16
|
|
16
|
+
@height = io.get_uint16
|
|
17
|
+
@horizresolution = io.get_uint32
|
|
18
|
+
@vertresolution = io.get_uint32
|
|
19
|
+
@reserved3 = io.get_uint32
|
|
20
|
+
@frame_count = io.get_uint16
|
|
21
|
+
compressorname_size = io.get_uint8 & 0x1F
|
|
22
|
+
compressorname_buffer = io.get_ascii(31)
|
|
23
|
+
@compressorname = compressorname_buffer[0, compressorname_size]
|
|
24
|
+
@depth = io.get_uint16
|
|
25
|
+
@pre_defined3 = io.get_int16
|
|
26
|
+
until eob?
|
|
27
|
+
box = BMFF::Box.get_box(io, self)
|
|
28
|
+
add_child box
|
|
29
|
+
case box
|
|
30
|
+
when BMFF::Box::CleanAperture
|
|
31
|
+
@clean_aperture_box = box
|
|
32
|
+
when BMFF::Box::PixelAspectRatio
|
|
33
|
+
@pixel_aspect_ratio_box = box
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
# vim: set expandtab tabstop=2 shiftwidth=2 softtabstop=2 autoindent:
|
|
3
|
+
|
|
4
|
+
class BMFF::Box::XMLMetaDataSampleEntry < BMFF::Box::MetaDataSampleEntry
|
|
5
|
+
attr_accessor :content_encoding, :namespace, :schema_location, :bit_rate_box
|
|
6
|
+
register_box "metx"
|
|
7
|
+
include(BMFF::Box::Container)
|
|
8
|
+
|
|
9
|
+
def parse_data
|
|
10
|
+
super
|
|
11
|
+
@content_encoding = io.get_null_terminated_string unless eob?
|
|
12
|
+
@namespace = io.get_null_terminated_string unless eob?
|
|
13
|
+
@schema_location = io.get_null_terminated_string unless eob?
|
|
14
|
+
unless eob?
|
|
15
|
+
@bit_rate_box = BMFF::Box.get_box(io, self, BMFF::Box::BitRate)
|
|
16
|
+
add_child @bit_rate_box
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
data/lib/bmff/box.rb
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
# vim: set expandtab tabstop=2 shiftwidth=2 softtabstop=2 autoindent:
|
|
3
|
+
|
|
4
|
+
module BMFF::Box; end
|
|
5
|
+
|
|
6
|
+
require "bmff/box/map"
|
|
7
|
+
require "bmff/box/base"
|
|
8
|
+
require "bmff/box/full"
|
|
9
|
+
require "bmff/box/container"
|
|
10
|
+
require "bmff/box/unknown"
|
|
11
|
+
|
|
12
|
+
require "bmff/box/file_type"
|
|
13
|
+
require "bmff/box/media_data"
|
|
14
|
+
require "bmff/box/free_space"
|
|
15
|
+
require "bmff/box/progressive_download_info"
|
|
16
|
+
require "bmff/box/movie"
|
|
17
|
+
require "bmff/box/movie_header"
|
|
18
|
+
require "bmff/box/track"
|
|
19
|
+
require "bmff/box/track_header"
|
|
20
|
+
require "bmff/box/track_reference"
|
|
21
|
+
require "bmff/box/track_reference_type"
|
|
22
|
+
require "bmff/box/track_group"
|
|
23
|
+
require "bmff/box/track_group_type"
|
|
24
|
+
require "bmff/box/media"
|
|
25
|
+
require "bmff/box/media_header"
|
|
26
|
+
require "bmff/box/handler"
|
|
27
|
+
require "bmff/box/media_information"
|
|
28
|
+
require "bmff/box/video_media_header"
|
|
29
|
+
require "bmff/box/sound_media_header"
|
|
30
|
+
require "bmff/box/hint_media_header"
|
|
31
|
+
require "bmff/box/null_media_header"
|
|
32
|
+
require "bmff/box/sample_table"
|
|
33
|
+
require "bmff/box/sample_entry"
|
|
34
|
+
require "bmff/box/hint_sample_entry"
|
|
35
|
+
require "bmff/box/bit_rate"
|
|
36
|
+
require "bmff/box/meta_data_sample_entry"
|
|
37
|
+
require "bmff/box/xml_meta_data_sample_entry"
|
|
38
|
+
require "bmff/box/text_meta_data_sample_entry"
|
|
39
|
+
require "bmff/box/uri"
|
|
40
|
+
require "bmff/box/uri_init"
|
|
41
|
+
require "bmff/box/uri_meta_sample_entry"
|
|
42
|
+
require "bmff/box/pixel_aspect_ratio"
|
|
43
|
+
require "bmff/box/clean_aperture"
|
|
44
|
+
require "bmff/box/colour_information"
|
|
45
|
+
require "bmff/box/visual_sample_entry"
|
|
46
|
+
require "bmff/box/audio_sample_entry"
|
|
47
|
+
require "bmff/box/sample_description"
|
|
48
|
+
require "bmff/box/sample_size"
|
|
49
|
+
require "bmff/box/compact_sample_size"
|
|
50
|
+
require "bmff/box/degradation_priority"
|
|
51
|
+
require "bmff/box/time_to_sample"
|
|
52
|
+
require "bmff/box/composition_offset"
|
|
53
|
+
require "bmff/box/composition_to_decode"
|
|
54
|
+
require "bmff/box/sync_sample"
|
|
55
|
+
require "bmff/box/shadow_sync_sample"
|
|
56
|
+
require "bmff/box/sample_dependency_type"
|
|
57
|
+
require "bmff/box/edit"
|
|
58
|
+
require "bmff/box/edit_list"
|
|
59
|
+
require "bmff/box/data_information"
|
|
60
|
+
require "bmff/box/data_entry_url"
|
|
61
|
+
require "bmff/box/data_entry_urn"
|
|
62
|
+
require "bmff/box/data_reference"
|
|
63
|
+
require "bmff/box/sample_to_chunk"
|
|
64
|
+
require "bmff/box/chunk_offset"
|
|
65
|
+
require "bmff/box/chunk_large_offset"
|
|
66
|
+
require "bmff/box/padding_bits"
|
|
67
|
+
require "bmff/box/sub_sample_information"
|
|
68
|
+
require "bmff/box/sample_auxiliary_information_sizes"
|
|
69
|
+
require "bmff/box/sample_auxiliary_information_offsets"
|
|
70
|
+
require "bmff/box/movie_extends"
|
|
71
|
+
require "bmff/box/movie_extends_header"
|
|
72
|
+
require "bmff/box/track_extends"
|
|
73
|
+
require "bmff/box/movie_fragment"
|
|
74
|
+
require "bmff/box/movie_fragment_header"
|
|
75
|
+
require "bmff/box/track_fragment"
|
|
76
|
+
require "bmff/box/track_fragment_header"
|
|
77
|
+
require "bmff/box/track_run"
|
|
78
|
+
require "bmff/box/movie_fragment_random_access"
|
|
79
|
+
require "bmff/box/track_fragment_random_access"
|
|
80
|
+
require "bmff/box/movie_fragment_random_access_offset"
|
|
81
|
+
require "bmff/box/track_fragment_base_media_decode_time"
|
|
82
|
+
require "bmff/box/level_assignment"
|
|
83
|
+
require "bmff/box/user_data"
|
|
84
|
+
require "bmff/box/copyright"
|
|
85
|
+
require "bmff/box/track_selection"
|
|
86
|
+
|
|
87
|
+
module BMFF::Box
|
|
88
|
+
def self.get_box(io, parent, box_class = nil)
|
|
89
|
+
offset = io.pos
|
|
90
|
+
size = io.get_uint32
|
|
91
|
+
type = io.get_ascii(4)
|
|
92
|
+
|
|
93
|
+
if box_class
|
|
94
|
+
klass = box_class
|
|
95
|
+
else
|
|
96
|
+
klass = get_box_class(type)
|
|
97
|
+
end
|
|
98
|
+
box = klass.new
|
|
99
|
+
box.io = io
|
|
100
|
+
box.offset = offset
|
|
101
|
+
box.parent = parent
|
|
102
|
+
box.size = size
|
|
103
|
+
box.type = type
|
|
104
|
+
|
|
105
|
+
box.parse
|
|
106
|
+
return box
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
def self.get_box_class(type)
|
|
110
|
+
if klass = Map.get_box_class(type)
|
|
111
|
+
return klass
|
|
112
|
+
end
|
|
113
|
+
return BMFF::Box::Unknown
|
|
114
|
+
end
|
|
115
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
# vim: set expandtab tabstop=2 shiftwidth=2 softtabstop=2 autoindent:
|
|
3
|
+
|
|
4
|
+
class BMFF::FileContainer
|
|
5
|
+
include(BMFF::Box::Container)
|
|
6
|
+
alias :boxes :children
|
|
7
|
+
|
|
8
|
+
def initialize(io)
|
|
9
|
+
@source_stream = io
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def self.parse(io)
|
|
13
|
+
io.extend(BMFF::BinaryAccessor)
|
|
14
|
+
container = self.new(io)
|
|
15
|
+
until io.eof?
|
|
16
|
+
container.add_child BMFF::Box.get_box(io, container)
|
|
17
|
+
end
|
|
18
|
+
return container
|
|
19
|
+
end
|
|
20
|
+
end
|
data/lib/bmff/version.rb
ADDED
data/lib/bmff.rb
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
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 TestBMFFBoxAudioSampleEntry < 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("mp4a")
|
|
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_uint32(0) # reserved2
|
|
22
|
+
io.write_uint32(0) # reserved2
|
|
23
|
+
io.write_uint16(2) # channelcount
|
|
24
|
+
io.write_uint16(16) # samplesize
|
|
25
|
+
io.write_uint16(0) # pre_defined
|
|
26
|
+
io.write_uint16(0) # reserved3
|
|
27
|
+
io.write_uint32(2890137600) # samplerate
|
|
28
|
+
size = io.pos
|
|
29
|
+
io.pos = 0
|
|
30
|
+
io.write_uint32(size)
|
|
31
|
+
io.pos = 0
|
|
32
|
+
|
|
33
|
+
box = BMFF::Box.get_box(io, nil, BMFF::Box::AudioSampleEntry)
|
|
34
|
+
assert_instance_of(BMFF::Box::AudioSampleEntry, box)
|
|
35
|
+
assert_equal(size, box.actual_size)
|
|
36
|
+
assert_equal("mp4a", box.type)
|
|
37
|
+
assert_equal([0, 0, 0, 0, 0, 0], box.reserved1)
|
|
38
|
+
assert_equal(1, box.data_reference_index)
|
|
39
|
+
assert_equal([0, 0], box.reserved2)
|
|
40
|
+
assert_equal(2, box.channelcount)
|
|
41
|
+
assert_equal(16, box.samplesize)
|
|
42
|
+
assert_equal(0, box.pre_defined)
|
|
43
|
+
assert_equal(0, box.reserved3)
|
|
44
|
+
assert_equal(2890137600, box.samplerate)
|
|
45
|
+
end
|
|
46
|
+
end
|
|
@@ -0,0 +1,37 @@
|
|
|
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 TestBMFFBoxBase < MiniTest::Unit::TestCase
|
|
9
|
+
def test_parse_largesize
|
|
10
|
+
io = StringIO.new("", "r+:ascii-8bit")
|
|
11
|
+
io.extend(BMFF::BinaryAccessor)
|
|
12
|
+
io.write_uint32(1)
|
|
13
|
+
io.write_ascii("xxxx")
|
|
14
|
+
io.write_uint64(16)
|
|
15
|
+
io.pos = 0
|
|
16
|
+
|
|
17
|
+
box = BMFF::Box.get_box(io, nil)
|
|
18
|
+
assert_equal(16, box.actual_size)
|
|
19
|
+
assert_equal(1, box.size)
|
|
20
|
+
assert_equal(16, box.largesize)
|
|
21
|
+
assert_equal("xxxx", box.type)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def test_parse_eof_size
|
|
25
|
+
io = StringIO.new("", "r+:ascii-8bit")
|
|
26
|
+
io.extend(BMFF::BinaryAccessor)
|
|
27
|
+
io.write_uint32(0)
|
|
28
|
+
io.write_ascii("xxxx")
|
|
29
|
+
io.pos = 0
|
|
30
|
+
|
|
31
|
+
box = BMFF::Box.get_box(io, nil)
|
|
32
|
+
assert_nil(box.actual_size)
|
|
33
|
+
assert_equal(0, box.size)
|
|
34
|
+
assert_nil(box.largesize)
|
|
35
|
+
assert_equal("xxxx", box.type)
|
|
36
|
+
end
|
|
37
|
+
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 TestBMFFBoxBitRate < 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("btrt")
|
|
14
|
+
io.write_uint32(65535) # buffer_size_db
|
|
15
|
+
io.write_uint32(1000000) # max_bitrate
|
|
16
|
+
io.write_uint32(500000) # avg_bitrate
|
|
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::BitRate, box)
|
|
24
|
+
assert_equal(size, box.actual_size)
|
|
25
|
+
assert_equal("btrt", box.type)
|
|
26
|
+
assert_equal(65535, box.buffer_size_db)
|
|
27
|
+
assert_equal(1000000, box.max_bitrate)
|
|
28
|
+
assert_equal(500000, box.avg_bitrate)
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -0,0 +1,35 @@
|
|
|
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 TestBMFFBoxChunkLargeOffset < 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("co64")
|
|
14
|
+
io.write_uint8(0) # version
|
|
15
|
+
io.write_uint24(0) # flags
|
|
16
|
+
io.write_uint32(3) # entry_count
|
|
17
|
+
# entry
|
|
18
|
+
3.times do |i|
|
|
19
|
+
io.write_uint64(i) # chunk_offset
|
|
20
|
+
end
|
|
21
|
+
size = io.pos
|
|
22
|
+
io.pos = 0
|
|
23
|
+
io.write_uint32(size)
|
|
24
|
+
io.pos = 0
|
|
25
|
+
|
|
26
|
+
box = BMFF::Box.get_box(io, nil)
|
|
27
|
+
assert_instance_of(BMFF::Box::ChunkLargeOffset, box)
|
|
28
|
+
assert_equal(size, box.actual_size)
|
|
29
|
+
assert_equal("co64", box.type)
|
|
30
|
+
assert_equal(0, box.version)
|
|
31
|
+
assert_equal(0, box.flags)
|
|
32
|
+
assert_equal(3, box.entry_count)
|
|
33
|
+
assert_equal([0, 1, 2], box.chunk_offset)
|
|
34
|
+
end
|
|
35
|
+
end
|
|
@@ -0,0 +1,35 @@
|
|
|
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 TestBMFFBoxChunkOffset < 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("stco")
|
|
14
|
+
io.write_uint8(0) # version
|
|
15
|
+
io.write_uint24(0) # flags
|
|
16
|
+
io.write_uint32(3) # entry_count
|
|
17
|
+
# entry
|
|
18
|
+
3.times do |i|
|
|
19
|
+
io.write_uint32(i) # chunk_offset
|
|
20
|
+
end
|
|
21
|
+
size = io.pos
|
|
22
|
+
io.pos = 0
|
|
23
|
+
io.write_uint32(size)
|
|
24
|
+
io.pos = 0
|
|
25
|
+
|
|
26
|
+
box = BMFF::Box.get_box(io, nil)
|
|
27
|
+
assert_instance_of(BMFF::Box::ChunkOffset, box)
|
|
28
|
+
assert_equal(size, box.actual_size)
|
|
29
|
+
assert_equal("stco", box.type)
|
|
30
|
+
assert_equal(0, box.version)
|
|
31
|
+
assert_equal(0, box.flags)
|
|
32
|
+
assert_equal(3, box.entry_count)
|
|
33
|
+
assert_equal([0, 1, 2], box.chunk_offset)
|
|
34
|
+
end
|
|
35
|
+
end
|
|
@@ -0,0 +1,40 @@
|
|
|
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 TestBMFFBoxCleanAperture < 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("clap")
|
|
14
|
+
io.write_uint32(160) # clean_aperture_width_n
|
|
15
|
+
io.write_uint32(161) # clean_aperture_width_d
|
|
16
|
+
io.write_uint32(90) # clean_aperture_height_n
|
|
17
|
+
io.write_uint32(91) # clean_aperture_height_d
|
|
18
|
+
io.write_uint32(320) # horiz_off_n
|
|
19
|
+
io.write_uint32(321) # horiz_off_d
|
|
20
|
+
io.write_uint32(180) # vert_off_n
|
|
21
|
+
io.write_uint32(181) # vert_off_d
|
|
22
|
+
size = io.pos
|
|
23
|
+
io.pos = 0
|
|
24
|
+
io.write_uint32(size)
|
|
25
|
+
io.pos = 0
|
|
26
|
+
|
|
27
|
+
box = BMFF::Box.get_box(io, nil)
|
|
28
|
+
assert_instance_of(BMFF::Box::CleanAperture, box)
|
|
29
|
+
assert_equal(size, box.actual_size)
|
|
30
|
+
assert_equal("clap", box.type)
|
|
31
|
+
assert_equal(160, box.clean_aperture_width_n)
|
|
32
|
+
assert_equal(161, box.clean_aperture_width_d)
|
|
33
|
+
assert_equal(90, box.clean_aperture_height_n)
|
|
34
|
+
assert_equal(91, box.clean_aperture_height_d)
|
|
35
|
+
assert_equal(320, box.horiz_off_n)
|
|
36
|
+
assert_equal(321, box.horiz_off_d)
|
|
37
|
+
assert_equal(180, box.vert_off_n)
|
|
38
|
+
assert_equal(181, box.vert_off_d)
|
|
39
|
+
end
|
|
40
|
+
end
|
|
@@ -0,0 +1,73 @@
|
|
|
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 TestBMFFBoxColourInformation < MiniTest::Unit::TestCase
|
|
9
|
+
def test_parse_nclx
|
|
10
|
+
io = StringIO.new("", "r+:ascii-8bit")
|
|
11
|
+
io.extend(BMFF::BinaryAccessor)
|
|
12
|
+
io.write_uint32(0)
|
|
13
|
+
io.write_ascii("colr")
|
|
14
|
+
io.write_ascii("nclx") # colour_type
|
|
15
|
+
io.write_uint16(1) # colour_primaries
|
|
16
|
+
io.write_uint16(2) # transfer_characteristics
|
|
17
|
+
io.write_uint16(3) # matrix_coefficients
|
|
18
|
+
io.write_uint8(128) # full_range_flag reserved
|
|
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::ColourInformation, box)
|
|
26
|
+
assert_equal(size, box.actual_size)
|
|
27
|
+
assert_equal("colr", box.type)
|
|
28
|
+
assert_equal("nclx", box.colour_type)
|
|
29
|
+
assert_equal(1, box.colour_primaries)
|
|
30
|
+
assert_equal(2, box.transfer_characteristics)
|
|
31
|
+
assert_equal(3, box.matrix_coefficients)
|
|
32
|
+
assert(box.full_range_flag)
|
|
33
|
+
assert_equal(0, box.reserved1)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def test_parse_ricc
|
|
37
|
+
io = StringIO.new("", "r+:ascii-8bit")
|
|
38
|
+
io.extend(BMFF::BinaryAccessor)
|
|
39
|
+
io.write_uint32(0)
|
|
40
|
+
io.write_ascii("colr")
|
|
41
|
+
io.write_ascii("rICC") # colour_type
|
|
42
|
+
size = io.pos
|
|
43
|
+
io.pos = 0
|
|
44
|
+
io.write_uint32(size)
|
|
45
|
+
io.pos = 0
|
|
46
|
+
|
|
47
|
+
box = BMFF::Box.get_box(io, nil)
|
|
48
|
+
assert_instance_of(BMFF::Box::ColourInformation, box)
|
|
49
|
+
assert_equal(size, box.actual_size)
|
|
50
|
+
assert_equal("colr", box.type)
|
|
51
|
+
assert_equal("rICC", box.colour_type)
|
|
52
|
+
assert_equal(:restricted, box.icc_profile)
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def test_parse_prof
|
|
56
|
+
io = StringIO.new("", "r+:ascii-8bit")
|
|
57
|
+
io.extend(BMFF::BinaryAccessor)
|
|
58
|
+
io.write_uint32(0)
|
|
59
|
+
io.write_ascii("colr")
|
|
60
|
+
io.write_ascii("prof") # colour_type
|
|
61
|
+
size = io.pos
|
|
62
|
+
io.pos = 0
|
|
63
|
+
io.write_uint32(size)
|
|
64
|
+
io.pos = 0
|
|
65
|
+
|
|
66
|
+
box = BMFF::Box.get_box(io, nil)
|
|
67
|
+
assert_instance_of(BMFF::Box::ColourInformation, box)
|
|
68
|
+
assert_equal(size, box.actual_size)
|
|
69
|
+
assert_equal("colr", box.type)
|
|
70
|
+
assert_equal("prof", box.colour_type)
|
|
71
|
+
assert_equal(:unrestricted, box.icc_profile)
|
|
72
|
+
end
|
|
73
|
+
end
|
|
@@ -0,0 +1,99 @@
|
|
|
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 TestBMFFBoxCompactSampleSize < MiniTest::Unit::TestCase
|
|
9
|
+
def test_parse_filed_size_4
|
|
10
|
+
io = StringIO.new("", "r+:ascii-8bit")
|
|
11
|
+
io.extend(BMFF::BinaryAccessor)
|
|
12
|
+
io.write_uint32(0)
|
|
13
|
+
io.write_ascii("stz2")
|
|
14
|
+
io.write_uint8(0) # version
|
|
15
|
+
io.write_uint24(0) # flags
|
|
16
|
+
io.write_uint24(0) # reserved1
|
|
17
|
+
io.write_uint8(4) # field_size
|
|
18
|
+
io.write_uint32(7) # sample_count
|
|
19
|
+
io.write_uint8(18) # entry_size 1 + 2
|
|
20
|
+
io.write_uint8(165) # entry_size 10 + 5
|
|
21
|
+
io.write_uint8(15) # entry_size 0 + 15
|
|
22
|
+
io.write_uint8(240) # entry_size 15 + 0 padding
|
|
23
|
+
size = io.pos
|
|
24
|
+
io.pos = 0
|
|
25
|
+
io.write_uint32(size)
|
|
26
|
+
io.pos = 0
|
|
27
|
+
|
|
28
|
+
box = BMFF::Box.get_box(io, nil)
|
|
29
|
+
assert_instance_of(BMFF::Box::CompactSampleSize, box)
|
|
30
|
+
assert_equal(size, box.actual_size)
|
|
31
|
+
assert_equal("stz2", box.type)
|
|
32
|
+
assert_equal(0, box.version)
|
|
33
|
+
assert_equal(0, box.flags)
|
|
34
|
+
assert_equal(0, box.reserved1)
|
|
35
|
+
assert_equal(4, box.field_size)
|
|
36
|
+
assert_equal(7, box.sample_count)
|
|
37
|
+
assert_equal([1, 2, 10, 5, 0, 15, 15], box.entry_size)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def test_parse_filed_size_8
|
|
41
|
+
io = StringIO.new("", "r+:ascii-8bit")
|
|
42
|
+
io.extend(BMFF::BinaryAccessor)
|
|
43
|
+
io.write_uint32(0)
|
|
44
|
+
io.write_ascii("stz2")
|
|
45
|
+
io.write_uint8(0) # version
|
|
46
|
+
io.write_uint24(0) # flags
|
|
47
|
+
io.write_uint24(0) # reserved1
|
|
48
|
+
io.write_uint8(8) # field_size
|
|
49
|
+
io.write_uint32(3) # sample_count
|
|
50
|
+
3.times do |i|
|
|
51
|
+
io.write_uint8(i) # entry_size
|
|
52
|
+
end
|
|
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)
|
|
59
|
+
assert_instance_of(BMFF::Box::CompactSampleSize, box)
|
|
60
|
+
assert_equal(size, box.actual_size)
|
|
61
|
+
assert_equal("stz2", box.type)
|
|
62
|
+
assert_equal(0, box.version)
|
|
63
|
+
assert_equal(0, box.flags)
|
|
64
|
+
assert_equal(0, box.reserved1)
|
|
65
|
+
assert_equal(8, box.field_size)
|
|
66
|
+
assert_equal(3, box.sample_count)
|
|
67
|
+
assert_equal([0, 1, 2], box.entry_size)
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def test_parse_filed_size_16
|
|
71
|
+
io = StringIO.new("", "r+:ascii-8bit")
|
|
72
|
+
io.extend(BMFF::BinaryAccessor)
|
|
73
|
+
io.write_uint32(0)
|
|
74
|
+
io.write_ascii("stz2")
|
|
75
|
+
io.write_uint8(0) # version
|
|
76
|
+
io.write_uint24(0) # flags
|
|
77
|
+
io.write_uint24(0) # reserved1
|
|
78
|
+
io.write_uint8(16) # field_size
|
|
79
|
+
io.write_uint32(3) # sample_count
|
|
80
|
+
3.times do |i|
|
|
81
|
+
io.write_uint16(i) # entry_size
|
|
82
|
+
end
|
|
83
|
+
size = io.pos
|
|
84
|
+
io.pos = 0
|
|
85
|
+
io.write_uint32(size)
|
|
86
|
+
io.pos = 0
|
|
87
|
+
|
|
88
|
+
box = BMFF::Box.get_box(io, nil)
|
|
89
|
+
assert_instance_of(BMFF::Box::CompactSampleSize, box)
|
|
90
|
+
assert_equal(size, box.actual_size)
|
|
91
|
+
assert_equal("stz2", box.type)
|
|
92
|
+
assert_equal(0, box.version)
|
|
93
|
+
assert_equal(0, box.flags)
|
|
94
|
+
assert_equal(0, box.reserved1)
|
|
95
|
+
assert_equal(16, box.field_size)
|
|
96
|
+
assert_equal(3, box.sample_count)
|
|
97
|
+
assert_equal([0, 1, 2], box.entry_size)
|
|
98
|
+
end
|
|
99
|
+
end
|
|
@@ -0,0 +1,64 @@
|
|
|
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 TestBMFFBoxCompositionOffset < MiniTest::Unit::TestCase
|
|
9
|
+
def test_parse_v0
|
|
10
|
+
io = StringIO.new("", "r+:ascii-8bit")
|
|
11
|
+
io.extend(BMFF::BinaryAccessor)
|
|
12
|
+
io.write_uint32(0)
|
|
13
|
+
io.write_ascii("ctts")
|
|
14
|
+
io.write_uint8(0) # version
|
|
15
|
+
io.write_uint24(0) # flags
|
|
16
|
+
io.write_uint32(3) # entry_count
|
|
17
|
+
3.times do |i|
|
|
18
|
+
io.write_uint32(i) # sample_count
|
|
19
|
+
io.write_uint32(10 + i) # sample_offset
|
|
20
|
+
end
|
|
21
|
+
size = io.pos
|
|
22
|
+
io.pos = 0
|
|
23
|
+
io.write_uint32(size)
|
|
24
|
+
io.pos = 0
|
|
25
|
+
|
|
26
|
+
box = BMFF::Box.get_box(io, nil)
|
|
27
|
+
assert_instance_of(BMFF::Box::CompositionOffset, box)
|
|
28
|
+
assert_equal(size, box.actual_size)
|
|
29
|
+
assert_equal("ctts", box.type)
|
|
30
|
+
assert_equal(0, box.version)
|
|
31
|
+
assert_equal(0, box.flags)
|
|
32
|
+
assert_equal(3, box.entry_count)
|
|
33
|
+
assert_equal([0, 1, 2], box.sample_count)
|
|
34
|
+
assert_equal([10, 11, 12], box.sample_offset)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def test_parse_v1
|
|
38
|
+
io = StringIO.new("", "r+:ascii-8bit")
|
|
39
|
+
io.extend(BMFF::BinaryAccessor)
|
|
40
|
+
io.write_uint32(0)
|
|
41
|
+
io.write_ascii("ctts")
|
|
42
|
+
io.write_uint8(1) # version
|
|
43
|
+
io.write_uint24(0) # flags
|
|
44
|
+
io.write_uint32(3) # entry_count
|
|
45
|
+
3.times do |i|
|
|
46
|
+
io.write_uint32(i) # sample_count
|
|
47
|
+
io.write_int32(10 + i) # sample_offset
|
|
48
|
+
end
|
|
49
|
+
size = io.pos
|
|
50
|
+
io.pos = 0
|
|
51
|
+
io.write_uint32(size)
|
|
52
|
+
io.pos = 0
|
|
53
|
+
|
|
54
|
+
box = BMFF::Box.get_box(io, nil)
|
|
55
|
+
assert_instance_of(BMFF::Box::CompositionOffset, box)
|
|
56
|
+
assert_equal(size, box.actual_size)
|
|
57
|
+
assert_equal("ctts", box.type)
|
|
58
|
+
assert_equal(1, box.version)
|
|
59
|
+
assert_equal(0, box.flags)
|
|
60
|
+
assert_equal(3, box.entry_count)
|
|
61
|
+
assert_equal([0, 1, 2], box.sample_count)
|
|
62
|
+
assert_equal([10, 11, 12], box.sample_offset)
|
|
63
|
+
end
|
|
64
|
+
end
|