Skip to content

Software VOD packet coverage: HEVC fragments on rounded durations, and a full coverage freezes #613

Closed

Description

@superuser404notfound

Found while answering #592 (comment). Two defects in the software VOD read-ahead's packet coverage. Neither explains #592's turnover, and both are real on their own.

1. HEVC coverage fragments on rounded container durations

The reorder-aware presentation coverage (SoftwareVideoPacketCoverage, successor PTS) is built for H.264 only (SoftwarePlaybackHost.swift:948). Every other codec keeps the strict pts + duration model, which tolerates no gap, not even one tick.

A Matroska file at 23.976 fps on a 1 ms time base whose packets carry duration=41 against PTS deltas of 41 and 42 ms leaves a 1 ms hole at every 42 ms step. Measured on an FFmpeg-muxed 4K HEVC fixture, from both sides:

ffprobe, first 10 s:            240 frames, 169 gaps (0.704 per frame)
engine counter, 90 s SW session: n=7500 packets -> video coverage 2307 ranges, audio 1

Consequences:

  • bufferedPosition is the end of the current island, not of the buffer: 0.41 to 0.51 s ahead of the playhead on a session with a 20 s reservoir.
  • The frontier limb of the park check and the cached-seek eligibility (SoftwarePacketReadAhead.swift:170, :233) see the same truncated frontier.
  • Island count grows with every frame, which is what made the frontier walk visible before 3e9188bd.

The successor model's own contract names the condition for widening it: "Other codecs must keep their strict packet duration coverage unless their presentation reordering has a separately established bound." HEVC has one. FFmpeg rejects sps_max_num_reorder_pics > HEVC_MAX_DPB_SIZE - 1 = 15 (n8.1.2 hevc/ps.c), inside the 32-timestamp queue.

2. A full coverage freezes instead of forgetting history

Coverage is never pruned during playback (updatePlayhead keeps the history for backward cached seeks), and it is capped at 4096 ranges. Past the cap:

  • plain coverage: insert returns false, nobody reads it, and new packets are no longer described;
  • H.264 presentation coverage: emit invalidates the whole model until the next seek.

Either way the frontier for everything stored after the cap is nil. That makes bufferedPosition nil, sends every cached seek into the stored region cold, and gives AE#605's cache-backed stills nothing to answer from. At 0.70 islands per frame the cap is reached after about 241 s of stored video.

Fix: at capacity, forget the ranges wholly behind the playhead and keep describing new packets. A backward cached seek into forgotten history becomes a cold seek, which is correct. The alternative is to lose everything ahead of the playhead.

Activity

  1. superuser404notfound commented on Sep 23, 2026

    @superuser404notfound
    OwnerAuthor

    Fixed in #614 (merged to main as ac2af29), unreleased. HEVC takes the successor-timestamp model, and a full coverage forgets the ranges behind the playhead instead of freezing. On a 4K HEVC Matroska file with 41 ms durations over an HTTP origin, aetherctl play --sw now reads buf 39.8 s ahead of the playhead where it read 0.4 s. Stays open until it ships in a release.

  2. superuser404notfound commented on Sep 23, 2026

    @superuser404notfound
    OwnerAuthor

    Released in 7.15.1 (b93f9c4b).

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions