Introducing a new way to review your PRs.

Read the announcement

capsoftware / cap

Open source Loom alternative. Beautiful, shareable screen recordings.

View on GitHub

31 documents · Updated Nov 23, 2026

docs / export-and-editor-rendering

Export and editor rendering

Export and editor rendering turn a recorded studio project into an edited view and a final media file. The system uses one project timeline to map source recordings to output time, combines video with visual layers and audio, and sends the result to an interactive preview or a format-specific writer. This page is a child of the recording and media engine; capture supplies the source project through the capture and recording pipeline, and final file packaging is covered by media encoding and muxing.

Editing model

The editor uses a project timeline as the shared description of the final video. A timeline maps source recording segments to output time and carries the visual and audio changes that should be applied when each frame is shown.

Project timeline

The project timeline is the link between recorded media and the edited result. Its main clip track selects ranges from recording segments. Other tracks add transitions, zoom and camera motion, scenes, masks, text, captions, keyboard displays, images, audio visualizers, and imported audio.

The edit remains tied to source media instead of creating a new video for every change. A cut changes clip ranges and shifts the related tracks so overlays and audio stay with the content they describe. Clip transitions reduce the time between adjacent clips and can blend the outgoing and incoming sources.

The editor also supports fullscreen text as a hold. A hold inserts output time without advancing the recording source. The editor therefore keeps a clear difference between recording-flow time and output time when it places overlays or applies a cut.

The project configuration is shared by preview, playback, and export. This gives each path the same clip mapping and visual rules.

References: crates/…/editor_instance.rs• L445-633 crates/…/editor_instance.rs• L926-1061 crates/…/audio.rs• L228-289

Timeline edits

Timeline edits change which source time appears at each output time. The editor updates dependent tracks when a user cuts, deletes, splits, or moves a clip. Transition references are also adjusted so a transition still joins the intended pair of clips after the edit.

Tracks that occupy output time use the same ripple rules as the clip track. When a fullscreen hold exists, the editor first converts the cut range into output time. This prevents a cut in source time from moving an overlay by the wrong amount.

References: apps/…/timeline-utils.ts• L15-245 apps/…/clip-transitions.ts• L248-305

Compositing model

Compositing is the process of combining decoded source images and project graphics into one output frame. The renderer first prepares the active sources for the requested time, then places them in a scene and draws the overlays that belong above the scene.

Source frames

For each output frame, the renderer finds the active timeline clip and asks its media decoders for the screen and camera images at the mapped source time. The decoder contract carries the image size, pixel format, plane layout, color interpretation, and optional platform-backed storage, so the compositor can use the source without forcing every frame through the same memory path.

The decoder chooses a platform hardware path or an FFmpeg path and reports which path is active. It bounds request time, worker lifetime, and fallback behavior. On macOS, the video reader supports projects with many source segments without keeping every native reader active. It creates extra readers only when non-sequential access needs them, limits the number of active readers, and releases idle reader state.

The frame cache has both temporal and byte limits. Sequential export can use a smaller cache than interactive seeking. The decoder also records presentation-time gaps as facts about the source and reuses the frame that remains on screen during each gap. That hold survives seeks, idle pauses, and cache changes. If a reader stops making progress, health checks recreate it; if the macOS reader still cannot return a frame, the decoder can switch to the software path. Cold and idle seeks are expected to return the same source pixels as sequential decoding.

The renderer requests screen and camera frames together when both are needed. It applies clip offsets while it maps output time to recording time, and it can request only the camera when a display image is not part of the result. A missing camera frame can leave the last usable camera image in place, but a render cannot silently use stale display content when no valid display frame exists.

The source color tag travels with the decoded frame. BT.709-tagged sources use BT.709 conversion, while untagged and other sources keep the BT.601-compatible path. The same color choice applies across hardware, software, and GPU conversion paths.

Project media metadata resolves each recording segment into its usable video and audio sources before rendering starts. It uses fast media-header data when that data is complete and falls back to a fuller probe when needed. Video and camera timing must agree; an unusable optional audio track can be omitted without rejecting the video segment.

References: crates/…/mod.rs• L135-162 crates/…/mod.rs• L818-986 crates/…/avassetreader.rs• L33-59 crates/…/avassetreader.rs• L733-750 crates/…/ffmpeg.rs• L197-223 crates/…/frame_converter.rs• L108-207 crates/…/project_recordings.rs• L322-451 crates/…/segment_timing.rs• L12-71

Scene layouts

The camera can appear as an overlay, stay hidden, show alone, or sit beside the screen. The renderer also supports a floating card layout. The scene state changes smoothly over a configured transition instead of switching the two layouts at one instant.

The camera path can apply camera blur without changing the rest of the composition. If the required blur result is not available, the renderer stops rather than producing an export that exposes an image the project asked it to hide.

The scene can also use an animated 3D camera treatment. Its pose and blur are sampled from keyframed properties, and its entry and exit ramp from the flat frame so the content does not jump at a segment boundary. The same sampled state drives preview and export.

References: crates/…/scene.rs• L9-84 crates/…/scene.rs• L110-175 crates/…/camera.rs• L559-635 crates/…/camera3d.rs• L60-184 crates/…/lib.rs• L574-614

Visual layers

The renderer builds the final image from a background and a set of content layers. The layers cover the product's main editing features:

  • Time-based backgrounds such as animated gradients.
  • Screen and camera media with crop, scale, opacity, rounding, border, shadow, and blur.
  • Cursor images, click-ripple effects, cursor motion effects, idle hiding, and click feedback.
  • Frame chrome, notches, and camera-only presentation.
  • Masks, text, keyboard displays, timed captions, and audio visualizers.
  • Color correction and camera or scene effects.

The screen and camera are converted into usable image textures before they are placed. The renderer then draws the background, content group, and annotations in order. Camera effects can change the content group while masks and other annotations remain above it. Time-based backgrounds, cursor effects, and audio visualizers use project frame time, so preview and export show the same animation at the same frame.

An audio visualizer turns the recorded microphone and system-audio waveform levels into timed bars, waves, or circles. It is a visual layer driven by the same audio-level data in preview and export, so it does not need to decode audio again for each frame.

Static background images are reused across editor selections, preview renders, and exports. The background path is checked before it is loaded, large images are reduced to a safe size, and a failed image falls back to a solid background. When the output size changes, the image crop is rebuilt for the new aspect ratio. A static blurred result can also be reused when its background, blur setting, output size, and source texture still match.

The composite path also applies bounded color correction. The correction is deterministic per frame, which keeps color, grain, and vignette behavior consistent between preview and export.

Cursor effects remain tied to recorded cursor events. The cursor layer can show a selected cursor asset, motion blur, click shrink, idle fade, and a bounded set of click ripples. When smoothing is enabled, the renderer prepares a cursor timeline from the recorded moves and clicks. It removes small shake and excess samples, compensates for spring lag, and can anticipate an upcoming primary-button press. A held primary button keeps the cursor on the drag path, while the cursor icon still follows the current event time rather than the look-ahead target.

Interaction and hover anchors can tighten the smoothed cursor near visible actions. The timeline uses these anchors without changing the source event stream, so playback, seeking, and export keep the same cursor path while still meeting the points that matter on screen.

Cursor motion blur scales with per-frame travel and the project amount. Finite positions outside the visible display are clipped by the display bounds instead of being hidden, while non-finite positions are hidden. Cursor style changes use bounded cached timeline variants without changing the source event stream.

References: crates/…/mod.rs• L79-94 crates/…/background.rs• L67-245 crates/…/background.rs• L350-535 crates/…/composite_frame.rs• L68-214 crates/…/cursor.rs• L442-671 crates/…/audio_visualizer.rs• L18-190 crates/…/cursor_interpolation.rs• L391-587 crates/…/cursor_interpolation.rs• L745-881

Screen enhancement

Screen enhancement improves still or enlarged screen content for paused previews and exports. Playback keeps the plain screen path so real-time motion does not pay for work that is most useful when the frame is being inspected or written to a file.

The enhancement can reduce color bands and can use a learned 2x screen upscaler when the screen is magnified and moving slowly enough for the result to remain stable. It limits work to the visible screen region and falls back to the normal sample when the region or graphics device cannot support the enhanced path. A paused preview uses the same quality rules as export.

References: crates/…/screen_enhance.rs• L6-20 crates/…/screen_enhance.rs• L135-208 crates/…/screen_enhance.rs• L589-765 crates/…/screen_upscale_net.rs• L85-98 crates/…/display.rs• L118-218 crates/…/screen_enhance_render_tests.rs• L158-205

Text and caption overlays

Text overlays are timed project elements with a position, size, alignment, color, and optional animation. The text path supports backgrounds, strokes, shadows, glow, gradients, wipes, and staggered reveals while keeping each element tied to its timeline track.

Captions are a related timed layer that can show the active spoken words. They can fade, bounce, pop, or highlight the current word. A caption's visible lifetime is bounded by its spoken words, so transcription data with an inflated trailing word does not keep a caption on screen for an unrelated silence. Caption layout also reports the drawn position and resting frame box so editor placement can follow what the renderer actually displayed.

Keyboard displays use the same text system and can move away from captions when both occupy the same screen lane. This includes manually placed captions and keyboard positions that use the caption lane. The renderer shapes text with font family choices that match the editor's generic font choices. The same output scaling and layout bounds apply to preview and export, which keeps line wrapping and overlay placement close to the pixels the user approved.

References: crates/…/text.rs• L351-399 crates/…/text.rs• L442-759 crates/…/captions.rs• L457-464 crates/…/captions.rs• L688-757 crates/…/captions.rs• L1076-1087 crates/…/keyboard.rs• L59-160 crates/…/keyboard.rs• L302-515

Zoom motion

Zoom motion follows a deterministic timeline in project output time. Manual targets and cursor-following targets are mapped through cuts, transitions, crops, and fullscreen holds before a spring model smooths the zoom amount, focus center, and active state.

