Skip to content

fix: detect access units in YouTube HLS AVC1 path#24

Merged
InfinityLoop1308 merged 1 commit intoInfinityLoop1308:devfrom
Priveetee:fix/avc1-stutter
Apr 12, 2026
Merged

fix: detect access units in YouTube HLS AVC1 path#24
InfinityLoop1308 merged 1 commit intoInfinityLoop1308:devfrom
Priveetee:fix/avc1-stutter

Conversation

@Priveetee
Copy link
Copy Markdown
Contributor

Summary

This PR fixes severe AVC1/H264 stutter on affected Pixel devices by changing YouTube HLS extractor configuration in one localized code path.

The patch is small because the root cause is localized: enabling access-unit detection in the YouTube HLS TS parsing path resolves the reproduced stutter behavior.

Related reports

Problem

On affected Pixel devices, YouTube AVC1/H264 playback can stutter heavily (audio remains in sync), with bursty dropped-frame patterns.
Observed decoder path on repro device: c2.exynos.h264.decoder.

Investigation highlights

  • Reproduced outside PipePipe UI (Media3 demo), so this is not a PipePipe UI-thread issue.
  • Cross-device comparison showed decoder/device specificity:
    • Pixel 8: reproducible drops
    • Z Fold 5 (c2.qti.avc.decoder): same stream family smooth
  • Bitrate-only hypothesis was ruled out (re-encodes at different bitrates were stable).
  • A/B testing pointed to HLS AVC1 access-unit parsing/feeding behavior.

Code change

File:

  • app/src/main/java/org/schabi/newpipe/player/helper/PlayerDataSource.java

Change in getYoutubeHlsMediaSourceFactory():

  • enable DefaultTsPayloadReaderFactory.FLAG_DETECT_ACCESS_UNITS
  • use DefaultHlsExtractorFactory(payloadReaderFlags, true)

This adjusts how H264 TS payload is split into access units before decoder input.

Validation (A/B, same repro setup)

  • detect-AU ON: 0 / 0 / 0 / 0 / 0 / 0 / 0 dropped frames (7 runs)
  • detect-AU OFF (control): 13 / 312 / 573 dropped frames (3 runs)

Also validated in continuous real-device usage after patch: playback remained smooth.

Scope

  • YouTube HLS extractor path only
  • No codec forcing
  • No quality forcing
  • No UI behavior changes
  • DASH/progressive paths unchanged

Build verification

  • Local build passes with this change: :app:assembleDebug

@InfinityLoop1308
Copy link
Copy Markdown
Owner

Thanks a lot for the fix! I saw all the comparative testing you did. Very solid work.
Merging now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants