mirror of
https://github.com/arcodange-org/mediabunny.git
synced 2026-09-29 20:03:48 +02:00
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:
+20
-2
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user