Skip to content

fix: set HEVC sync samples from IRAP VCL NALs - #7861

Merged
robwalch merged 1 commit into
video-dev:masterfrom
gemxx:master
May 20, 2026
Merged

fix: set HEVC sync samples from IRAP VCL NALs#7861
robwalch merged 1 commit into
video-dev:masterfrom
gemxx:master

Conversation

@gemxx

@gemxx gemxx commented May 20, 2026

Copy link
Copy Markdown
Contributor

This PR will...

Fix a HEVC fMP4 sync sample regression introduced by #7854, where parameter-set NALs could mark samples as keyframes.

A HEVC sample is now marked as sync only when its access unit contains an IRAP VCL picture, such as BLA, IDR, or CRA.

Test stream:

https://sf1-cdn-tos.huoshanstatic.com/obj/media-fe/badcase/hls-hevc-au-testset/hls-hevc-sync/index.m3u8

Why is this Pull Request needed?

Some HEVC TS streams place parameter sets before regular non-IRAP pictures:

VPS/SPS/PPS/SEI/AUD + TRAIL

This issue was introduced by #7854. After access-unit boundary handling groups those prefix NALs with the following picture, the old SPS path could still mark the sample as key:

VideoSample.key = true;

That can produce an invalid fMP4 sync sample:

wrong:   K__ [VPS, SPS, PPS, prefix SEI, AUD, TRAIL]
correct: ___ [VPS, SPS, PPS, prefix SEI, AUD, TRAIL]

TRAIL is not a random access picture. On Chrome/macOS, VideoToolbox may fail decoding when such a sample is incorrectly marked as sync:

PIPELINE_ERROR_DECODE
NSOSStatusErrorDomain Code=-12909
VTDecompressionOutputCallback

Real IRAP pictures remain sync samples:

K__ [SPS, PPS, prefix SEI, prefix SEI, AUD, IDR]

Are there any points in the code the reviewer needs to double check?

Please check the HEVC sync-sample rule:

VPS/SPS/PPS/AUD/SEI do not make a sample sync.
Only IRAP VCL pictures, such as BLA/IDR/CRA, make a sample sync.

Also note that VideoSample.key = true is still needed in IRAP branches because a sample may already have been opened by prefix NALs before the IRAP VCL NAL is parsed.

Resolves issues:

N/A

Checklist

  • [ x] changes have been done against master branch, and PR does not conflict
  • new unit / functional tests have been added (whenever applicable)
  • API or design changes are documented in API.md

Validation performed:

  • npm run build:debug
  • npx prettier --check src/demux/video/hevc-video-parser.ts
  • git diff --check
  • Manual Safari/Chrome/Firefox macOS/Window playback verification with the affected HEVC stream
@robwalch

Copy link
Copy Markdown
Collaborator
@robwalch robwalch added this to the 1.7.0 milestone May 20, 2026
@robwalch
robwalch merged commit 959235c into video-dev:master May 20, 2026
12 checks passed
@github-project-automation github-project-automation Bot moved this from Top priorities to Done in HLS.js Release Planning and Backlog May 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants