Preview and export
Preview and export turn the editor timeline into something a person can watch, inspect, and save. Preview gives fast control of the current composition while export checks the requested output, hands an export-ready composition to the render system, and stores the result for download. This page is a child of Editor workspace and relates to Timeline editing, Media and scene management, and Effects and animation.
Preview surface
The preview surface shows the active composition at the current playhead position. It combines the composition player with temporary visual layers used for fast scrubbing, transition playback, color comparison, and direct editing overlays. The editor places this surface beside its controls through src/…/preview-area.tsx.
Transport controls
Transport controls move the playhead and control how the composition is watched. Play and pause use the composition player as the source of normal frame progress. Start, end, and single-frame actions commit a seek to the playback store and clear any temporary hover frame first, so a control action cannot return the view to an older scrub position. The controls also expose monitor volume, proxy playback, and frame capture.
References: src/…/playback-controls.tsx• L86-141 src/…/preview-area.tsx• L698-717
Preview preferences
The shared playback store is the source of truth for transport state and preview choices. It keeps the current frame, play state, playback rate, shuttle mode, loop state, monitor gain, mute state, zoom, proxy use, and fast-scrub quality. Device-facing choices such as zoom, monitor volume, mute, loop, proxy use, and preview quality persist between sessions. The current playhead and other active transport state do not persist as an active playback session.
previewFrame is a temporary frame used while the pointer hovers or a scrub is in progress. currentFrame remains the committed playhead. The store uses one frame update order for these values so the preview can move without briefly presenting a stale committed frame. A completed scrub promotes the viewed frame to the committed playhead and clears the temporary state through commitPreviewFrameToCurrentFrame.
References: src/…/types.ts• L24-78 src/…/store.ts• L104-163 src/…/store.ts• L234-278 src/…/preview-handoff.ts• L3-16
Preview bridge
The preview bridge connects the visible preview surface to controls and analysis tools without making those tools own the renderer. It publishes the frame currently shown by a rendered overlay and registers capture functions for a data URL, raw pixels, or a canvas source. It also carries a request to warm likely frames after an edit. These values are transient and describe the mounted preview rather than project data.
Frame capture first prefers the current rendered canvas. If that source is not available, it asks the preview for a captured image. A successful PNG capture downloads the image and, when a project is active, imports the generated image into the media library with a frame-capture tag.
References: src/…/types.ts• L3-37 src/…/store.ts• L32-61 src/…/playback-controls.tsx• L141-217
Preview rendering path
Preview rendering chooses between the composition player and a rendered canvas path. The player is useful when browser video elements can present the frame directly. The rendered path takes ownership when a scrub, transition, effect edit, or other case needs a composed frame that the player cannot show in time. Both paths are driven from the same preview composition model.
Composition player
The preview stage mounts a player with the active composition and passes it the frame rate, duration, render size, and initial committed frame. The player renders MainComposition, which resolves tracks, media sources, transitions, keyframes, masks, effects, and audio into the visible composition. The preview can ask the composition to use proxy media when that preference is enabled.
The player reports frame and play-state changes back to the preview controller. During ordinary playback those reports advance the committed playhead. During a transient scrub they do not replace the temporary preview frame. This separation lets the timeline and preview share one playhead without letting a delayed browser event undo a user action.
References: src/…/preview-stage.tsx• L404-426 src/…/use-preview-playback-controller.ts• L75-155 src/…/main-composition.tsx• L203-260
Fast scrub rendering
Fast scrub rendering is a second preview path for frames that need direct composition rendering. A single render pump owns the asynchronous work. It keeps the newest priority frame, abandons stale generations after async work, and uses background work only when no urgent frame waits. It may prewarm nearby frames and sources so the next visible frame is ready sooner.
The rendered frame is built off screen before it reaches the display canvas. The bridge records the displayed frame only after presentation. During playback, a display-timed loop presents ready frames or queues only the latest target for the pump. This gives the controls and comparison views a reliable view of what the user can see while one render owner prevents capture, scrubbing, and playback transitions from writing to the same surface at the same time.
References: src/…/use-preview-render-pump-controller.ts• L636-646 src/…/use-preview-render-pump-controller.ts• L774-800 src/…/use-preview-render-pump-controller.ts• L1310-1344 src/…/use-preview-render-pump-controller.ts• L1353-1403 src/…/use-preview-renderer-controller.ts• L606-747
Decoder prewarm worker
The decoder prewarm worker moves background video seeking away from the main thread. It keeps source-level decoder state and returns decoded image data that the preview render pump can use. The worker is a readiness aid, not a separate composition renderer. The visible frame still passes through the preview composition renderer so transforms, effects, layers, and transitions remain part of the result.
The preview can fall back to browser video elements or to another decode path when the worker cannot prepare a source. This keeps prewarm failures from becoming preview failures.
References: src/…/decoder-prewarm-worker.ts• L1-7 src/…/decoder-prewarm-worker.ts• L76-145 src/…/use-preview-render-pump-controller.ts• L951-1035
Preview quality and source choice
Preview source choice balances speed with image quality. Proxy media can reduce decode cost during normal playback. Fast scrubbing can use a lower render scale, nearby-frame prewarm, cached frames, and direct browser video sources. The system changes the presentation path when a transition or an effect needs a fully composed frame. Export does not use these preview shortcuts.
The preview also adapts its fast-scrub quality when observed frame work exceeds the playback budget. The user-selected quality is the upper preference; the runtime can lower its active cap while playback is under load.
References: src/…/types.ts• L64-78 src/…/use-preview-playback-controller.ts• L48-63 src/…/frame-source-policy.ts• L1-16 src/…/frame-source-policy.ts• L213-257
Export workflow
Export converts a selected timeline or sequence into a saved video or audio file. The export dialog is the user-facing boundary. It selects the sequence, range, output mode, format, quality, resolution, rate control, subtitle behavior, and smart-copy preference. It then either starts one export now or creates one or more jobs for the render queue.
Export selection
The dialog reads the selected sequence as an export view rather than changing the editor timeline. It can export the active range defined by in and out points or the whole project. It can also split that range into marker-based or fixed-duration jobs. A selected sequence is read again when a queue action is chosen, so the queued work reflects the latest editor state.
Video exports support browser-compatible containers and codecs. Audio exports use an audio-only container. Transcript captions can be omitted, burned into video, embedded when the container supports a toggleable track, or written as a sidecar SRT file. Resolution choices keep the project aspect ratio and use encoder-safe dimensions.
References: src/…/export-dialog.tsx• L304-433 src/…/export-dialog.tsx• L632-739 src/…/export.ts• L6-73
Export preflight
Preflight checks whether the requested output can run before the user starts it. It checks the range, referenced media, output settings, codec support, likely render path, estimated size, and estimated duration. Errors disable the export action. Warnings and information explain a fallback or a cost without blocking the user.
The settings view presents the preflight result as a short report. It shows the worst severity, the predicted path, and the most useful checks rather than the full diagnostic set. The report distinguishes smart copy, worker rendering, and main-thread fallback so the user can understand the expected cost before starting.
Smart copy is the shortest path. It is allowed only when the timeline is a matching full-source video with no range cut, retiming, visual change, or audio change. When it is eligible, the system copies the original media bytes instead of rendering new frames. Otherwise the export uses the composition render path.
References: src/…/export-dialog.tsx• L443-473 src/…/export-settings-view.tsx• L26-52 src/…/export-preflight-panel.tsx• L28-79 src/…/export-preflight.ts• L381-520 src/…/smart-copy.ts• L283-335 src/…/smart-copy.ts• L342-373
Composition handoff
The preview and export paths meet at composition input: a frame-based description of tracks, items, transitions, keyframes, canvas size, background, and project audio settings. The handoff preserves the project’s visual and audio meaning while allowing each consumer to choose its own source and output strategy.
Timeline conversion
For export, timeline data is converted into an export composition before rendering. The conversion applies effective track state, trims the selected range, shifts item positions to the export start, adjusts media timing, filters transitions, and prepares keyframes for trimmed or split items. It also adds virtual transcript caption content when needed. This creates a self-contained composition whose frame zero is the start of the requested export range.
The export uses project resolution as the composition space. The output resolution is applied later by the render pipeline. This keeps transform behavior aligned with the preview even when the user chooses a smaller output.
References: src/…/timeline-to-composition.ts• L26-53 src/…/timeline-to-composition.ts• L58-217 src/…/timeline-to-composition.ts• L249-260
Render engine handoff
After conversion, export resolves media IDs to full-resolution source URLs. It then gives the composition and resolved client settings to runRender. Export reaches the render engine through src/…/renderer.ts, which exposes the shared settings, result, capability, and render-pipeline contract without making export code depend on renderer internals. This shared pipeline is used by both immediate export and queued export, which keeps codec selection and worker fallback consistent.
The render pipeline first tries a dedicated export worker. The worker renders video or audio and reports progress, completion, cancellation, or an error. If the browser cannot run the job in that worker, the pipeline retries on the main thread for known cases such as animated images, missing offline audio support, worker unavailability, or worker runtime failure. A cancellation signal reaches the active render and stops the work.
The composition renderer then produces video frames and composition audio for the encoder. The result is a media blob with its type, duration, and size. A completed immediate export can play in the export dialog before the user downloads it.
References: src/…/renderer.ts• L1-5 src/…/renderer-contract.ts• L1-41 src/…/use-client-render.ts• L140-250 src/…/render-pipeline.ts• L248-303 src/…/export-render.worker.ts• L86-176 src/…/canvas-render-orchestrator.ts• L765-876
Render queue
The render queue separates export setup from render time. It lets the user add the current range or several segments and then continue editing while jobs run in the background. The queue runner processes one job at a time because the browser’s shared graphics device is not a safe place for competing export renders.
Job snapshots
Each queued job stores a frozen copy of the chosen sequence and its project audio and canvas settings. Later edits do not change the output of that job. The job also stores the range, output settings, status, progress, file name, and eventual saved path. Segment jobs share one captured timeline snapshot and one codec resolution step for the batch.
References: src/…/render-queue-store.ts• L1-91 src/…/build-render-job.ts• L1-8 src/…/build-render-job.ts• L54-88 src/…/build-render-job.ts• L225-240
Serial job runner
The runner stays mounted near the editor root even when the queue panel is closed. It takes the next queued job, tries smart copy, converts and resolves the snapshot when rendering is needed, runs the shared render pipeline, and saves the result to the project’s export area. It then marks the job complete, failed, or cancelled and starts the next queued job.
The queue panel can pause or resume work, move queued jobs, cancel active work, retry finished failures, and remove finished entries. Progress is a job-level view of the same render phases used by immediate export.
References: src/…/use-render-queue-runner.ts• L25-85 src/…/use-render-queue-runner.ts• L97-156 src/…/render-queue-panel.tsx• L192-220
Queue persistence and saved outputs
Queue state is stored per project. A reload requeues work that was rendering and pauses restored pending jobs so a refresh never starts a render without user action. Snapshot data is stored once when several segment jobs share it. Progress-only changes do not cause repeated queue-file writes.
The exports view lists files saved for the active project. It refreshes after a job completes and lets the user download or delete a saved file. Immediate exports keep the result in the dialog until the user downloads it or closes the dialog.
References: src/…/use-render-queue-persistence.ts• L1-16 src/…/use-render-queue-persistence.ts• L57-85 src/…/exports-dialog.tsx• L124-199 src/…/export-dialog.tsx• L1623-1666
Change checklist
When these files or sections are changed, remember to consider these:
- Changes to
CompositionInputPropsor timeline conversion must stay aligned between previewinputProps, export conversion, worker messages, and the composition runtime. - Changes to preview frame ownership must preserve the distinction between
currentFrame,previewFrame, anddisplayedFrame; otherwise a delayed render can replace a newer user action. - Changes to preflight checks or the renderer adapter must keep predicted paths, blocking severity, capability probes, and the settings shown in the export dialog aligned.
- Changes to export settings must update UI mapping, codec preflight, worker settings, file naming, and the main-thread fallback together.
- Changes to a queued job snapshot must update queue persistence and restore behavior. Segment jobs must still share a valid snapshot without changing after enqueue.
- Changes to saved export paths must stay aligned between queue completion records and the project export browser.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| A scrub or capture starts while another preview render owns the shared render surface | The display can show mixed or stale pixels | The preview renderer uses one render lock and resumes the pump after capture ends. |
| A delayed scrub render completes after the user moves the pointer or changes transport | An old frame can replace the current preview | Render generations and newest-target checks discard stale work before presentation. |
| A queued job reads live timeline state at render time | Later edits change an export that the user already queued | The queue stores a frozen timeline snapshot at enqueue time. |
| The preflight report uses stale capability or range data | The dialog can show a safe path or enable an export that the current settings cannot run | The dialog cancels obsolete checks and disables actions while required capability data is still pending. |
| The export worker cannot support animated images, offline audio, or a browser-only dependency | A worker export fails even though the browser can render it on the main thread | runRender retries known worker-limit cases on the main thread. |
| Referenced media is missing or the export range has no frames | The output is incomplete or cannot start | Preflight reports blocking errors and disables export actions. |
| A page reload interrupts a rendering job | The worker is gone and the job cannot resume from its old progress | Queue restore changes in-flight jobs back to queued and pauses pending work. |
Key files
| File | Why to read it |
|---|---|
| src/…/preview-area.tsx | Shows how the preview surface and its transport row fit into the editor workspace. |
| src/…/video-preview.tsx | Main preview coordinator for composition input, overlays, playback, capture, and renderer routing. |
| src/…/store.ts | Defines the shared playhead, transport, and preview preference state. |
| src/…/store.ts | Defines the transient link between rendered preview output and capture or analysis consumers. |
| src/…/use-preview-render-pump-controller.ts | Explains priority frame rendering, prewarm work, stale-frame rejection, and presentation. |
| src/…/main-composition.tsx | Shows the runtime boundary where composition input becomes visual and audio output. |
| src/…/export-dialog.tsx | Defines export choices, preflight display, immediate export, and queue entry points. |
| src/…/export-preflight-panel.tsx | Shows the compact severity and render-path summary before export starts. |
| src/…/renderer.ts | Defines the export-facing boundary to renderer settings, capability checks, results, and execution. |
| src/…/timeline-to-composition.ts | Defines the timeline-to-composition handoff used before export rendering. |
| src/…/render-pipeline.ts | Provides shared codec resolution, worker execution, cancellation, and fallback behavior. |
| src/…/export-render.worker.ts | Defines the worker boundary for video and audio render requests. |
| src/…/render-queue-store.ts | Defines job snapshots, queue state, status changes, and user queue actions. |
| src/…/use-render-queue-runner.ts | Shows how queued jobs run serially and become saved project exports. |
| src/…/use-render-queue-persistence.ts | Shows how queue state survives project reloads without silently restarting work. |