webm-muxer
Advanced tools
Comparing version 1.0.6 to 1.0.7
@@ -229,2 +229,3 @@ "use strict"; | ||
var FILE_CHUNK_SIZE = __pow(2, 24); | ||
var MAX_CHUNKS_AT_ONCE = 2; | ||
var FileSystemWritableFileStreamWriteTarget = class extends WriteTarget { | ||
@@ -234,3 +235,2 @@ constructor(stream) { | ||
this.chunks = []; | ||
this.toFlush = []; | ||
this.stream = stream; | ||
@@ -257,5 +257,10 @@ } | ||
if (chunk.written[0].start === 0 && chunk.written[0].end === FILE_CHUNK_SIZE) { | ||
this.toFlush.push(chunk); | ||
this.chunks.splice(chunkIndex, 1); | ||
chunk.shouldFlush = true; | ||
} | ||
if (this.chunks.length > MAX_CHUNKS_AT_ONCE) { | ||
for (let i = 0; i < this.chunks.length - 1; i++) { | ||
this.chunks[i].shouldFlush = true; | ||
} | ||
this.flushChunks(); | ||
} | ||
if (toWrite.byteLength < data.byteLength) { | ||
@@ -270,19 +275,22 @@ this.writeDataIntoChunks(data.subarray(toWrite.byteLength), position + toWrite.byteLength); | ||
data: new Uint8Array(FILE_CHUNK_SIZE), | ||
written: [] | ||
written: [], | ||
shouldFlush: false | ||
}; | ||
this.chunks.push(chunk); | ||
return this.chunks.length - 1; | ||
this.chunks.sort((a, b) => a.start - b.start); | ||
return this.chunks.indexOf(chunk); | ||
} | ||
flushChunks() { | ||
if (this.toFlush.length > 0) { | ||
for (let chunk of this.toFlush) { | ||
for (let section of chunk.written) { | ||
this.stream.write({ | ||
type: "write", | ||
data: chunk.data.subarray(section.start, section.end), | ||
position: chunk.start + section.start | ||
}); | ||
} | ||
flushChunks(force = false) { | ||
for (let i = 0; i < this.chunks.length; i++) { | ||
let chunk = this.chunks[i]; | ||
if (!chunk.shouldFlush && !force) | ||
continue; | ||
for (let section of chunk.written) { | ||
this.stream.write({ | ||
type: "write", | ||
data: chunk.data.subarray(section.start, section.end), | ||
position: chunk.start + section.start | ||
}); | ||
} | ||
this.toFlush.length = 0; | ||
this.chunks.splice(i--, 1); | ||
} | ||
@@ -294,5 +302,3 @@ } | ||
finalize() { | ||
this.toFlush.push(...this.chunks); | ||
this.chunks.length = 0; | ||
this.flushChunks(); | ||
this.flushChunks(true); | ||
} | ||
@@ -299,0 +305,0 @@ }; |
{ | ||
"name": "webm-muxer", | ||
"version": "1.0.6", | ||
"version": "1.0.7", | ||
"description": "WebM multiplexer in pure TypeScript for use with WebCodecs API, video & audio.", | ||
@@ -5,0 +5,0 @@ "main": "./build/webm-muxer.js", |
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
34072
650