Add MPEG-TS muxer, fix a demuxer bug, remove Infinity from output format track counts

This commit is contained in:
Vanilagy
2026-01-16 16:33:28 +01:00
parent ae37973878
commit e8b27768a9
13 changed files with 1705 additions and 64 deletions
+29
View File
@@ -0,0 +1,29 @@
/*!
* Copyright (c) 2025-present, Vanilagy and contributors
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
export const TIMESCALE = 90_000; // MPEG-TS timestamps run on a 90 kHz clock
export const TS_PACKET_SIZE = 188;
export const enum MpegTsStreamType {
MP3_MPEG1 = 0x03,
MP3_MPEG2 = 0x04,
AAC = 0x0f,
AVC = 0x1b,
HEVC = 0x24,
}
export const buildMpegTsMimeType = (codecStrings: (string | null)[]) => {
let string = 'video/MP2T';
const uniqueCodecStrings = [...new Set(codecStrings.filter(Boolean))];
if (uniqueCodecStrings.length > 0) {
string += `; codecs="${uniqueCodecStrings.join(', ')}"`;
}
return string;
};