Screen helpers · class
FrameRecorder
Explained in Recording and clips.
class FrameRecorderimport { FrameRecorder } from '@driftengine/core';Constructor
new
constructor(options: FrameRecorderOptions)| Parameter | Type | Description |
|---|---|---|
options | FrameRecorderOptions |
Accessors
| Name | Type | Description |
|---|---|---|
mimeTypeget | string | |
pacingget | FramePacingReport | null | What the pacing actually was, or null when recording the canvas directly.MoreThe measurement is the point rather than a diagnostic afterthought: an export that ran below its target rate produced a juddering file, and the only honest options are to say so or to have not measured. |
duplicateFrameget | boolean | Whether the frame frameRendered just composited repeats the one before it.MoreFalse without a target, and false when |
Methods
prepare
prepare(): { width: number; height: number; reduced: boolean; } | nullTake over the render surface before recording starts.
More
Separate from start because the aspect has to be in force before the
first frame anybody records: the camera composes for renderer.aspect, so
locking and recording in the same breath would put a screen-shaped shot in
the first frames of a vertical clip. Returns the frame size that will be
recorded, which is not always the one requested — see measuredFps.
captureDue
captureDue(nowMs: number): booleanWhether the frame about to be drawn will be kept. True when there is no fixed target, so a caller can gate its render pass unconditionally.
| Parameter | Type | Description |
|---|---|---|
nowMs | number |
More
Call once per animation frame, drawing or not: the instant is kept and reused when the frame is handed over, so one clock decides and commits.
frameRendered
frameRendered(): booleanOne rendered frame, offered to the recording.
More
Call at the very end of the render pass. Cheap and false when there is no
fixed target, so a caller can hand every frame over unconditionally. Takes no
instant — it uses the one captureDue was given for this frame.
resetPacing
resetPacing(): voidStart the measurement over, keeping the schedule.
More
For a caller that records a warm-up in front of the clip proper: what a device costs while an encoder gets going is not what the clip is like, and the report is what the export decides whether to warn the player on.
start
start(): voidstop
stop(): Promise<Blob | null>Resolves with the finished clip, or null if nothing was recorded.
More
The surface goes back before the promise resolves either way. A cancelled export that left the drawing buffer pinned to 1080x1920 would leave the game rendering into the wrong shape for the rest of the session.
release
release(): voidGive the render surface back. Safe at any point, and idempotent.