Repository navigation
perf(rendering): read recording metadata from container headers - #2498
Merged
richiemcilroy merged 3 commits intoOct 19, 2026
Merged
Conversation
Contributor
|
@x1xhlol is attempting to deploy a commit to the Cap Software Inc Team on Vercel. A member of the Team first needs to authorize it. |
Contributor
Author
|
@greptileai review |
Member
|
Thanks for this! It now conflicts with main after today's merges. Could you merge or rebase onto the latest main? Once it's up to date I'll run the full engine verify and real-capture suites on it and merge if they pass. |
devin-ai-integration
Bot
force-pushed
the
devin/1791909220-header-media-probe
branch
from
October 18, 2026 18:06
3e2d4e1 to
b1e82e9
Compare
Contributor
Author
|
should be done |
Member
|
@greptileai review |
richiemcilroy
approved these changes
Oct 19, 2026
richiemcilroy
left a comment
Member
There was a problem hiding this comment.
Verified: exports are frame- and audio-identical to the base on 1080p/4K fixtures (-1.1 to -2.0% instructions), and header metadata matches the fully probed metadata (size, fps, duration, sample rate, channels) on all 435 media files of a real recordings library. CI green, Greptile 5/5. Thanks!
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.
Summary
Opening a recording in the editor called
avformat_find_stream_infoon every display, camera and audio file. That call decodes frames to fill in stream info, so for a 3024x1964 H.264 display track it software-decodes video just to learn width, height, fps and duration. MP4 and Ogg headers already contain those values.This PR opens files with
avformat_open_inputonly and reads metadata fromcodecparand the stream/container durations:from_headersreturnsNone(and we fall back to the existing full probe) when the header is incomplete: zero width/height, missingavg_frame_rate, missing sample rate/channels, or no usable duration.header_duration_secsreproduces FFmpeg's container duration calculation from streamstart_time/duration, so header and full-probe durations match.open_fragmented_input.AVAssetReaderDecoder::run(macOS) did a second full probe per decoder just to validate dimensions before signalling ready. It now usesheader_video_metadatafirst and keeps the old probe as the fallback.Tests generate media with ffmpeg-next and check that header metadata matches the full probe for H.264 MP4, Ogg Opus, fragmented AAC
.m4a(written with the recorder'sfrag_keyframe+empty_moov+default_base_moofflags) and WAV. They also check that MPEG-4 video and a fragmented.m4awith no fragments yet both fall back to the full probe, and that a missing file still errors. On the fixture's four.oggtracks, header and full-probe values match exactly.Benchmarks
cargo run --release -p cap-editor --example editor-startup-benchmark -- --recording-path <fresh copy of cap-performance-fixtures/reference-recording.cap> --runs 10 --profile-stages. Three rounds, alternating before/after, fresh fixture copy each run. Before =eefa6ef, after = this branch. Times are means of the per-round averages, in ms.macOS (Apple M4 Pro virtual machine, macOS 26.6.2, 12 vCPU)
Editor max RSS went from about 145 to 107 MiB. Layer warmup runs in parallel and used to finish hidden behind the probe, so it now shows up as the remaining startup cost (about 2 ms to 29 ms in that column).
Linux (8 vCPU, llvmpipe)
1080p export on the same Mac (export also builds
ProjectRecordingsMeta): 7.59 s before, 7.49 s after over 2 alternating runs each, which is within noise. The outputs were identical in shape (1664x1080 H.264, 1850 frames, AAC 1445 frames).Checked on macOS:
cargo fmt --all --check,cargo clippy -p cap-rendering --all-targets -- -D warnings,cargo test -p cap-rendering project_recordings,cargo check -p cap-editor -p cap-export,cargo checkinapps/desktop-gpui. The same commands minus the macOS-only path also pass on Linux. Not measured on physical Apple hardware or Windows. Windows takes the sameProjectRecordingsMetapath.

Confidence Score: 5/5
The PR appears safe to merge; no actionable defects were established.Summary
Reads recording metadata from container headers before trying the existing full probe.
No new actionable issues were found. The previous audio-test concern is addressed. Review checks were static; tests and benchmarks were not rerun.
Reviews (3) · Last reviewed commit: "test(rendering): cover Ogg Opus and frag..." · Reviewed by Greptile