Fixed negative timestamps occurring with live media (fixes #364)

This commit is contained in:
Vanilagy
2026-05-07 11:11:37 +02:00
parent daf42181c9
commit fff09411e6
11 changed files with 40 additions and 53 deletions
+8 -12
View File
@@ -614,17 +614,15 @@ export class HlsMuxer extends Muxer {
const release = await playlist.mutex.acquire();
try {
const timestamp = this.validateAndNormalizeTimestamp(track, packet.timestamp, packet.type === 'key');
const adjustedPacket = packet.clone({ timestamp });
trackData.packets.push(adjustedPacket);
this.validateTimestamp(track, packet.timestamp, packet.type === 'key');
trackData.packets.push(packet);
if (playlist.currentSegmentStartTimestamp === null) {
playlist.currentSegmentStartTimestamp = adjustedPacket.timestamp;
playlist.currentSegmentStartTimestamp = packet.timestamp;
} else if (!playlist.currentSegmentStartTimestampIsFixed) {
playlist.currentSegmentStartTimestamp = Math.min(
playlist.currentSegmentStartTimestamp,
adjustedPacket.timestamp,
packet.timestamp,
);
}
@@ -645,17 +643,15 @@ export class HlsMuxer extends Muxer {
const release = await playlist.mutex.acquire();
try {
const timestamp = this.validateAndNormalizeTimestamp(track, packet.timestamp, packet.type === 'key');
const adjustedPacket = packet.clone({ timestamp });
trackData.packets.push(adjustedPacket);
this.validateTimestamp(track, packet.timestamp, packet.type === 'key');
trackData.packets.push(packet);
if (playlist.currentSegmentStartTimestamp === null) {
playlist.currentSegmentStartTimestamp = adjustedPacket.timestamp;
playlist.currentSegmentStartTimestamp = packet.timestamp;
} else if (!playlist.currentSegmentStartTimestampIsFixed) {
playlist.currentSegmentStartTimestamp = Math.min(
playlist.currentSegmentStartTimestamp,
adjustedPacket.timestamp,
packet.timestamp,
);
}