The zoom path prepares cursor movement into focus clusters and maps raw display coordinates into the cropped content area. It can pre-aim an incoming zoom while the view is still at full size, and it can snap explicitly instant animations without carrying motion into the next segment. Lazy preparation keeps the render hot path small, while the same sampled timeline makes playback, seeking, preview, and export agree.

The timeline keeps separate recording time and output time when a cut, transition, or fullscreen hold changes the mapping. It can retain valid samples when an edit changes unrelated visual settings, but it rebuilds them when framing, crop, timing, spring settings, or transition state changes.

References: crates/…/zoom_spring.rs• L1-26 crates/…/zoom_spring.rs• L360-457 crates/…/zoom_spring.rs• L471-559 crates/…/zoom_spring.rs• L803-929 crates/…/zoom_spring.rs• L1117-1173 crates/…/spring_mass_damper.rs• L164-299

Editor preview

The editor preview is a time-sensitive version of the rendering path used for export. It favors the newest requested frame so scrubbing and live playback respond to user input instead of processing every old request.

Scrubbing

When the playhead moves, the preview renderer maps the requested output time to a source clip, decodes the needed source frames, builds the current visual state, and returns one composited image. New requests replace older queued requests, but a request that is already being rendered is allowed to finish when the last frame was presented too recently. This keeps rapid scrubbing responsive without starving the preview completely. After a successful render, the renderer can prefetch nearby frames to make the next scrub or play action faster.

Preview zoom, cursor motion, and paused screen enhancement use cached or precomputed timelines that are shared in meaning with playback and export. A project change clears the affected preview timelines so a new edit cannot reuse motion or image processing derived from older project state.

Export preview can borrow the open editor's decoders and GPU resources. It pauses idle prefetch while the representative frame is rendered, then releases that guard when the preview ends. This avoids a cold render session for each request and prevents prefetch from competing with export-preview work.

When the export page uses the open editor, it normalizes missing default timeline data and synchronizes legacy keyboard and caption data for the preview. It uses this working configuration without changing the saved project. Caption visibility follows the current caption setting rather than a stale legacy export flag.

For a recording that is still being finalized, the preparing preview exposes a smaller, progressive view of the unchanged stopped timeline. It opens only the source segments needed for current requests, reports the playable prefix, retries short-lived render errors, and discards a frame when a newer request has replaced it.

References: crates/…/preview.rs• L42-214 crates/…/preview.rs• L216-440 crates/…/editor_instance.rs• L1091-1522 crates/…/editor.rs• L243-553 crates/…/preparing_preview.rs• L506-724 crates/…/display.rs• L118-218

Playback

Playback adds a clock and audio output around the frame renderer. It warms a set of decoded frames before it starts, keeps more frames ahead while it runs, and uses a short cache around the current position. The prefetch limit follows both frame size and a byte budget. A short boost gives playback more runway after starvation, then returns it to the normal limit. A seek re-anchors the clock and audio playhead without rebuilding the whole editor instance.

If decoding falls behind real time, playback can skip ahead and report the skip. Export does not use this real-time skip behavior; it renders the full output frame range.

The normal editor session keeps one persistent audio output available and attaches each playback source to it. The stream can be prewarmed before the first play and can pause after a long idle period on outputs that support fast restart. The clock starts only after the output confirms that it is consuming audio, while a video-only session can continue when no usable output device exists. A headless output follows the same source and timing rules for tests and playback measurements without requiring a sound device.

The following flow shows how one timeline position becomes a preview or playback frame.

flowchart LR
    Playhead[Output time or playhead] --> Map[Timeline clip and source-time mapping]
    Map --> Decode[Screen and camera source frames]
    Map --> State[Scene, zoom, cursor, and overlay state]
    Decode --> Compose[Composite one output frame]
    State --> Compose
    Compose --> Preview[Preview image]
    Compose --> Playback[Timed playback frame]
    Audio[Recording audio and music] --> Playback

References: crates/…/playback.rs• L36-50 crates/…/playback.rs• L653-768 crates/…/playback.rs• L1011-1059 crates/…/playback.rs• L1419-1464 crates/…/playback.rs• L1548-1669

Preparing playback

Preparing playback is the bridge from a recording that is still loading to the ordinary editor session. It progressively mixes declared microphone and system-audio tracks, reports the earliest time that has both video and required audio, and allows playback only within that ready prefix.

The preparing session can finish audio while the user watches the early preview. It keeps required audio output awake while preparing playback runs. A validated handoff transfers completed audio to an editor instance only when the project path, track identities, and shared audio output still match. The editor then adopts the active position and playback intent instead of starting again from zero.

This handoff keeps source preparation separate from ordinary project loading. If the project changes in a way that invalidates the candidate, the editor stops it and can recreate the candidate rather than mixing stale audio with new media.

References: crates/…/mixer.rs• L14-191 crates/…/mixer.rs• L208-442 crates/…/preparing_playback.rs• L142-277 crates/…/preparing_playback.rs• L366-454 crates/…/preparing_handoff.rs• L241-300 crates/…/editor_instance.rs• L706-829

