🎥 Make videos programmatically with React
Update parse-webm-header.ts
Jonny Burger56af340d57fc
diff --git a/packages/video-parser/src/boxes/webm/parse-webm-header.ts b/packages/video-parser/src/boxes/webm/parse-webm-header.tsindex 9137d2eaa5..0e098eb3e9 100644--- a/packages/video-parser/src/boxes/webm/parse-webm-header.ts+++ b/packages/video-parser/src/boxes/webm/parse-webm-header.ts@@ -1,5 +1,6 @@import {getArrayBufferIterator} from '../../read-and-increment-offset';+// Parsing according to https://darkcoding.net/software/reading-mediarecorders-webm-opus-output/export const parseWebmHeader = (data: ArrayBuffer) => {const counter = getArrayBufferIterator(data, 4);const length = counter.getEBML();@@ -7,4 +8,16 @@ export const parseWebmHeader = (data: ArrayBuffer) => {if (length !== 31) {throw new Error(`Expected header length 31, got ${length}`);}++ // Discard header for now+ counter.discard(31);++ const magic = counter.getSlice(4);+ // "We find 18 53 80 67."+ // We are done with the generic EBML fields and now come to the Matroska fields.+ if (new Uint8Array(magic).join() !== [0x18, 0x53, 0x80, 0x67].join()) {+ throw new Error(+ 'Expected "EBML" magic fields, got ' + new Uint8Array(magic).join(),+ );+ }};