Add "Quick start" to docs, small API and docs adjustments

This commit is contained in:
Vanilagy
2025-06-18 12:25:10 +02:00
parent a2fc4decda
commit befab215b4
8 changed files with 533 additions and 36 deletions
+8 -8
View File
@@ -150,7 +150,7 @@ export class MatroskaMuxer extends Muxer {
this.ebmlWriter = new EBMLWriter(this.writer);
if (this.format._options.streamable) {
if (this.format._options.appendOnly) {
this.writer.ensureMonotonicity = true;
}
}
@@ -160,7 +160,7 @@ export class MatroskaMuxer extends Muxer {
this.writeEBMLHeader();
if (!this.format._options.streamable) {
if (!this.format._options.appendOnly) {
this.createSeekHead();
}
@@ -228,7 +228,7 @@ export class MatroskaMuxer extends Muxer {
{ id: EBMLId.TimestampScale, data: 1e6 },
{ id: EBMLId.MuxingApp, data: APP_NAME },
{ id: EBMLId.WritingApp, data: APP_NAME },
!this.format._options.streamable ? segmentDuration : null,
!this.format._options.appendOnly ? segmentDuration : null,
] };
this.segmentInfo = segmentInfo;
}
@@ -370,9 +370,9 @@ export class MatroskaMuxer extends Muxer {
private createSegment() {
const segment: EBML = {
id: EBMLId.Segment,
size: this.format._options.streamable ? -1 : SEGMENT_SIZE_BYTES,
size: this.format._options.appendOnly ? -1 : SEGMENT_SIZE_BYTES,
data: [
!this.format._options.streamable ? this.seekHead as EBML : null,
!this.format._options.appendOnly ? this.seekHead as EBML : null,
this.segmentInfo,
this.tracksElement,
],
@@ -862,7 +862,7 @@ export class MatroskaMuxer extends Muxer {
this.currentCluster = {
id: EBMLId.Cluster,
size: this.format._options.streamable ? -1 : CLUSTER_SIZE_BYTES,
size: this.format._options.appendOnly ? -1 : CLUSTER_SIZE_BYTES,
data: [
{ id: EBMLId.Timestamp, data: msTimestamp },
],
@@ -877,7 +877,7 @@ export class MatroskaMuxer extends Muxer {
private finalizeCurrentCluster() {
assert(this.currentCluster);
if (!this.format._options.streamable) {
if (!this.format._options.appendOnly) {
const clusterSize = this.writer.getPos() - this.ebmlWriter.dataOffsets.get(this.currentCluster)!;
const endPos = this.writer.getPos();
@@ -959,7 +959,7 @@ export class MatroskaMuxer extends Muxer {
assert(this.cues);
this.ebmlWriter.writeEBML(this.cues);
if (!this.format._options.streamable) {
if (!this.format._options.appendOnly) {
const endPos = this.writer.getPos();
// Write the Segment size
+6 -6
View File
@@ -303,11 +303,11 @@ export class MovOutputFormat extends IsobmffOutputFormat {
*/
export type MkvOutputFormatOptions = {
/**
* Configures the output to only write data monotonically, useful for live-streaming the file as it's being muxed.
* When enabled, some features such as storing duration and seeking will be disabled or impacted, so don't use this
* option when you want to write out a file for later use.
* Configures the output to only append new data at the end, useful for live-streaming the file as it's being
* created. When enabled, some features such as storing duration and seeking will be disabled or impacted, so don't
* use this option when you want to write out a clean file for later use.
*/
streamable?: boolean;
appendOnly?: boolean;
/**
* This field controls the minimum duration of each Matroska cluster, in seconds. New clusters will only be created
@@ -354,8 +354,8 @@ export class MkvOutputFormat extends OutputFormat {
if (!options || typeof options !== 'object') {
throw new TypeError('options must be an object.');
}
if (options.streamable !== undefined && typeof options.streamable !== 'boolean') {
throw new TypeError('options.streamable, when provided, must be a boolean.');
if (options.appendOnly !== undefined && typeof options.appendOnly !== 'boolean') {
throw new TypeError('options.appendOnly, when provided, must be a boolean.');
}
if (
options.minimumClusterDuration !== undefined