Playback audio

Playback audio combines microphone, system sound, and timeline music on the same output-time clock as the video. It applies clip offsets and timing repair, gain and mute choices, stereo mode, microphone improvement, speed rules, transitions, and music fades before the output device consumes samples.

The normal path uses decoded segment audio. A hard cut between unrelated source ranges gets a short fade on both sides to avoid a click. Transitions mix outgoing and incoming audio, while a fullscreen hold pauses recording audio and lets output-time music continue. The preparing path can use progressive audio windows, so a long recording becomes playable as its sources arrive. Its layout is limited to the unchanged stopped 1x timeline; ordinary playback takes over when richer edits need support.

A bounded queue separates mixing from the real-time output callback and reports buffering, audible playhead position, completion, and failure to the playback clock. The persistent output keeps device wake-up and source replacement outside the video clock, so a pause or device restart does not silently move the visual playhead ahead of audible audio.

References: crates/…/audio.rs• L255-458 crates/…/audio.rs• L484-642 crates/…/audio.rs• L736-871 crates/…/audio.rs• L1419-1528 crates/…/join_fade.rs• L3-73 crates/…/mixer.rs• L39-121 crates/…/mixer.rs• L243-442

Performance benchmarks

The editor benchmark tools measure the cost of the same decode, compose, and playback paths used by the application. They separate decode-only work, full frame rendering, scrubbing, warmup, audio readiness, output delivery, and frame skips so performance changes can be compared by stage rather than by one total time.

The measurements can use different output sizes and decoder paths. Live-edit runs also change selected project settings while playback is active. These tools expose whether a change keeps the preview responsive while preserving the shared rendering rules.

References: crates/…/playback-pipeline-benchmark.rs• L339-412 crates/…/playback-pipeline-benchmark.rs• L422-612 crates/…/playback-pipeline-benchmark.rs• L615-820 crates/…/editor-playback-benchmark.rs• L78-279 crates/…/editor-playback-benchmark.rs• L683-842

Export pipeline

Export runs the project through a deterministic frame pipeline rather than recording the preview surface. It loads the project and source media, resolves the output size and frame rate, renders every required frame, and passes those frames with mixed audio to the selected output writer.

Export preparation

The export builder loads recording metadata and the project configuration. For a fresh recording with no timeline, it creates the same full-length timeline that the editor would create. It also fills missing clip offsets, clamps the timeline to available sources, and synchronizes legacy keyboard and caption data before it measures the export duration.

Export preparation can choose a streaming audio path for eligible MP4 jobs. That path opens source audio early while video decoders prepare, then keeps source validation separate from video setup. Other jobs fully load their audio before rendering so a missing track does not remain hidden until late in the export. Export preserves the loaded caption settings rather than changing the saved project configuration. The eager and streaming paths have a comparison example so changes to preparation time, first progress, and memory use can be measured against the same project.

Cursor-only export uses a derived project configuration. It removes visible media pixels and unrelated overlays but preserves the timing structure that affects frame count and cursor motion. The derived configuration does not change the saved editor project.

New destinations are staged beside the requested path. The final path is published only after the selected writer finishes. A failed or cancelled export therefore does not leave a partial new file at the destination.

Export activity also marks the process as busy so background hover analysis can step aside while a render runs. The marker is released when the export ends, including when the job stops through cancellation or failure.

References: crates/…/lib.rs• L116-265 crates/…/lib.rs• L289-419 crates/…/estimates.rs• L169-199 crates/…/export-path-comparison.rs• L25-92 crates/…/export_activity.rs• L1-24

Export audio

Export audio turns recording microphone and system sound sources into samples that match the edited video. It groups sources by recording segment, applies clip offsets and timing repair, then applies project volume, mute, channel, speed, transition, and microphone-improvement rules as it produces the final audio stream.

Eligible MP4 jobs can open several source tracks in parallel and render audio beside video. Audio is budgeted from the video frame grid, so each frame receives the samples up to its next frame boundary and the encoded timestamps stay contiguous. A bounded lag limit lets video and AAC work at the same time without allowing audio to drift far behind.

The audio path reads sources in bounded groups and can stop the full export when a source fails or the user cancels. It also validates sources that are no longer used by the visible timeline. This catches a bad recording input instead of silently producing a file that differs from the project's expected audio. If more than one part of the MP4 pipeline fails, source errors keep their source order and take priority over cancellation.

Streaming audio is selected only for timelines whose timing and feature shape it can represent safely. Projects with timeline music, speed changes, complex transitions, or unsupported holds use the full audio path. When the project uses timeline music, the editor loads the needed source ranges and mixes them in output time. Missing music is skipped for playback and export, while recording audio remains subject to the stricter export validation path.

References: crates/…/export_audio.rs• L93-187 crates/…/export_audio.rs• L189-359 crates/…/export_audio.rs• L374-430 crates/…/export_audio.rs• L470-574 crates/…/audio.rs• L295-458 crates/…/mp4.rs• L1068-1297

Frame rendering

