GUIDE 23 / 28 · NATIVE 2.0.7

Recording & replay engine

Understand the continuous segment buffer, manual recordings, replay finalization and hardware encoder selection.

The capture pipeline#

The service probes H.264 encoders in order: NVIDIA NVENC, Intel QSV, AMD AMF and CPU libx264. The probe encodes a short 640×360 sample. Selection depends on the encoder actually working, not just appearing in FFmpeg's list.

Capture starts with DXGI through ddagrab. If startup does not produce a completed segment within the startup window, the service falls back to gdigrab. Video is scaled and encoded using the configured resolution, frame rate and bitrate. The current native build records the desktop; it does not expose a plugin API for choosing arbitrary windows.

Continuous replay segments#

FFmpeg writes approximately two-second MPEG-TS segments and a rolling CSV with their media timestamps. The service tracks completed segments using media time, retains the configured history and pins segments needed by an active manual recording.

The default replay duration is 300 seconds; supported stored duration is bounded from 10 to 1200 seconds. Available history grows after startup. Saving immediately cannot create minutes that have not been captured. A replay ends at the newest completed segment, so it can trail live activity by roughly one segment.

StatusMeaning
isStartingCapture is warming up and may not have usable segments yet.
isBufferActiveCapture has at least one completed replay segment.
availableSecondsCompleted usable history, capped by the configured duration.
isRecordingManualA manual interval is active.
isSavingReplayA replay export is being finalized.

Manual and replay requests#

Manual recording marks an interval in the same capture timeline. Stopping a manual recording waits for its final segment, then exports that interval. When replay is enabled, capture continues after the manual export so the existing replay history remains available.

Commands are serialized. Repeated replay requests share the pending export instead of launching duplicate work. A pending manual toggle and a short toggle guard prevent one physical shortcut press from starting and immediately stopping recording.

Changing only the replay duration or output directory can preserve capture history. Changes to capture-affecting settings such as resolution, FPS, bitrate, audio or microphone mode require a capture restart. A capture configuration change during an active manual recording is rejected.

How export preserves quality#

The service snapshots the relevant segment files using hard links when possible and copies when necessary. FFmpeg concatenates that snapshot into an MP4 without re-encoding the full video. A trim step uses MP4 edit lists to handle boundaries while preserving the preceding keyframe needed for decoding.

After duration and first-frame validation, the service publishes the staging file under its final MP4 name, generates a thumbnail, registers the clip, dispatches plugin hooks and optionally queues a Drive upload. A failed export can leave its snapshot for recovery. See export recovery.

Practical limits#

Export still reads and writes media data. A slow drive, cross-volume copies or an awaited plugin hook can lengthen saving even when video is not re-encoded. H.264 at the configured bitrate is compressed video; stream copying preserves that recorded quality but does not make it lossless.

Use the replay user guide for setup and performance diagnostics for startup, encoder and latency checks.

Implementation reference: src/native/recorder.ts · native 2.0.7.

Fast clip trimming#

src/native/clip-editor.ts performs local start/end trimming separately from the rolling capture buffer. Video uses stream copy and MP4 edit lists to retain decoding preroll while showing the selected start. All audio streams are preserved when levels are unchanged. Changed levels remix the combined AAC track from the original labelled sources; the stems themselves are copied. The output must contain a decodable frame, match selected duration within the export tolerance and retain the expected track count.

On success the new local clip is inserted atomically, emits clip:created and invokes the existing plugin onClipSaved hook. Edited files preserve their source type (manual or instant_replay) and gain optional sourceClipId and edit metadata. They are not automatically queued for cloud upload.