Repository navigation
Software path: presentation timebase + per-frame times (#311) - #322
Merged
Merged
Conversation
…timebase (#311) A host compositing a bitmap overlay (libass) over software-decoded video needs two things the engine had but did not expose: the clock the frames are presented against, and where the frame boundaries are. Neither was reachable, so an ASS presenter that works on the native path could not run on the one path that carries VP9, AV1 without hardware decode and MPEG-4 Part 2. `softwarePresentationTimebase` hands out the render synchronizer's timebase. It is the master clock for both renderers, and it reads the source axis, the same axis as the cues, so an overlay paced against it needs no conversion. `setSoftwareVideoFrameTimeObserver` reports every enqueued frame. It takes its own value type rather than reusing `NativeVideoFrameTime`: three of that type's five fields answer questions this path does not have (two axes, a segment index, a producer epoch), and a placeholder is indistinguishable from a measurement at the call site. What this path does have is the presentation time and a flush generation, which carries the epoch's actual job: entries recorded under an older generation describe frames the compositor has discarded, which is what a seek does. Reported at the handover, not at admission, so a frame refused for an unschedulable timestamp, skipped after a seek, or lost to a failed sample-buffer creation is never reported as a boundary that exists. Past the reorder buffer, so unlike the native path's decode-order stream these arrive in ascending presentation order. `aetherctl play --frame-times` exercises both against real media. On a VP9 session over a rate-limited origin: 490 frames reported, 0 out of order, the timebase tracking ftLast about 50 ms behind (that gap is the decode cushion), and a seek at t=12 moving the generation 0 -> 1. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01HX5zV3Fcf7Nzq4DYGdXvQE
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Both halves of #311, which are only useful together: a bitmap overlay (libass) over software-decoded video needs a clock to pace against and the frame boundaries to land on.
What is public now
The timebase is the render synchronizer's, which drives the audio renderer and the display layer both, and it is created unconditionally, so it exists for the whole session even on a source with no audio track. It reads the source axis, the same axis as the cues the engine emits, so nothing needs converting between them.
Why a separate type instead of
NativeVideoFrameTimeThe reporter asked for the existing callback, and the honest answer is that three of that type's five fields have no meaning here.
sourceanditemexist because the native path muxes what it demuxes and the axes differ; here the engine enqueues the source timestamp unchanged.segmentIndexindexes segments this path does not produce.epochkeys a producer restart that does not happen.Filling those with placeholders would put a value in a field a consumer cannot distinguish from a measurement, so
SoftwareVideoFrameTimecarries what this path actually knows.generationkeeps the one jobepochreally does: entries recorded under an older generation describe frames the compositor has thrown away, which is exactly what a seek does. A backward seek makes that concrete, since the same timestamp comes round again and the timestamps alone cannot separate the two runs.Where it is reported
At the handover in
flushFrame, not at admission. A frame refused for an unschedulable timestamp (#298), skipped after a seek, or lost to a failed sample-buffer creation never reaches that line, so it is never reported as a boundary that exists. Being past the reorder buffer also means these arrive in ascending presentation order, unlike the native path's decode-order stream.Verification
aetherctl play --frame-timesinstalls the observer beforeload()(the documented usage: the engine re-arms each new host) and reads the timebase. Real VP9 session over a rate-limited origin, with a seek at t=12:30 to 33 frames per second on 30 fps content,
ftLastrunning about 50 ms ahead of the timebase (that gap is the decode cushion, and its size is why the two have to be on one axis), the generation stepping at the seek, andooo=0over 490 frames, which measures the ascending-order claim rather than asserting it.Unit coverage in
Issue311SoftwareFrameTimesTests: reported in ascending order past a B-frame run, unschedulable and post-seek-skipped frames never reported, generation stepping across a flush with the same timestamp on both sides, observer removal, and both surfaces nil without a software session. Full suite green (1537 tests).Out of scope, as the reporter framed it: the remote-HLS bypass, where AVPlayer owns decode and the engine never sees a frame.