Display a tag-level overview for the generated FLVs
List the type and size of each tag of the input FLVs on the muxing helper page.
Showing
2 changed files
with
59 additions
and
4 deletions
... | @@ -157,6 +157,10 @@ nav a:hover { | ... | @@ -157,6 +157,10 @@ nav a:hover { |
157 | Author's custom styles | 157 | Author's custom styles |
158 | ========================================================================== */ | 158 | ========================================================================== */ |
159 | 159 | ||
160 | section { | ||
161 | clear: both; | ||
162 | } | ||
163 | |||
160 | form label { | 164 | form label { |
161 | display: block; | 165 | display: block; |
162 | } | 166 | } | ... | ... |
... | @@ -55,6 +55,19 @@ | ... | @@ -55,6 +55,19 @@ |
55 | </form> | 55 | </form> |
56 | </section> | 56 | </section> |
57 | <section> | 57 | <section> |
58 | <h2>Tag Comparison</h2> | ||
59 | <div class="result-wrapper"> | ||
60 | <h3>videojs-contrib-hls</h3> | ||
61 | <ol class="vjs-tags"> | ||
62 | </ol> | ||
63 | </div> | ||
64 | <div class="result-wrapper"> | ||
65 | <h3>Working</h3> | ||
66 | <ol class="working-tags"> | ||
67 | </ol> | ||
68 | </div> | ||
69 | </section> | ||
70 | <section> | ||
58 | <h2>Results</h2> | 71 | <h2>Results</h2> |
59 | <div class="result-wrapper"> | 72 | <div class="result-wrapper"> |
60 | <h3>videojs-contrib-hls</h3> | 73 | <h3>videojs-contrib-hls</h3> |
... | @@ -98,15 +111,27 @@ | ... | @@ -98,15 +111,27 @@ |
98 | var inputs = document.getElementById('inputs'), | 111 | var inputs = document.getElementById('inputs'), |
99 | original = document.getElementById('original'), | 112 | original = document.getElementById('original'), |
100 | working = document.getElementById('working'), | 113 | working = document.getElementById('working'), |
114 | |||
115 | vjsTags = document.querySelector('.vjs-tags'), | ||
116 | workingTags = document.querySelector('.working-tags'), | ||
117 | |||
101 | vjsOutput = document.querySelector('.vjs-hls-output'), | 118 | vjsOutput = document.querySelector('.vjs-hls-output'), |
102 | workingOutput = document.querySelector('.working-output'); | 119 | workingOutput = document.querySelector('.working-output'), |
120 | |||
121 | tagTypes = { | ||
122 | 0x08: 'audio', | ||
123 | 0x09: 'video', | ||
124 | 0x12: 'metadata' | ||
125 | }; | ||
103 | 126 | ||
104 | original.addEventListener('change', function() { | 127 | original.addEventListener('change', function() { |
105 | var reader = new FileReader(); | 128 | var reader = new FileReader(); |
106 | reader.addEventListener('loadend', function() { | 129 | reader.addEventListener('loadend', function() { |
107 | var parser = new videojs.hls.SegmentParser(), | 130 | var parser = new videojs.hls.SegmentParser(), |
108 | tags = [parser.getFlvHeader()], | 131 | tags = [parser.getFlvHeader()], |
132 | tag, | ||
109 | hex, | 133 | hex, |
134 | li, | ||
110 | byteLength = 0, | 135 | byteLength = 0, |
111 | data, | 136 | data, |
112 | i, | 137 | i, |
... | @@ -115,7 +140,11 @@ | ... | @@ -115,7 +140,11 @@ |
115 | parser.parseSegmentBinaryData(new Uint8Array(reader.result)); | 140 | parser.parseSegmentBinaryData(new Uint8Array(reader.result)); |
116 | // collect all the tags | 141 | // collect all the tags |
117 | while (parser.tagsAvailable()) { | 142 | while (parser.tagsAvailable()) { |
118 | tags.push(parser.getNextTag().bytes); | 143 | tag = parser.getNextTag(); |
144 | tags.push(tag.bytes); | ||
145 | li = document.createElement('li'); | ||
146 | li.innerHTML = tagTypes[tag.bytes[0]] + ': ' + tag.bytes.byteLength + 'B'; | ||
147 | vjsTags.appendChild(li); | ||
119 | } | 148 | } |
120 | // create a uint8array for the entire segment and copy everything over | 149 | // create a uint8array for the entire segment and copy everything over |
121 | i = tags.length; | 150 | i = tags.length; |
... | @@ -142,8 +171,30 @@ | ... | @@ -142,8 +171,30 @@ |
142 | working.addEventListener('change', function() { | 171 | working.addEventListener('change', function() { |
143 | var reader = new FileReader(); | 172 | var reader = new FileReader(); |
144 | reader.addEventListener('loadend', function() { | 173 | reader.addEventListener('loadend', function() { |
145 | var hex = '<pre>'; | 174 | var hex = '<pre>', |
146 | hex += videojs.hls.utils.hexDump(new Uint8Array(reader.result)); | 175 | bytes = new Uint8Array(reader.result), |
176 | i = 9, // header | ||
177 | dataSize, | ||
178 | li; | ||
179 | |||
180 | // traverse the tags | ||
181 | i += 4; // previous tag size | ||
182 | while (i < bytes.byteLength) { | ||
183 | dataSize = bytes[i + 1] << 16; | ||
184 | dataSize |= bytes[i + 2] << 8; | ||
185 | dataSize |= bytes[i + 3]; | ||
186 | dataSize += 11; | ||
187 | |||
188 | li = document.createElement('li'); | ||
189 | li.innerHTML = tagTypes[bytes[i]] + ': ' + dataSize + 'B'; | ||
190 | workingTags.appendChild(li); | ||
191 | |||
192 | i += dataSize; // tag size | ||
193 | i += 4; // previous tag size | ||
194 | } | ||
195 | |||
196 | // output the hex dump | ||
197 | hex += videojs.hls.utils.hexDump(bytes); | ||
147 | hex += '</pre>'; | 198 | hex += '</pre>'; |
148 | workingOutput.innerHTML = hex; | 199 | workingOutput.innerHTML = hex; |
149 | }); | 200 | }); | ... | ... |
-
Please register or sign in to post a comment