Fix HLS writing an incomplete init segment for sparse segments, improve decoder config validation, fix getFirstTimestamp() for Inputs with zero-packet tracks, allow zero-track muxing for some formats that allow it, add new track metadata that allows you to specify the decoder config early (enables zero-packet tracks), fix trafIndices in sparse fragmented MP4s, fix assertion errors in MPEG-TS demuxer

This commit is contained in:
Vanilagy
2026-08-08 17:00:36 +02:00
parent 7ec538e175
commit 5b22c8c17d
23 changed files with 1433 additions and 204 deletions
+20 -2
View File
@@ -48,7 +48,18 @@ export class WaveMuxer extends Muxer {
this.writer = await this.output._getRootWriter(false);
this.riffWriter = new RiffWriter(this.writer);
// No writing needed here - we'll write the header with the first sample
// If the track already tells us everything we need, we can write the header right now. Otherwise, we'll write
// it with the first sample.
const track = this.output.tracks[0];
assert(track?.isAudioTrack());
if (track.metadata.decoderConfig) {
validateAudioChunkMetadata({ decoderConfig: track.metadata.decoderConfig }, track.source._codec);
this.writeHeader(track, track.metadata.decoderConfig);
this.sampleRate = track.metadata.decoderConfig.sampleRate;
this.headerWritten = true;
}
release();
}
@@ -70,7 +81,7 @@ export class WaveMuxer extends Muxer {
try {
if (!this.headerWritten) {
validateAudioChunkMetadata(meta);
validateAudioChunkMetadata(meta, track.source._codec);
assert(meta);
assert(meta.decoderConfig);
@@ -341,6 +352,13 @@ export class WaveMuxer extends Muxer {
async finalize() {
const release = await this.mutex.acquire();
if (!this.headerWritten) {
throw new Error(
'Cannot finalize an empty WAVE file: no packets were added and the track specified no decoderConfig in'
+ ' its metadata, so there\'s no telling what the file should look like.',
);
}
const endPos = this.writer.getPos();
if (this.isRf64) {