Registry / serialization / codem-isoboxer

codem-isoboxer

JSON →
library0.3.10jsnpmunverified

codem-isoboxer is a lightweight JavaScript parser for MP4 (MPEG-4, ISOBMFF) files and boxes, primarily designed for browser environments. Its current stable version is 0.3.10, with releases occurring as features and bug fixes are integrated, rather than on a fixed schedule. The library's core purpose is to provide a small, fast, and efficient way to extract metadata and validate ISOBMFF segments, making it suitable for integration into player frameworks or for analyzing media files. Key differentiators include its focus on minimal overhead, direct manipulation of ArrayBuffers and DataViews, and specific support for boxes relevant to emerging standards like MPEG-DASH (e.g., `emsg` boxes) and HLS using fragmented MP4, as well as timed text overlays. It offers a relatively raw interface, providing box structures with minimal abstraction, allowing developers fine-grained control over parsing and data access.

npm install codem-isoboxer
INSTALL
IMPORT
SIG · CODEM-ISOBOXER
C
codem-isoboxer
serializationjavascriptv0.3.10
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

ISOBoxer
// ISOBoxer is available globally after <script src="iso_boxer.min.js"></script>
import ISOBoxer from 'codem-isoboxer'; const ISOBoxer = require('codem-isoboxer');
This library is designed for browser environments and exposes `ISOBoxer` as a global variable. It does not provide ESM or CommonJS module exports for direct `import` or `require`.
ISOBoxer.parseBuffer
const parsedFile = ISOBoxer.parseBuffer(arrayBuffer);
import { parseBuffer } from 'codem-isoboxer';
`parseBuffer` is a method of the global `ISOBoxer` object, not a named export. It expects an `ArrayBuffer` as input.
ParsedFile.prototype.fetch
const ftypBox = parsedFile.fetch('ftyp');
import { fetch } from 'codem-isoboxer';
`fetch` and `fetchAll` are methods available on the `parsedFile` object returned by `ISOBoxer.parseBuffer`, used for traversing the box structure.

This quickstart demonstrates how to parse an `ArrayBuffer` containing ISOBMFF data using `ISOBoxer.parseBuffer` and then how to retrieve specific boxes using `fetch` and `fetchAll` methods from the resulting `ParsedFile` object. It includes a mock for `ISOBoxer` to make the code runnable outside a browser environment for testing purposes, but in a real browser, `ISOBoxer` is a global.

// Simulate an ArrayBuffer for demonstration (a minimal ftyp box) // In a real scenario, this buffer would come from XHR, FileReader, etc. const buffer = new ArrayBuffer(16); const view = new DataView(buffer); view.setUint32(0, 16, false); // Box size: 16 bytes view.setUint32(4, 0x66747970, false); // Box type: "ftyp" view.setUint32(8, 0x69736f6d, false); // Major brand: "isom" view.setUint32(12, 0x00000001, false); // Minor version: 1 // In a browser, ISOBoxer would be globally available after including the script: // <script src="iso_boxer.min.js"></script> // For this runnable quickstart demonstration, we'll mock ISOBoxer // In your actual browser code, remove this mock and assume ISOBoxer is global. const ISOBoxer = (() => { const parseBuffer = (arrayBuffer) => { const dv = new DataView(arrayBuffer); const boxes = []; let offset = 0; while (offset < arrayBuffer.byteLength) { const size = dv.getUint32(offset, false); const typeCode = dv.getUint32(offset + 4, false); const type = String.fromCharCode( (typeCode >> 24) & 0xFF, (typeCode >> 16) & 0xFF, (typeCode >> 8) & 0xFF, typeCode & 0xFF ); // In a real parse, more box-specific data would be extracted boxes.push({ _type: type, _size: size, _offset: offset }); offset += size; if (size === 0) break; // Avoid infinite loop for malformed box } return { boxes: boxes, fetch: (boxType) => boxes.find(b => b._type === boxType), fetchAll: (boxType) => boxes.filter(b => b._type === boxType) }; }; return { parseBuffer }; })(); const parsedFile = ISOBoxer.parseBuffer(buffer); console.log('All parsed boxes:', parsedFile.boxes); // Expected: [{ _type: 'ftyp', _size: 16, _offset: 0 }] const ftypBox = parsedFile.fetch('ftyp'); if (ftypBox) { console.log('Fetched ftyp box:', ftypBox); } const allMdatBoxes = parsedFile.fetchAll('mdat'); if (allMdatBoxes.length === 0) { console.log('No mdat boxes found in this example buffer.'); }
Debug
Known issues
gotchacodem-isoboxer is designed for browser environments and exposes its API as a global `ISOBoxer` object. It does not provide CommonJS or ESM module exports, meaning standard `import` or `require` statements will not work without a build step that specifically bundles or adapts it.
fix
Include the library via a `<script>` tag in your HTML (`<script src="path/to/iso_boxer.min.js"></script>`) and access its functionality through the global `ISOBoxer` object.
affects: >=0.1.0
gotchaThe library supports a limited, though extensible, set of ISOBMFF boxes. If you need to parse a box type not listed in the README or Wiki, you will need to implement a custom parser for it and extend the library.
fix
Consult the 'Box Support' wiki page on GitHub. For unsupported boxes, refer to the `src/parsers` directory in the source code to understand how to add new box parsers.
affects: >=0.1.0
gotchacodem-isoboxer provides a relatively raw interface to ISOBMFF data. It makes minimal assumptions about file validity and performs limited handling of complex data types, often returning raw buffer views or basic parsed values. Developers must handle further interpretation of specific box contents.
fix
Be prepared to implement additional logic to interpret the specific data structures within the parsed boxes, especially for more complex or application-specific fields. Understand the ISOBMFF specification for the boxes you are parsing.
affects: >=0.1.0
gotchaThe library explicitly requires `ArrayBuffer` and `DataView` support, and optionally `TextDecoder`, which are standard modern browser APIs. It is not intended for Node.js environments without polyfills or specific browser-emulating setups.
fix
Ensure your target browser environment supports these APIs. For Node.js usage, consider alternative libraries or integrate polyfills for the required browser APIs.
affects: >=0.1.0
Errors
Common errors & fixes
ReferenceError: ISOBoxer is not defined
The `ISOBoxer` global object was not loaded or is not in scope.
fix
Ensure the `iso_boxer.min.js` script is correctly included in your HTML before attempting to use `ISOBoxer`. Verify the script path and that it's loaded synchronously or before your script executes.
TypeError: ISOBoxer.parseBuffer is not a function
The `ISOBoxer` object exists, but `parseBuffer` is not a property or is not a function. This often indicates incorrect loading or a corrupt script.
fix
Check the network tab in your browser's developer tools to confirm `iso_boxer.min.js` loaded successfully without errors. Ensure no other script is overwriting the `ISOBoxer` global variable.
TypeError: Cannot read properties of undefined (reading 'byteLength')
The `parseBuffer` function was called with an argument that is not a valid `ArrayBuffer` or a compatible object.
fix
Ensure you are passing a valid `ArrayBuffer` instance to `ISOBoxer.parseBuffer`. Common mistakes include passing a `Blob`, `File` object, or `Uint8Array` directly without converting to `ArrayBuffer` first (e.g., `await blob.arrayBuffer()`).
Upgrade
Version history
0.3.10latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
21 hits · last 30 days
node
16
OpenAI (training)
1
Resources
codem-isoboxer — npm install codem-isoboxer · libregistry