From bf0180ca781ec90b8a3ab3e06ffa46817e2fe3b6 Mon Sep 17 00:00:00 2001 From: Vladmir Vyatkin Date: Sun, 6 Oct 2024 19:40:26 +0500 Subject: [PATCH] Fix PPS growth in HEVC TS parser (#6724) Co-authored-by: vladimir.vyatkin --- src/demux/video/hevc-video-parser.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/demux/video/hevc-video-parser.ts b/src/demux/video/hevc-video-parser.ts index b3b61bb755c..2618d639a40 100644 --- a/src/demux/video/hevc-video-parser.ts +++ b/src/demux/video/hevc-video-parser.ts @@ -1,4 +1,5 @@ import BaseVideoParser from './base-video-parser'; +import type { ParsedVideoSample } from '../tsdemuxer'; import type { DemuxedVideoTrack, DemuxedUserdataTrack, @@ -180,7 +181,7 @@ class HevcVideoParser extends BaseVideoParser { track.params[prop] = config[prop]; } } - if (this.initVPS !== null || track.pps.length === 0) { + if (track.vps !== undefined && track.vps[0] === this.initVPS) { track.pps.push(unit.data); } } @@ -239,6 +240,16 @@ class HevcVideoParser extends BaseVideoParser { return new Uint8Array(dst.buffer, 0, dstIdx); } + protected pushAccessUnit( + VideoSample: ParsedVideoSample, + videoTrack: DemuxedVideoTrack, + ) { + super.pushAccessUnit(VideoSample, videoTrack); + if (this.initVPS) { + this.initVPS = null; // null initVPS to prevent possible track's sps/pps growth until next VPS + } + } + readVPS(vps: Uint8Array): { numTemporalLayers: number; temporalIdNested: boolean;