The `matroska` package provides a Node.js library for parsing Matroska (MKV), WebM, and EBML streams and files. It is a fork of `node-ebml`, emphasizing fast parsing with an option for incomplete metadata extraction (info tags and attachments) or a complete parse of the entire document structure. The current stable version is 2.2.5, with its last publish approximately three years ago, indicating a maintenance-focused release cadence rather than active feature development. Recent updates have included fixes for `cueClusterPosition` problems and improved resilience when handling invalid MKV formats, alongside stream support introduced in older versions. Its key differentiators include its speed and the ability to process potentially malformed Matroska files, making it suitable for applications that require robust media metadata extraction in a Node.js environment.
npm install matroskaVerified import paths — ran on the pinned version, not inferred.
This code demonstrates how to perform a complete parse of a Matroska (MKV) file from a URL using the `Decoder` class and its `parse` method, logging the full document structure and extracting some common info tags.
Ensure your project is configured for CommonJS, or use dynamic `import()` in an async context if running in an ESM module (`await import('matroska')`). Consider `createRequire` for specific scenarios in ESM files.For full access to all Matroska elements, including media blocks, instantiate `new matroska.Decoder()` and call its `parse()` method. For just metadata like duration, muxing app, etc., use the static `Decoder.parseInfoTagsAndAttachments()`.
Monitor the GitHub repository for activity. If long-term maintenance or new features are critical, evaluate alternative Matroska/EBML parsing libraries or be prepared to contribute to the project.
Wrap the `parse` and `parseInfoTagsAndAttachments` methods with `util.promisify` or manually create a Promise-based wrapper to use them with `async/await` syntax for cleaner asynchronous code.
Either rename your file to use a `.cjs` extension, remove `"type": "module"` from your `package.json` to revert to CommonJS default, or use dynamic `import()` (`const matroska = await import('matroska');`).Ensure you are using `const { Decoder } = require('matroska');` or `const matroska = require('matroska'); const decoder = new matroska.Decoder();` to correctly access the `Decoder` class. Double-check for typos.Implement a queueing mechanism or process files in batches to control concurrency. Ensure that file descriptors are properly closed after parsing is complete. On Linux, you might temporarily increase the `ulimit -n` for development.
No dependency data recorded yet.