Repository navigation
fix(hls): remux finite HEVC MPEG-TS VOD - #269
superuser404notfound merged 1 commit into
Conversation
Hardening on top of the HEVC-in-MPEG-TS VOD ingest from PR #269. The reader addresses the EXTINF sum, but every engine seek target is an ABSOLUTE source PTS, and MPEG-TS carries an arbitrary PTS origin: ffmpeg writes 1.4 s by default, broadcast-derived VOD routinely starts hours in. Handing the raw target to the reader therefore mapped a seek to item second 5 of a 1000 s-origin source onto the LAST segment of its playlist, the producer restarted on content 580 s away from the one it asked for, and the session clock left the item's own duration (`cur=1592.60 dur=600.0` on Fixtures/user/hls-hevc-vod-long-offset). `Demuxer` now strips the origin (the anchoring stream's `start_time`, else the container's) before positioning a `TimeSeekableIOReader`, and the protocol says which axis it speaks. `seekBounded` takes the same seam. It is the deadline-bounded form of a byte binary search that this source cannot serve at all, and on an index-less MPEG-TS that search is the one #112 round 10 already latched off as wedged or broken. The VOD cue prewarm in turn skips a segmented source: there is no index for it to load, and each reposition would refetch a segment for the uniform-stride plan it ends up building anyway. Also: - The carriage probe reads packet-aligned chunks and stops at its first verdict instead of accumulating up to 512 KiB byte by byte. It runs on every HLS VOD reroute, including the H.264 sources that then stay native, where the per-byte loop measured ~75 ms of CPU per load against a loopback origin versus ~2 ms for a bulk read. The ceiling drops to 128 KiB with it. - Byte seeks stop reporting a rewind that never happened; only a reposition that does not move succeeds, which is all the `CustomIOReaderBridge` capability handshake needs. - The prefetch window narrows with the observed segment size, so four 4K segments in flight cannot peak near 100 MB (AE#255: bound by bytes, not by count), and the FIFO matches the live ingest at 16 MB. - `makeIndependentReader` returns nil rather than opening a second full HTTP ingest of the same VOD for side-demuxed subtitles or scrub previews. - A reposition onto the segment the producer already opened at, with nothing consumed since, resolves without refetching it (scrub churn). - The two reroute call sites collapse into one helper. Verified: full suite green (405 XCTest, 1365 Swift Testing in 207 suites), strict-concurrency build clean, tvOS BUILD SUCCEEDED. End to end through `aetherctl play` against a local range-capable origin serving the new fixtures: HEVC-in-TS VOD plays with duration 600.04 s and six forward/backward seeks land exactly (52-100 ms), each mapping to the segment before its target; the same run on the 1000 s-origin fixture now restarts at segment 0 for a seek to item second 0 instead of segment 98; the H.264 control keeps the AE#154 native route. Fixture recipes are in Scripts/fetch-fixtures.sh. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01HX5zV3Fcf7Nzq4DYGdXvQE
|
Merged, thank you. The shape is right: the decision comes from the playlist and the PMT, the ingest is seekable, and every carriage AVPlayer handles itself stays on the native route. Follow-up hardening is on main in d8cc273. One real defect, found before the merge. A seek to item second 5 positioned the ingest at the last segment of a 600 s playlist, and the session clock left the item's own duration. Rest of the follow-up:
Verification here: full suite green (405 XCTest, 1365 Swift Testing in 207 suites), strict-concurrency build clean, tvOS BUILD SUCCEEDED, plus an end to end run through
The open piece is a confirmation on real hardware against the original source, so I reopened #268 for it. |
Fixes #268.
Problem
AVPlayer can mount finite HEVC-in-MPEG-TS HLS as audio-only / black video. This is a long-standing HEVC HLS playback-path problem, not a device-generation-specific issue.
The existing HLS reroute sends VOD back to native remote HLS. That is correct for ordinary HLS, but preserves the black-screen path for this carriage. Reusing the live ingest is also not suitable because its rolling-window contract breaks VOD seek semantics.
Change
#EXT-X-ENDLIST, MPEG-TS carriage, and PMT stream type0x24(HEVC)This is content-gated; it does not infer codecs from the
.m3u8suffix or retry from an AVPlayer error string.Validation
swift test --filter Issue268HLSVODIngestTests— 4 passedswift build -Xswiftc -strict-concurrency=complete— passedxcodebuild -scheme AetherEngine -destination 'generic/platform=tvOS' build CODE_SIGNING_ALLOWED=NO— passedswift test --skip-build --skip Issue220SoftwareDecoderDrainTests— 1361 tests in 206 suites passedA full unfiltered run has one failure in
Issue220SoftwareDecoderDrainTests(expected drain counter >= 24, observed 17). The same failure reproduces in a clean worktree at upstream83dca0b, so it is not introduced by this branch.The same reader/demux seam was physically validated in a downstream integration with finite duration, forward seek, post-seek progress, and 2x playback. This PR reconstructs that workaround against current upstream
main; direct physical-device acceptance of this exact branch remains pending, hence the draft status.