The export loop advances through the output frame range. For each frame it maps output time to source time, decodes the needed source images, prepares the shared cursor and zoom timelines, renders the current scene, and sends the result to the output queue. Transition frames render the outgoing and incoming scenes before applying the selected transition. Camera 3D state is sampled as part of the scene, so keyframed pose and blur follow the same frame time as the other visual layers.

Cursor, zoom, and screen-enhancement state are prepared once per recording segment where possible and then sampled at each output frame. This keeps raw cursor timing, smoothed motion, click anticipation, zoom focus, and image treatment consistent across the full export rather than rebuilding the motion model for every frame.

The renderer can produce a general RGBA frame or an NV12 frame for the MP4 path. A bounded queue separates rendering from encoding, so a slow writer applies back pressure instead of allowing unbounded frame growth. The render loop can also render selected windows for estimates and previews.

The renderer retries short-lived decode and render failures. After a frame has succeeded, a later failed frame can use the last successful image under the renderer's fallback rules. Failure to obtain an initial frame or too many consecutive failures stops the job instead of hiding a broken source in the final file.

References: crates/…/lib.rs• L623-1070 crates/…/lib.rs• L1190-1818 crates/…/mod.rs• L888-986 crates/…/mod.rs• L1122-1141 crates/…/display.rs• L689-1127 crates/…/cursor_interpolation.rs• L457-587 crates/…/mp4.rs• L385-877

Turbo MP4 export

Turbo MP4 export is a parallel path for projects that need higher throughput. It divides the output frame range into contiguous chunks, renders and software-encodes the chunks at the same time, then joins them in order into one MP4 while keeping the same project timing and visual rules.

Each later chunk renders a short lead-in before its first published frame. This carries stateful visual effects across chunk boundaries. The join step checks frame order and H.264 parameter compatibility before it publishes the result. The path stages new destinations and can fall back to the standard MP4 pipeline when turbo fails, unless the caller requests strict behavior.

Turbo uses the same audio timeline and cancellation contract as standard MP4 export. Estimates can sample the turbo path itself, so a user sees time and size predictions for the path that will run.

References: crates/…/turbo.rs• L1-15 crates/…/turbo.rs• L64-115 crates/…/turbo.rs• L206-265 crates/…/turbo.rs• L575-763 crates/…/turbo.rs• L789-1084 crates/…/export-turbo-benchmark.rs• L34-98

Platform render paths

The render path keeps pixels on the GPU when the platform and encoder support it, while retaining CPU readback as the common fallback. The compositor converts the finished image to NV12 for MP4 output and carries frame size, stride, frame number, frame rate, and color meaning with the data.

On macOS, MP4 export can pass an IOSurface-backed NV12 frame to VideoToolbox without a CPU copy. On Linux, an opt-in device-memory path can pass NV12 frames through shared GPU buffers. If these paths are unavailable or fail, the renderer uses CPU-visible buffers and the export still follows the same frame contract.

Readback and device work have bounded waits. YUV dimensions and strides are checked before conversion. A failed conversion or GPU handoff must be reported to the owning render path so it cannot encode an earlier frame as if it were current.

References: crates/…/frame_pipeline.rs• L17-40 crates/…/frame_pipeline.rs• L228-249 crates/…/frame_pipeline.rs• L602-723 crates/…/frame_pipeline.rs• L765-921 crates/…/frame_pipeline.rs• L1062-1218 crates/…/cpu_yuv.rs• L96-150 crates/…/mp4.rs• L516-710

Output formats

Export settings select the container, frame rate, output size, and format-specific quality controls. Each writer receives the same composited timeline frames but chooses a delivery format and audio policy suited to its use.

DeliverableVideo pathAudio pathMain use
MP4H.264-oriented NV12 pipeline with hardware input when available, or standard and turbo software pathsMixed recording audio and music as AAC when presentGeneral video export and sharing
GIFRendered RGBA framesNo audioShort image animation
MOVRendered RGBA frames encoded as ProResNo audio in this pathHigh-quality or transparent cursor-only output

The MP4 path keeps audio samples on the video frame grid. It renders into a temporary output and publishes the final path only after encoding, validation, and cancellation checks succeed. The MP4 writer also returns a path with the .mp4 extension even when the requested path has another extension. GIF uses the same staging rule for new destinations. MOV also renders into a temporary sibling file and replaces or creates the requested destination only after the writer finishes. Cancellation, encoder failure, or a failed replacement leaves an existing destination unchanged and removes the temporary owner when it is released. Detailed codec and container contracts belong to media encoding and muxing.

References: crates/…/settings.rs• L8-39 crates/…/mp4.rs• L306-337 crates/…/mp4.rs• L756-881 crates/…/turbo.rs• L997-1084 crates/…/gif.rs• L71-193 crates/…/mov.rs• L55-176 crates/…/mp4_output_path.rs• L44-81

Export preview and estimates

The export screen renders a representative frame with the same project settings as the final job. It returns the image, the actual output size, the total frame count, the render time, and an estimated file size so a user can review settings before starting a long export.

