Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

webm-muxer

Package Overview
Dependencies
Maintainers
1
Versions
44
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

webm-muxer - npm Package Compare versions

Comparing version 1.0.8 to 1.1.0

6

build/webm-muxer.d.ts

@@ -6,3 +6,3 @@ declare interface WebMMuxerOptions {

width: number,
height: number
height: number,
frameRate?: number

@@ -24,2 +24,6 @@ },

addAudioChunk(chunk: EncodedAudioChunk, meta: EncodedAudioChunkMetadata, timestamp?: number): void;
addVideoChunkRaw(data: Uint8Array, type: 'key' | 'delta', timestamp: number, meta?: EncodedVideoChunkMetadata): void;
addAudioChunkRaw(data: Uint8Array, type: 'key' | 'delta', timestamp: number, meta?: EncodedAudioChunkMetadata): void;
finalize(): ArrayBuffer | null;

@@ -26,0 +30,0 @@ }

29

build/webm-muxer.js

@@ -458,7 +458,13 @@ "use strict";

addVideoChunk(chunk, meta, timestamp) {
let data = new Uint8Array(chunk.byteLength);
chunk.copyTo(data);
this.addVideoChunkRaw(data, chunk.type, timestamp != null ? timestamp : chunk.timestamp, meta);
}
addVideoChunkRaw(data, type, timestamp, meta) {
this.ensureNotFinalized();
if (!this.options.video)
throw new Error("No video track declared.");
this.writeVideoDecoderConfig(meta);
let internalChunk = this.createInternalChunk(chunk, timestamp);
if (meta)
this.writeVideoDecoderConfig(meta);
let internalChunk = this.createInternalChunk(data, type, timestamp, VIDEO_TRACK_NUMBER);
if (this.options.video.codec === "V_VP9")

@@ -548,6 +554,11 @@ this.fixVP9ColorSpace(internalChunk);

addAudioChunk(chunk, meta, timestamp) {
let data = new Uint8Array(chunk.byteLength);
chunk.copyTo(data);
this.addAudioChunkRaw(data, chunk.type, timestamp != null ? timestamp : chunk.timestamp, meta);
}
addAudioChunkRaw(data, type, timestamp, meta) {
this.ensureNotFinalized();
if (!this.options.audio)
throw new Error("No audio track declared.");
let internalChunk = this.createInternalChunk(chunk, timestamp);
let internalChunk = this.createInternalChunk(data, type, timestamp, AUDIO_TRACK_NUMBER);
this.lastAudioTimestamp = internalChunk.timestamp;

@@ -563,14 +574,12 @@ while (this.videoChunkQueue.length > 0 && this.videoChunkQueue[0].timestamp <= internalChunk.timestamp) {

}
if (meta.decoderConfig) {
if (meta == null ? void 0 : meta.decoderConfig) {
this.writeCodecPrivate(this.audioCodecPrivate, meta.decoderConfig.description);
}
}
createInternalChunk(externalChunk, timestamp) {
let data = new Uint8Array(externalChunk.byteLength);
externalChunk.copyTo(data);
createInternalChunk(data, type, timestamp, trackNumber) {
let internalChunk = {
data,
timestamp: timestamp != null ? timestamp : externalChunk.timestamp,
type: externalChunk.type,
trackNumber: externalChunk instanceof EncodedVideoChunk ? VIDEO_TRACK_NUMBER : AUDIO_TRACK_NUMBER
type,
timestamp,
trackNumber
};

@@ -577,0 +586,0 @@ return internalChunk;

{
"name": "webm-muxer",
"version": "1.0.8",
"version": "1.1.0",
"description": "WebM multiplexer in pure TypeScript for use with WebCodecs API, video & audio.",

@@ -5,0 +5,0 @@ "main": "./build/webm-muxer.js",

@@ -44,5 +44,6 @@ # webm-muxer - JavaScript WebM multiplexer

interface WebMMuxerOptions {
// When 'buffer' is used, the muxed file is written to a buffer in memory. When a
// FileSystemWritableFileStream acquired through the File System Access API (see example below) is
// used, the muxed file is written directly to disk, allowing for files way larger than what would fit
// When 'buffer' is used, the muxed file is written to a buffer in memory.
// When a FileSystemWritableFileStream acquired through the File System
// Access API (see example below) is used, the muxed file is written
// directly to disk, allowing for files way larger than what would fit
// in RAM.

@@ -53,3 +54,3 @@ target: 'buffer' | FileSystemWritableFileStream,

width: number,
height: number
height: number,
frameRate?: number // Optional, adds metadata to the file

@@ -69,4 +70,4 @@ },

```js
// Create a muxer with a video track running the VP9 codec, and no audio track. The muxed file is written
// to a buffer in memory.
// Create a muxer with a video track running the VP9 codec, and no audio track.
// The muxed file is written to a buffer in memory.
let muxer1 = new WebMMuxer({

@@ -81,4 +82,5 @@ target: 'buffer',

// Create a muxer with a video track running the VP9 codec, and an audio track running the Opus codec. The
// muxed file is written directly to a file on disk, using the File System Access API.
// Create a muxer with a video track running the VP9 codec, and an audio track
// running the Opus codec. The muxed file is written directly to a file on disk,
// using the File System Access API.
let fileHandle = await window.showSaveFilePicker({

@@ -88,3 +90,3 @@ suggestedName: `video.webm`,

description: 'Video File',
accept: {'video/webm' :['.webm']}
accept: { 'video/webm': ['.webm'] }
}],

@@ -108,3 +110,4 @@ });

// Create a muxer running only an Opus-coded audio track, and no video. Writes to a buffer in memory.
// Create a muxer running only an Opus-coded audio track, and no video. Writes
// to a buffer in memory.
let muxer3 = new WebMMuxer({

@@ -138,2 +141,21 @@ target: 'buffer',

```
Should you have obtained your encoded media data from a source other than the WebCodecs API, you can use these following methods
to directly send your raw data to the muxer:
```ts
addVideoChunkRaw(
data: Uint8Array,
type: 'key' | 'delta',
timestamp: number,
meta?: EncodedVideoChunkMetadata
): void;
addAudioChunkRaw(
data: Uint8Array,
type: 'key' | 'delta',
timestamp: number,
meta?: EncodedAudioChunkMetadata
): void;
```
When encoding is finished, call `finalize` on the `WebMMuxer` instance to finalize the WebM file. When using

@@ -176,2 +198,2 @@ `target: 'buffer'`, the resulting file's buffer is returned by this method:

For development, clone this repository, install everything with `npm i`, then run `npm run watch` to bundle the code
into the `build` directory.
into the `build` directory.

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc