Skip to content

Recorder

Cross-browser recording of a MediaStream from an HTMLVideoElement. Uses native captureStream where available and falls back to a canvas-based approach (iOS Safari). Also picks a supported MIME type.

Functions

createRecordingPromise()

function createRecordingPromise(
  stream,
  duration,
  recordingOptions,
): Promise<File>;

Defined in: src/shared/clips/recorder.ts:84

Records a MediaStream into a File for duration ms.

Parameters

Parameter Type Description
stream MediaStream The stream to record.
duration number Duration in milliseconds.
recordingOptions { fileExtension: string; mimeType: string; } Codec choice.
recordingOptions.fileExtension string -
recordingOptions.mimeType string -

Returns

Promise\<File>

The recorded file.


getStream()

function getStream(videoElement, endTime): Promise<MediaStream>;

Defined in: src/shared/clips/recorder.ts:24

Gets a MediaStream from a video element, with a canvas fallback.

Parameters

Parameter Type Description
videoElement HTMLVideoElement The source video element.
endTime number When (seconds) the recording should stop.

Returns

Promise\<MediaStream>

The combined media stream.


getSupportedMimeType()

function getSupportedMimeType(): {
  fileExtension: string;
  mimeType: string;
} | null;

Defined in: src/shared/clips/recorder.ts:132

Returns the first browser-supported recording MIME type + extension.

Returns

| { fileExtension: string; mimeType: string; } | null

The choice, or null.


recordMediaStream()

function recordMediaStream(videoElement, startTime, endTime): Promise<File>;

Defined in: src/shared/clips/recorder.ts:155

Records a clip from a video element between two timestamps, restoring the element's prior state afterward.

Parameters

Parameter Type Description
videoElement HTMLVideoElement The source element.
startTime number Start time (seconds).
endTime number End time (seconds).

Returns

Promise\<File>

The recorded clip file.