@babylonjs/core
Version:
Getting started? Play directly with the Babylon.js API using our [playground](https://playground.babylonjs.com/). It also contains a lot of samples to learn how to use it.
72 lines (71 loc) • 2.98 kB
TypeScript
import type { Nullable } from "../types.js";
import type { AbstractEngine } from "../Engines/abstractEngine.js";
/**
* This represents the different options available for the video capture.
*/
export interface VideoRecorderOptions {
/** The canvas you want to record */
canvas?: HTMLCanvasElement;
/** Defines the mime type of the video. */
mimeType: string;
/** Defines the FPS the video should be recorded at. */
fps: number;
/** Defines the chunk size for the recording data. */
recordChunckSize: number;
/** The audio tracks to attach to the recording. */
audioTracks?: MediaStreamTrack[];
}
/**
* This can help with recording videos from BabylonJS.
* This is based on the available WebRTC functionalities of the browser.
*
* @see https://doc.babylonjs.com/features/featuresDeepDive/scene/renderToVideo
*/
export declare class VideoRecorder {
private static readonly _DefaultOptions;
/**
* Returns whether or not the VideoRecorder is available in your browser.
* @param engine Defines the Babylon Engine.
* @param canvas Defines the canvas to record. If not provided, the engine canvas will be used.
* @returns true if supported otherwise false.
*/
static IsSupported(engine: AbstractEngine, canvas?: HTMLCanvasElement): boolean;
private readonly _options;
private _canvas;
private _mediaRecorder;
private _recordedChunks;
private _fileName;
private _resolve;
private _reject;
private _isRecording;
/**
* True when a recording is already in progress.
*/
get isRecording(): boolean;
/**
* Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
* @param engine Defines the BabylonJS Engine you wish to record.
* @param options Defines options that can be used to customize the capture.
*/
constructor(engine: AbstractEngine, options?: Partial<VideoRecorderOptions>);
/**
* Stops the current recording before the default capture timeout passed in the startRecording function.
*/
stopRecording(): void;
/**
* Starts recording the canvas for a max duration specified in parameters.
* @param fileName Defines the name of the file to be downloaded when the recording stop.
* If null no automatic download will start and you can rely on the promise to get the data back.
* @param maxDuration Defines the maximum recording time in seconds.
* It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
* @returns A promise callback at the end of the recording with the video data in Blob.
*/
startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
/**
* Releases internal resources used during the recording.
*/
dispose(): void;
private _handleDataAvailable;
private _handleError;
private _handleStop;
}