Estimates use sampled frame windows rather than treating one frame as a guarantee. They measure render pace and encoded packet size, account for encoder warm-up and keyframe behavior, and return a central estimate with a range. A short-lived cache avoids repeating the same sample for the same project and settings. MP4 estimates can use the turbo encoder's sampling plan when the final job uses turbo. The preview benchmark records the cost and result shape of a preview with either a loaded project configuration or the normal project load path, which helps compare changes to preview preparation and audio readiness.

The preview can use the open editor's decoders and rendering resources. It pauses idle editor prefetch while the representative frame is rendered, then releases that guard when the preview ends. It also handles transition frames and cursor-only settings through the same project rules used by export.

Benchmark runs define throughput and estimation goals across MP4 and GIF presets. The editor playback benchmarks also compare decode, render, scrubbing, warmup, audio, and callback costs. Their recorded results provide calibration data for later estimate changes rather than a guarantee for every preset.

References: crates/…/preview.rs• L42-214 crates/…/preview.rs• L216-440 crates/…/estimates.rs• L123-250 crates/…/estimates.rs• L276-450 crates/…/estimates.rs• L460-821 crates/…/editor-playback-benchmark.rs• L78-279 crates/…/playback-pipeline-benchmark.rs• L45-85 crates/…/EXPORT-BENCHMARKS.md• L1-14 crates/…/EXPORT-BENCHMARKS.md• L49-119

Desktop export lifecycle

The desktop client presents export as a separate lifecycle with starting, rendering, copying, uploading, done, and failed states. It sends settings to the export service, receives frame progress, and can cancel the active job. File export may copy the generated artifact to a user-selected path. Link export uploads the generated artifact after rendering and then returns a shareable link.

The desktop app pauses the live editor preview for the duration of an export. On macOS and Windows it can run the export worker outside the main application process. A worker failure can trigger a safer software-rendering retry, while a frame decode failure can trigger an FFmpeg decoder retry.

References: apps/…/editor_export.rs• L131-186 apps/…/editor_export.rs• L476-659 apps/…/export.rs• L479-663 apps/…/export.rs• L1158-1266

Change checklist

When these files or sections are changed, remember to consider these:

  • Keep timeline time conversion identical in the editor, preview, playback loop, export loop, zoom timeline, and audio renderer. Fullscreen holds must not shift overlays or change frame counts in only one path.
  • Keep export preparation aligned with the editor's default timeline, clip-offset rules, source clamping, and legacy keyboard or caption synchronization. A raw recording must export like the same recording after the editor opens it.
  • Keep preview normalization and caption enablement aligned with export preparation. The preview must use a working configuration without writing it back or applying a stale legacy export flag.
  • Keep source frame mapping and clip audio offsets aligned. A visual clip change without the matching audio mapping can create an audio/video shift.
  • Keep audio source order, timing repair, speed rules, transitions, hard-cut fades, and frame-grid sample budgeting aligned. A change in one can produce a valid file with the wrong source alignment or duration.
  • Keep audio visualizer levels and output-time placement aligned with the audio mixer. A visualizer must not use source time when the edited audio uses output time.
  • Keep progressive preparing-audio limits aligned with the ordinary audio renderer. Its supported stopped 1x layout must not be widened in one readiness path only.
  • Keep the streaming audio eligibility rules aligned with the MP4 worker, unused-source validation, cancellation state, and standard-export restart. A new timeline feature may require the full audio path.
  • Keep MP4 hardware input selection, NV12 metadata, encoder retry, turbo fallback, and staged publication aligned. A retry must start from fresh decoders and a fresh output owner.
  • Keep the MP4 output-path contract aligned with the writer and its callers. The returned path must use the actual .mp4 file that was written, including when the requested path has another extension.
  • Keep turbo chunk boundaries, preroll, progress counts, packet timestamps, parameter sets, and stitch order aligned. A chunk can look valid alone but be invalid in the final stream.
  • Keep sampled estimate plans aligned with the selected encoder and benchmark presets. Hardware, standard software, turbo, GIF, and MOV do not have the same warm-up or size behavior.
  • Keep GPU output ownership, plane stride, frame number, color interpretation, bounded waits, and writer selection aligned. A recycled surface or shared buffer must remain valid until encoding has finished with it.
  • Keep source color tags aligned across header probes, decoders, YUV conversion, compositing, and MP4 output. A BT.709 source must not change matrix when it moves between hardware and software paths.
  • Keep screen-enhancement quality gates aligned between project settings, paused preview, export, and playback. Playback must remain unenhanced while paused preview and export remain equivalent.
  • Keep caption effective time, word timing, layout position, font choice, and overlay order aligned between editor placement, preview, and export.
  • Keep keyboard lane resolution aligned with the caption layout that was actually drawn. Manual caption placement can create an overlap even when the two settings use different named positions.
  • Keep cursor and zoom settings tied to the same recording events and project revision. Cursor style variants must not change the source event stream, and a drag must not be redirected toward a later click.
  • Keep playback prefetch byte limits, seek generations, starvation recovery, and audio clock handoff aligned. A buffer policy change must not cause old frames or silent clock drift.
  • Keep cancellation and editor pause guards released on every render, encode, validation, staging, retry, copy, and upload path. Export activity guards must also end when a worker fails.

