Repository navigation
Description
Summary
On a large UHD HDR10 MKV remux, the HLS-fMP4 muxer cannot cut the first segment because it needs a parsed audio packet to write the audio sample entry, and the selected audio track has no packet within the forward prime-scan budget (~128 MiB / ~296 packets). The producer exits muxerFailed, retries twice, hits the revive cap, and gives up. AVPlayer then sits at AVPlayerWaitingToMinimizeStallsReason indefinitely (init.mp4 returns 404 … "empty (provider not ready?)") → permanent black screen.
The container has several audio tracks; the selected one is a sparsely-interleaved legacy track (Czech AC-3 2.0 "VHS, TV"). The primary tracks (e.g. English AC-3 5.1) are expected to mux fine on the same file. The engine picks the legacy track because it is the first one matching the host's preferred audio language (Czech), via preferredAudioLanguages — with no signal that it is a poor mux candidate.
Environment
- AetherEngine 6.21.0
- Apple TV 4K, tvOS 26.6 (build 23L773)
- HDR-capable panel, Match Content ON
Source media (ffprobe)
- Container: Matroska (MKV), ~61.8 GB (66,343,218,052 B). HTTP source, full Range support verified (
206across offset 0, mid-file, and near-EOF) — not a transport issue. - Video: HEVC, 3840×2160, HDR10 / PQ (
DV=none), ~97 Mbps avg. Keyframe index is healthy (6121 IRAPs → 1358 segments, keyframe-aligned). - Audio / subtitle tracks (source order):
0 hevc video eng 1 dts audio 8ch eng "EN DTS-HD 7.1" 2 ac3 audio 6ch eng "EN AC3 5.1" 3 subrip sub eng 4 ac3 audio 2ch cze "Czech AC3 2.0 (VHS, TV)" ← selected 5 ac3 audio 6ch cze "Czech AC3 5.1 (DVD, Blu-ray)" 6 subrip sub cze 7 hdmv_pgs sub eng
Expected
Plays. If the selected track can't be primed within budget, the engine should fall back / widen the scan / mux video-first and admit audio when it appears — not a hard permanent black screen.
Actual
audio: override accepted, sourceStreamIndex=4 (auto would have picked 4)
audio: codec=ac3 → stream-copy as `ac-3`
prepared: codec=hvc1.2.4.H153.b0,ac-3 resolution=3840x2160 fps=23.976 range=PQ DV=none segments=1357 duration=5431.8s
...
AE#222 seg-0.m4s cut deferred: audio sample entry needs a parsed packet and none has been muxed; scanning forward for a prime frame
AE#222 prime scan gave up after 296 packet(s) / 128 MiB without an audio packet
pump finished: reason=muxerFailed packetsRead=138 packetsWritten=136 lastError=0 elapsed=9851ms
#99 VOD pump died with muxerFailed; rebuilding producer + muxer (attempt 1/2)
...
#99 VOD pump died with muxerFailed; rebuilding producer + muxer (attempt 2/2)
...
#99 VOD muxerFailed revive cap reached (3 failures, cap 2); giving up (source not muxable in this session)
After giving up, AVPlayer never receives a usable init.mp4:
-> 404 /init.mp4 reason=init.mp4 empty (provider not ready?)
timeControlStatus=waitingToPlay reason=AVPlayerWaitingToMinimizeStallsReason (indefinitely)
→ permanent black screen.
Analysis
- The muxer needs a parsed packet from the selected audio track (source stream 4) to write the audio sample entry before it can cut
seg-0. It scans forward but that track's first packet lies beyond the ~128 MiB / ~296-packet budget for this file's interleave (128 MiB ≈ ~10 s of video at ~97 Mbps, yet a sparse track's first packet can be far further in). - Stream 4 is a legacy Czech AC-3 2.0 "VHS, TV" track — plausibly authored with sparse / bulk-late interleave. The primary tracks (stream 2 EN AC-3 5.1, stream 5 CZ AC-3 5.1) are the "real" tracks and almost certainly interleave densely from the start.
- Both
autoand the host override select stream 4 because it is the first track matching the preferred audio language (Czech); there's no signal that it's a poor mux candidate. - The video keyframe index is healthy here — the audio prime is the sole blocker.
Suggestions
- When the selected audio track can't be primed within budget, fall back to another audio track (or mux video-only and admit audio late) instead of
muxerFailed→ permanent stall. - Or make the prime-scan budget adaptive / configurable for high-bitrate 4K sources.
- Surfacing a recoverable error to the host (so it can re-load with a different track) would also help; today it is a silent, permanent stall with no host-observable failure.
Repro
UHD HDR10 HEVC MKV remux whose selected audio track (via preferred-language matching) is a sparsely-interleaved secondary AC-3 track. Host supports Range fully; ~62 GB. Reproduced repeatably on the source above.
Filed alongside #365 (DV Profile 7 dual-layer <no fdesc> / -11855) — both surfaced integrating full UHD-BD remuxes as a source.
Activity
fix(video): find the moov prime by seeking, and tell the host when th…
superuser404notfound commentedon Aug 13, 2026
Fixed in 6.25.0 (
62c61e7f, mergedca5ba888). The analysis in this report is accurate: the prime scan is exactly where it dies, and the interleave of the selected track is exactly why.Two things came out of reproducing it.
The budget was measured on the wrong axis
The scan is bounded at 128 MiB of forward reading. That is a byte bound, so what it buys shrinks as the bitrate grows: five minutes of a 3 Mbps encode, ten seconds of a 97 Mbps UHD one. Raising it would only move the line, since a legacy dub can have its first packet hundreds of MiB in.
It never had to be the first frame. AC-3 and E-AC-3 are one complete syncframe per packet, movenc builds the whole sample entry from whichever frame it gets, and the prime frame's timestamp is discarded anyway (the primed fragment is truncated and
frag_discontre-armed, which is what keeps it from shifting the audio timeline). So when the forward scan comes back empty, the pump now seeks to four positions, midpoint first, then 90 %, and takes any frame the track yields there.Nothing in the container could have pointed at the track instead: on a fixture whose first audio packet sits at byte 221,172,397, that track's
AVStream.start_timestill reads0.000000and itsdurationreports the segment duration.On that fixture the forward scan reads its 128 MiB and finds nothing, the midpoint probe reads 32 MiB and finds nothing, and the 90 % probe captures a 418 B frame after two packets. The session then plays,
init.mp4carries a realdac3, and the audio lands where the source put it: segment 19 holds video 76.000 to 79.958 plus the source's first audio packet at 79.994, segment 20 holds audio 80.028 to 83.965. The prime taken from 84 s did not drag anything with it.The permanent stall was a separate defect
"No host-observable failure" was the sharpest observation in the report, and it turned out to be its own bug rather than a consequence of the first one. The exhausted arm of the VOD muxer-failure revive was a bare
return: no producer, no restart, no error, so the provider answered404 init.mp4 emptyforever while AVPlayer sat inwaitingToPlay. The sibling arm for read errors, 150 lines up the same file, has surfaced its own exhaustion since #169.Measured on a source whose audio track carries no blocks at all: before,
state=playing phase=rebufferingfor the whole session; after,state=error("Source audio cannot be muxed (code -22)")inside a second. The terminal failure now carries a reason as well as a code, which also fixed two existing call sites that reported a failed read for something that read fine.The verdict is recorded on the session so the revive attempts do not each pay the full search again (about 256 MiB of reads per attempt) to reach the same answer, and it is deliberately not recorded when a read threw: that says nothing about the track.
On the track fallback
Falling back to another audio track was considered and not built. With the prime found by seeking, the track selected by preferred-language matching is the one that plays, and silently overriding that choice would be a worse trade than a bounded search. If a source ever turns up where no position yields a frame, the terminal error above is now the honest outcome and the host can act on it.
Retest welcome. If it still fails, the log lines to look for are
AE#366 prime hunt at <n>s(one per probe) and whether the session reachesstate=errorrather than sitting silent.fix(video): a VOD pump that produced nothing says so, whatever killed it
RomanLiberda commentedon Aug 13, 2026
Retested on 6.25.1 — fixed: the file now plays from the start with audio present (no offset), just with a slightly longer startup while the midpoint prime hunt runs before the first segment is served.
superuser404notfound commentedon Aug 14, 2026
Thanks for the retest, closing on that.
The longer startup is the price of the change and not a leftover: the search for the priming audio packet is no longer a forward read bounded at 128 MiB, it seeks (midpoint first, which is why a track muxed in bulk near the end is found at once), and the first segment is cut once a parsed packet has reached the muxer. On a 97 Mbps remux with a sparsely interleaved track that search is real work, where the old byte bound gave up after about ten seconds of media and produced a permanently black screen instead.
Shipped in 6.25.0 and 6.25.1, both now superseded by 6.25.4 with unrelated fixes on the same path.