mirror of
https://github.com/arcodange-org/mediabunny.git
synced 2026-09-30 12:23:52 +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:
+22
-2
@@ -814,7 +814,10 @@ const HEVC_CODEC_STRING_REGEX = /^(hev1|hvc1)\.(?:[ABC]?\d+)\.[0-9a-fA-F]{1,8}\.
|
||||
const VP9_CODEC_STRING_REGEX = /^vp09(?:\.\d{2}){3}(?:(?:\.\d{2}){5})?$/;
|
||||
const AV1_CODEC_STRING_REGEX = /^av01\.\d\.\d{2}[MH]\.\d{2}(?:\.\d\.\d{3}\.\d{2}\.\d{2}\.\d{2}\.\d)?$/;
|
||||
|
||||
export const validateVideoChunkMetadata = (metadata: EncodedVideoChunkMetadata | undefined) => {
|
||||
export const validateVideoChunkMetadata = (
|
||||
metadata: EncodedVideoChunkMetadata | undefined,
|
||||
trackCodec: VideoCodec | null,
|
||||
) => {
|
||||
if (!metadata) {
|
||||
throw new TypeError('Video chunk metadata must be provided.');
|
||||
}
|
||||
@@ -985,13 +988,23 @@ export const validateVideoChunkMetadata = (metadata: EncodedVideoChunkMetadata |
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (trackCodec !== null && inferCodecFromCodecString(metadata.decoderConfig.codec) !== trackCodec) {
|
||||
throw new TypeError(
|
||||
`Video chunk metadata decoder configuration codec string '${metadata.decoderConfig.codec}' does not fit to`
|
||||
+ ` the track codec '${trackCodec}'.`,
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
const VALID_AUDIO_CODEC_STRING_PREFIXES = [
|
||||
'mp4a', 'mp3', 'opus', 'vorbis', 'flac', 'ulaw', 'alaw', 'pcm', 'ac-3', 'ec-3',
|
||||
];
|
||||
|
||||
export const validateAudioChunkMetadata = (metadata: EncodedAudioChunkMetadata | undefined) => {
|
||||
export const validateAudioChunkMetadata = (
|
||||
metadata: EncodedAudioChunkMetadata | undefined,
|
||||
trackCodec: AudioCodec | null,
|
||||
) => {
|
||||
if (!metadata) {
|
||||
throw new TypeError('Audio chunk metadata must be provided.');
|
||||
}
|
||||
@@ -1133,6 +1146,13 @@ export const validateAudioChunkMetadata = (metadata: EncodedAudioChunkMetadata |
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (trackCodec !== null && inferCodecFromCodecString(metadata.decoderConfig.codec) !== trackCodec) {
|
||||
throw new TypeError(
|
||||
`Audio chunk metadata decoder configuration codec string '${metadata.decoderConfig.codec}' does not fit to`
|
||||
+ ` the track codec '${trackCodec}'.`,
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
export const validateSubtitleMetadata = (metadata: SubtitleMetadata | undefined) => {
|
||||
|
||||
Reference in New Issue
Block a user