Important failure modes

TriggerConsequenceGuard
A project has no usable timeline or no source segmentNo frame can be mapped, so export can otherwise create an empty artifact.Synthesize a full-length default timeline for raw studio projects and reject zero-frame results.
A source display frame cannot be decoded or uploadedPreview shows an error; export retries and then fails if it has no usable first frame or too many failures.Decoder retry, frame failure limits, and first-frame validation.
A decoder cannot initialize its preferred hardware pathThe source may fail to open or can become slower than expected.Platform decoder fallback to FFmpeg or software decoding, with initialization timeouts and status reporting.
A variable-frame-rate source has a presentation-time gapA request can show the wrong frame or advance through a false blank interval.Track presentation-time holes and hold the latest valid frame until the next decoded frame.
A source has incomplete video metadata or mismatched camera timingThe segment cannot be mapped safely, or the camera can be paired with the wrong recording time.Probe complete media metadata before rendering and reject mismatched required video timing.
A preparing audio track is incomplete, missing, or fails lateThe playable prefix stops before that clip or the preparing session becomes unavailable.Required-track validation, progressive readiness, terminal-source checks, and bounded cleanup.
Completed preparing audio belongs to another project or changed track identityThe editor could reuse stale decoded audio or refuse a valid handoff.Project-path and per-track identity checks before adoption.
A preparing-audio project uses speed changes, transitions, holds, or timeline musicThe progressive mixer cannot represent the layout and playback can stop or use the wrong samples.Validate the stopped 1x shape and hand off to ordinary playback for richer timelines.
A transition or overlay keeps an old clip index after an editThe transition or overlay is applied to the wrong clip or time range.Update dependent tracks and transition indexes during split, delete, and move operations.
Recording-flow time is used where output time includes a fullscreen holdText, masks, captions, zoom, or audio tracks move out of sync with the visible edit.Convert ranges through hold windows before shifting output tracks.
A hard cut between unrelated source ranges has no join fadeAudio can click at the output boundary.Derive joins in output time and apply a short fade on both sides, excluding transitions and continuous splits.
A caption word has an inflated end timeA caption stays visible across a long silence.Bound the effective caption end by the shared maximum word duration.
Caption and keyboard boxes overlap in the same laneThe overlays cover each other or the keyboard display hides caption text.Resolve keyboard placement from the rendered caption box, including manual caption positions.
Cursor or zoom settings use a timeline from another recording or stale project revisionMotion can look valid but follow the wrong source events or old edit ranges.Scope precomputed variants to their source event stream and clear them when project state changes.
A primary-button drag is treated as an upcoming click targetThe smoothed cursor pulls toward the release or a later press while the pointer is still dragging.Anticipate presses only while the primary button is up and keep the drag on the recorded path.
A cursor position is non-finite or outside the visible displayNon-finite data can produce invalid GPU content; an out-of-band finite position can pop instead of sliding at the display edge.Hide non-finite positions and clip finite positions through display bounds.
Screen enhancement runs during real-time playbackPlayback can lose responsiveness or show a different quality path than the user expects.Restrict enhancement to paused preview and export.
An enhancement region is off-screen or exceeds device limitsThe enhanced texture cannot be made safely and the frame may fail or use invalid bounds.Limit enhancement to the visible region and use the plain screen sample when the region is unsupported.
A GPU readback, IOSurface handoff, shared GPU buffer, or RGBA-to-NV12 conversion does not completeA frame render fails, stalls, or can otherwise reuse stale pixels.Bounded waits, metadata and plane validation, render retries, and CPU fallback.
A preview frame has zero dimensions, overlapping rows, or a short pixel bufferThe export preview cannot be converted to its JPEG response.Validate dimensions, row stride, and required buffer length before encoding.
A recycled platform surface is released before submitted GPU work finishesA later frame can replace source pixels while an earlier frame is still being converted.Retain a bounded set of surfaces until the sampling window has passed.
A turbo chunk stops, has a different parameter set, or reaches the stitcher out of orderThe turbo output is rejected instead of producing a file with a broken stream.Shared stop state, chunk result checks, preroll, frame-count checks, and parameter-set validation.
Turbo export fails after a new destination was stagedA partial result could be mistaken for the final deliverable or a fallback could overwrite a new file.Keep the temporary owner alive, publish only after success, and fall back only when the destination remains safe.
An MP4 audio worker or unused-source validator fails while video is renderingVideo work can continue or cancellation can hide the source error.Notify the render path, abort shared work, and resolve source failures before interruption.
A hardware MP4 encoder fails after frames have been sentThe output attempt fails even though the project and rendered frames are valid.Reopen the streaming inputs and retry once with the software encoder, except for sampled estimates or cancelled jobs.
Audio sample budgets are not derived from the video frame gridAudio timestamps can overlap or leave gaps, which causes drift or a duration mismatch.Monotonic frame-grid budgeting and contiguous sample cursors.
A new destination cannot be staged or cancellation arrives before publicationA partial file can be mistaken for a completed deliverable.Fail staging early, keep temporary output owned by active workers, and publish only after all pipeline results succeed.
A caller requests an MP4 path with a non-MP4 extensionThe writer creates an MP4 at a different path than the caller expects, or the caller reports a path that was not written.Normalize the destination to .mp4 before writing and return that actual path.
The export worker exits without a valid completion eventThe desktop client cannot trust the output path.Completion-event check, stderr tail reporting, and a safer worker retry.

