Commit 489e38c
fix(hls): keyframe-gated VOD segment cut so the IRAP opens its segment (#92)
Root cause (confirmed via segverify vs ffmpeg ground truth): VOD routed each
packet to a segment by its DTS against PTS-valued plan boundaries. Under
B-frame reorder a keyframe's DTS is below its PTS, so the boundary IRAP fell
into the previous segment and the next segment started mid-GOP, decode-
dependent on its predecessor. AVPlayer hitting a fresh decode at such a
boundary (rebuffer recovery) showed transient blocky corruption (the #92
report on native DV P8.1). The defect was general to reordered content, not
just open-GOP CRA: closed-GOP-with-B-frames was equally affected.
Fix: VODSegmentCutter cuts in decode order, keyframe-gated, like the existing
live path and like FFmpeg's hls muxer. A segment opens at the IRAP that
reaches its plan boundary, so the IRAP is the segment's first sample and its
open-GOP RASL leading pictures (which follow in decode order) stay with it; a
fresh decode then starts cleanly at the IRAP and discards RASL via
NoRaslOutputFlag. Audio routing is unchanged (still presentation-aligned by
PTS, as FFmpeg does). EXTINF still derives from the plan boundaries.
Verified locally with `aetherctl segverify` on synthetic HEVC: before, 1/8
segments independently decodable (only seg0); after, 8/8 for BOTH open-GOP
and closed-GOP, matching ffmpeg's own hls segmenter. 9 TDD tests for the
cutter (RASL-stays-with-keyframe, intra-segment keyframe does not cut, base-
index restart, sparse jump, end-boundary clamp). The #92 witness verdict now
keys off "starts at IRAP" (trailing RASL are legitimate). Full suite green
(XCTest 236, Swift Testing 268), strict-concurrency clean.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XZTEfmztPE8hAdjHdBr9BH1 parent c70e1c2 commit 489e38c
3 files changed
Lines changed: 141 additions & 17 deletions
File tree
- Sources/AetherEngine/Video
- Tests/AetherEngineTests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
245 | 245 | | |
246 | 246 | | |
247 | 247 | | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
248 | 251 | | |
249 | 252 | | |
250 | 253 | | |
| |||
313 | 316 | | |
314 | 317 | | |
315 | 318 | | |
316 | | - | |
317 | | - | |
318 | | - | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
319 | 325 | | |
320 | 326 | | |
321 | 327 | | |
322 | 328 | | |
323 | | - | |
| 329 | + | |
324 | 330 | | |
325 | 331 | | |
326 | 332 | | |
| |||
589 | 595 | | |
590 | 596 | | |
591 | 597 | | |
| 598 | + | |
592 | 599 | | |
593 | 600 | | |
594 | 601 | | |
| |||
1937 | 1944 | | |
1938 | 1945 | | |
1939 | 1946 | | |
| 1947 | + | |
| 1948 | + | |
| 1949 | + | |
| 1950 | + | |
| 1951 | + | |
1940 | 1952 | | |
1941 | | - | |
1942 | | - | |
1943 | | - | |
1944 | | - | |
1945 | | - | |
| 1953 | + | |
| 1954 | + | |
1946 | 1955 | | |
1947 | | - | |
1948 | | - | |
1949 | | - | |
1950 | | - | |
| 1956 | + | |
1951 | 1957 | | |
1952 | 1958 | | |
1953 | 1959 | | |
| |||
2010 | 2016 | | |
2011 | 2017 | | |
2012 | 2018 | | |
2013 | | - | |
| 2019 | + | |
2014 | 2020 | | |
2015 | 2021 | | |
2016 | 2022 | | |
| |||
2129 | 2135 | | |
2130 | 2136 | | |
2131 | 2137 | | |
2132 | | - | |
2133 | | - | |
2134 | | - | |
| 2138 | + | |
2135 | 2139 | | |
2136 | 2140 | | |
2137 | 2141 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
0 commit comments