@ludovicm67/webm-tools
Advanced tools
Comparing version 0.3.8 to 0.4.0
# @ludovicm67/webm-tools | ||
## 0.4.0 | ||
### Minor Changes | ||
- 121731a: Rewrite the parser, and fix the timestamps on the fly | ||
### Patch Changes | ||
- dc49223: Display timestamp for Block and SimpleBlock, and create a new `display` cli command | ||
## 0.3.8 | ||
@@ -4,0 +14,0 @@ |
@@ -6,2 +6,3 @@ // @ts-check | ||
import merge from './merge.js' | ||
import display from './display.js' | ||
@@ -31,2 +32,8 @@ const program = new Command() | ||
program.command('display') | ||
.description('Display information about a WebM file') | ||
.argument('<file name>', 'path to the WebM file') | ||
.option('--debug', 'show debug information') | ||
.action(display) | ||
program.parse(process.argv) |
@@ -5,3 +5,4 @@ // @ts-check | ||
import { readFile } from 'node:fs/promises' | ||
import { decode, resetDecoder, displayDecodedElements } from '../lib/ebml.js' | ||
import { decode } from '../lib/decoder.js' | ||
import { displayDecodedElements } from '../lib/tools.js' | ||
@@ -31,6 +32,3 @@ /** | ||
const firstChunk = await readFile(firstChunkPath) | ||
resetDecoder({ | ||
debug: false | ||
}) | ||
const { decoded } = decode(firstChunk) | ||
const { decoded } = decode(/** @type {import('@ludovicm67/media-tools-utils').Buffer} **/(/** @type {unknown} **/ (firstChunk))) | ||
if (debug) { | ||
@@ -51,6 +49,3 @@ console.info('\nDecoded first chunk:') | ||
const newFile = Buffer.concat([firstChunk, ...otherChunks]) | ||
resetDecoder({ | ||
debug: false | ||
}) | ||
const { decoded: newFileDecoded } = decode(newFile) | ||
const { decoded: newFileDecoded } = decode(/** @type {import('@ludovicm67/media-tools-utils').Buffer} **/(/** @type {unknown} **/ (newFile))) | ||
if (debug) { | ||
@@ -57,0 +52,0 @@ console.info('\nDecoded merged chunk (if it looks great, the merge was sucessful):') |
@@ -30,3 +30,2 @@ # We provide a CLI to run some tools | ||
Options: | ||
-V, --version output the version number | ||
-h, --help display help for command | ||
@@ -36,4 +35,4 @@ | ||
fix [options] <previous chunk> <broken chunk> Fix a WebM file using the previous chunk | ||
merge [options] <first chunk> <second chunk> [other chunks...] Merge WebM chunks together. The first chunk should | ||
be a sane chunk. | ||
merge [options] <first chunk> <second chunk> [other chunks...] Merge WebM chunks together. The first chunk should be a sane chunk. | ||
display [options] <file name> Display information about a WebM file | ||
help [command] display help for command | ||
@@ -78,1 +77,16 @@ ``` | ||
``` | ||
## Display information about a WebM file | ||
``` | ||
Usage: webm-tools display [options] <file name> | ||
Display information about a WebM file | ||
Arguments: | ||
file name path to the WebM file | ||
Options: | ||
--debug show debug information | ||
-h, --help display help for command | ||
``` |
export { default as ebmlSchema } from "./lib/ebml-schema.js"; | ||
export * as ebml from "./lib/ebml.js"; | ||
export { displayDecodedElements } from "./lib/tools.js"; | ||
export { decode } from "./lib/decoder.js"; | ||
export { fix } from "./lib/index.js"; | ||
export { Buffer, utils } from "@ludovicm67/media-tools-utils"; | ||
//# sourceMappingURL=index.d.ts.map |
export function fix(prevChunk: import('@ludovicm67/media-tools-utils').Buffer, brokenChunk: import('@ludovicm67/media-tools-utils').Buffer, options?: LibOptions): import('@ludovicm67/media-tools-utils').Buffer; | ||
export function display(fileBuffer: import('@ludovicm67/media-tools-utils').Buffer): void; | ||
export type LibOptions = { | ||
@@ -3,0 +4,0 @@ /** |
@@ -8,5 +8,6 @@ // @ts-check | ||
export { default as ebmlSchema } from './lib/ebml-schema.js' | ||
export * as ebml from './lib/ebml.js' | ||
export { displayDecodedElements } from './lib/tools.js' | ||
export { decode } from './lib/decoder.js' | ||
// Export functions that can be used to work with WebM files | ||
export { fix } from './lib/index.js' |
// @ts-check | ||
import { resetDecoder, decode, displayDecodedElements } from './ebml.js' | ||
import { displayDecodedElements } from './tools.js' | ||
import { decode } from './decoder.js' | ||
import { Buffer } from '@ludovicm67/media-tools-utils' | ||
@@ -24,5 +25,2 @@ | ||
resetDecoder({ | ||
debug: false | ||
}) | ||
const { decoded, headerBuffer, lastStartBuffer } = decode(prevChunk) | ||
@@ -36,6 +34,3 @@ if (debug) { | ||
const newFile = Buffer.concat([headerBuffer, lastStartBuffer, brokenChunk]) | ||
resetDecoder({ | ||
debug: false | ||
}) | ||
const { decoded: newFileDecoded } = decode(newFile) | ||
const { decoded: newFileDecoded, buffer: newFileBuffer } = decode(newFile, { fixTimestamps: true }) | ||
if (debug) { | ||
@@ -47,3 +42,14 @@ console.info('\nDecoded fixed chunk:') | ||
return newFile | ||
return newFileBuffer | ||
} | ||
/** | ||
* Display information of a WebM file. | ||
* | ||
* @param {import('@ludovicm67/media-tools-utils').Buffer} fileBuffer Content of the file to display. | ||
* @returns {void} | ||
*/ | ||
export const display = (fileBuffer) => { | ||
const { decoded } = decode(fileBuffer) | ||
displayDecodedElements(decoded) | ||
} |
{ | ||
"name": "@ludovicm67/webm-tools", | ||
"version": "0.3.8", | ||
"version": "0.4.0", | ||
"description": "WebM tools", | ||
@@ -13,4 +13,3 @@ "main": "index.js", | ||
"build": "npm run typings", | ||
"prepack": "npm run build", | ||
"test": "true" | ||
"prepack": "npm run build" | ||
}, | ||
@@ -42,3 +41,3 @@ "repository": { | ||
"devDependencies": { | ||
"@types/node": "^20.11.16", | ||
"@types/node": "^20.11.24", | ||
"rimraf": "^5.0.5", | ||
@@ -45,0 +44,0 @@ "typescript": "^5.3.3" |
@@ -14,6 +14,4 @@ # WebM tools | ||
- `ebmlSchema`: the EBML schema | ||
- `ebml`: an object with the following methods: | ||
- `resetDecoder`: reset the decoder state | ||
- `decode`: decode an EBML element | ||
- `displayDecodedElements`: display the decoded elements using `console.log` | ||
- `decode`: decode an EBML element | ||
- `displayDecodedElements`: display the decoded elements using `console.log` | ||
- `fix`: the function to use to fix a chunk by using the previous one | ||
@@ -20,0 +18,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
179454
36
5322
42