Key files

FileWhy to read it
crates/…/configuration.rsDefines the project timeline and time rules shared by editing, playback, and export.
apps/…/timeline-utils.tsShows how cuts and ripple edits keep clip and overlay tracks aligned.
apps/…/clip-transitions.tsShows how clip transitions affect timeline duration and source mapping.
crates/…/editor_instance.rsConnects project state, source segments, preparing handoff, preview rendering, and playback.
crates/…/audio.rsShows how recording audio, speed rules, transitions, hard-cut fades, and timeline music share output time.
crates/…/join_fade.rsDefines the short audio fade used at discontinuous clip joins.
crates/…/export_audio.rsShows how export audio sources are opened, aligned, rendered, validated, and stopped on failure.
crates/…/mixer.rsShows the progressive audio readiness boundary and its match with ordinary mixing.
crates/…/audio_output.rsShows the persistent editor audio output and the boundary between playback timing and device output.
crates/…/playback.rsShows frame prefetch, seek handling, clock timing, playback skips, and audio handoff.
crates/…/playback-pipeline-benchmark.rsMeasures decode-only, full render, and scrubbing costs across decoder paths and output sizes.
crates/…/editor-playback-benchmark.rsMeasures live playback warmup, audio readiness, rendering stages, output delivery, and live edits.
crates/…/lib.rsShows the shared frame loop, timeline-to-source mapping, transitions, retries, and RGBA or NV12 output paths.
crates/…/project_recordings.rsShows how project segments resolve source video and audio metadata before rendering.
crates/…/segment_timing.rsShows how display and camera start times become source frame times.
crates/…/mod.rsShows decoder selection, frame formats, color metadata, time requests, bounded worker lifetime, and decoder status.
crates/…/frame_converter.rsShows how decoded planes become usable RGBA data while preserving source color meaning.
crates/…/cursor_interpolation.rsShows the shared cursor timeline for raw motion, smoothing, drag behavior, click anticipation, and visible-action anchors.
crates/…/cursor.rsShows cursor asset selection, placement, idle visibility, click feedback, and motion blur.
crates/…/zoom_spring.rsShows the deterministic zoom timeline shared by preview, playback, and export.
crates/…/spring_mass_damper.rsShows the shared spring behavior used by cursor and zoom motion.
crates/…/audio_visualizer.rsShows how audio levels become the timed visualizer layer.
crates/…/screen_enhance.rsShows when paused preview and export use screen debanding and upscaling.
crates/…/screen_upscale_net.rsShows the screen enhancement model used for enlarged screen content.
crates/…/display.rsShows how decoded screen frames become composited textures and how enhancement joins the display path.
crates/…/composite_frame.rsShows compositing uniforms, deterministic color correction, and enhanced screen sampling.
crates/…/cpu_yuv.rsShows the source color-matrix rules and the BT.709 export conversion reference.
crates/…/lib.rsBuilds the export session, fills raw-project timing data, applies export preparation policy, and selects audio preparation.
crates/…/mp4.rsShows the concurrent rendered-frame and frame-grid audio pipeline, NV12 input selection, hardware retry, validation, cancellation, path normalization, and safe MP4 publication path.
crates/…/turbo.rsShows chunked parallel MP4 rendering, software encoding, preroll, stitching, fallback, and cancellation.
crates/…/estimates.rsShows how sampled render and packet data becomes time and size estimates for standard and turbo paths.
crates/…/EXPORT-BENCHMARKS.mdRecords the throughput targets, tested export presets, and actual-versus-estimated results used to assess export performance.
crates/…/export-turbo-benchmark.rsProvides a command-line benchmark for comparing standard and turbo MP4 export throughput and resource use.
crates/…/export-path-comparison.rsCompares eager and streaming MP4 preparation with first-progress and memory measurements.
crates/…/preview-audio-benchmark.rsMeasures preview preparation time, memory use, output dimensions, and frame count.
crates/…/mp4_output_path.rsVerifies that MP4 export returns and writes the normalized .mp4 destination.
crates/…/gif.rsShows the staged RGBA frame path and cancellation behavior for GIF output.
crates/…/mov.rsShows the RGBA-to-ProRes path, frame timing, temporary output ownership, replacement, and cancellation behavior used for MOV output.
crates/…/preview.rsShows how one export-settings frame becomes the export preview through standalone or shared editor resources.
apps/…/export.rsShows desktop export commands, worker isolation, progress, retry, and cancellation.
apps/…/editor_export.rsShows the user-facing export states, settings, destinations, and upload handoff.