Repository navigation
feat(export): add Turbo export mode using every core - #3479
Merged
Merged
Conversation
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Comment on lines
+648
to
+651
| if !sampled { | ||
| for frame in 0..total_frames { | ||
| worker.request(frame, frame); | ||
| } |
Contributor
There was a problem hiding this comment.
Full Turbo exports queue every audio frame before encoding video. Both channels in ExportAudioWorker are unbounded, and write_through consumes only audio up to the current video frame. If audio runs faster than video, packets for the remaining timeline build up in memory. Long recordings can therefore retain far more audio than the writer currently needs.
Request audio through a bounded lookahead, or otherwise limit how far the audio worker can run ahead.
Knowledge Base Used: Export and editor rendering
Prompt To Fix With AI
This is a comment left during a code review.
Path: crates/export/src/mp4/turbo.rs
Line: 648-651
Comment:
**Audio queues keep growing**
Full Turbo exports queue every audio frame before encoding video. Both channels in `ExportAudioWorker` are unbounded, and `write_through` consumes only audio up to the current video frame. If audio runs faster than video, packets for the remaining timeline build up in memory. Long recordings can therefore retain far more audio than the writer currently needs.
Request audio through a bounded lookahead, or otherwise limit how far the audio worker can run ahead.
**Knowledge Base Used:** [Export and editor rendering](https://app.greptile.com/cap/-/custom-context/knowledge-base/capsoftware/cap/-/docs/export-and-editor-rendering.md)
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.
This comment has been minimized.
This comment has been minimized.
Member
Author
|
hey @greptileai, please re-review the PR |
Member
Author
|
hey @greptileai, please re-review the PR |
This branch was successfully deployed
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.
Turbo export
Adds a Turbo export toggle to the GPUI export page (MP4). It uses much more CPU, GPU and memory to finish 2-2.8x faster on an M4. The standard export is unchanged, byte for byte.
flowchart LR T[Timeline] --> C0[Chunk 0<br/>decoders, render, libx264] T --> C1[Chunk 1<br/>pre-roll, decoders, render, libx264] T --> CN[Chunk N] C0 -->|packets| S[Stitcher<br/>final MP4 + audio] C1 -->|spool file| S CN -->|spool file| S A[Audio worker<br/>whole timeline] --> S S -->|any failure but cancel| F[Standard export]Why the standard export can't go faster on its own
How it works
crates/export/src/mp4/turbo.rssplits the timeline into contiguous chunks: one per 4 cores, up to 4, at least 4 s each. Each chunk gets its own decoders and render loop on its own thread, all sharing one wgpu device.SoftwareEncoderTuningincrates/enc-ffmpeg/src/video/h264.rs:45). The CRF for each preset and frame rate was calibrated so turbo matches or beats VideoToolbox's SSIM and PSNR against a lossless render, at a smaller file:export_prepared_turbo,crates/export/src/mp4.rs:216).estimate_turbo_export,crates/export/src/estimates.rs:136).turbo_available,apps/desktop-gpui/src/editor_export.rs:2978). Windows and Linux run the same pipeline in the verify suite, but their speed is not measured yet.Results
Two real studio recordings (screen, camera, mic) on a Mac mini M4 (10 cores), median of 3 alternating runs with
cargo run --release -p cap-export --example export-turbo-benchmark.mainis the standard export. Turbo uses the default plan (2 chunks).mainmainQuality against a lossless render of the same timeline (PSNR dB / SSIM):
maincrates/verify/tests/export.rs:279) runs turbo split into 3 chunks, so seams land inside cuts, speed changes, reordering, transitions, camera scene changes and VFR holds, and checks every frame on both decoders. It also covers a chunk failure falling back to the standard export, and cancellation by callback and by flag.Standard export unchanged
main(file size, decoded-frame hashes, audio MD5) on both recordings, at the same speed (9.11 s on both).PacketSinkbound onH264Encoder::queue_frame_reusable, an opt-in builder option, and the screenshot path passed explicitly toexport_render_to_channel.map_asynccallback when the submission has finished but the callback has not run yet (mapped_result,crates/rendering/src/frame_pipeline.rs:113). wgpu runs map callbacks on whichever thread's poll collected them, so with several renderers on one device another thread can run a buffer's callback just after this thread's wait returns. Before, that readback failed and the export stopped with a lost frame (seen on the Windows WARP CI runners). A single renderer finds its callback already run, exactly as before.

Confidence Score: 5/5
The latest changes appear safe to merge; the earlier audio-queue concern remains non-blocking.Findings
Fix with agent prompt
Summary
Adds an optional Turbo MP4 export mode that renders and encodes timeline chunks in parallel.
Reviews (3) · Last reviewed commit: "test(verify): cover a failed turbo expor..." · Reviewed by Greptile