@diffusionstudio/core-v4
Version:
A fast, browser based video compositing engine powered by WebCodecs
185 lines (184 loc) • 5.2 kB
TypeScript
import { Serializer } from '../../services';
import { BaseSource } from '../../sources';
import { AudioClip } from '../audio';
import { Asset, MediaInput, Size, Time } from '../../types';
import { Renderer } from '../../renderer';
import { ClipType, ClipAnimationOptions } from './types';
import { Layer, TransitionConfig } from '../../layer';
import { ClipProps } from './interfaces';
export declare class Clip extends Serializer {
/**
* Unique identifier of the clip
*/
id: string;
_name: undefined | string;
_delay: number;
_duration: number;
/**
* Data associated with the clip
*/
data: Record<string, unknown>;
/**
* Flag to check if the clip has been initialized
*/
initialized: boolean;
/**
* Defines the type of the clip
*/
readonly type: ClipType;
/**
* Defines the source of the clip which can be
* shared with other clips for more efficient
* memory usage
*/
source?: BaseSource;
/**
* Timestamp when the clip has been created
*/
readonly createdAt: Date;
/**
* Controls the visability of the clip
*/
disabled: boolean;
/**
* Animation properties for the clip
*/
animations: ClipAnimationOptions;
/**
* Access the parent layer
*/
layer?: Layer;
/**
* The input that was used to create the clip
*/
input?: MediaInput;
/**
* Stores the current transition configuration; how this clip transitions to the next clip.
*/
transition?: TransitionConfig;
/**
* Human readable identifier of the clip
*/
get name(): string | undefined;
set name(name: string);
/**
* Get the first visible frame. When setting this value,
* the clip will be offset to match the new start time
*/
get start(): number;
set start(time: Time);
/**
* Get the last visible frame. When setting this value,
* the clip will be offset to match the new end time
*/
get end(): number;
set end(time: Time);
/**
* Get the delay of the clip
*/
get delay(): number;
/**
* Get the duration of the clip
*/
get duration(): number;
/**
* Get the index of the clip in the layer
*/
get index(): number;
/**
* Set the index of the clip in the layer, will be ignored if the layer is not sequential
*/
set index(index: number);
constructor(props?: ClipProps);
containsAudio(): this is AudioClip;
/**
* Set the animation time of the clip
* and interpolate the values
* @param time the current absolute time to render
*/
animate(time: number): this;
/**
* Change clip's offset to zero in seconds. Can be negative
*/
set delay(time: Time);
/**
* Set the duration of the clip, needs to be positive
*/
set duration(time: Time);
/**
* Triggered when the clip is
* added to the composition
*/
init(): Promise<void>;
initRenderer(renderer: Renderer): Promise<void>;
deinitRenderer(renderer: Renderer): Promise<void>;
/**
* Triggered when the clip enters the scene
*/
enter(renderer: Renderer): Promise<void>;
/**
* Triggered for each redraw of the scene when the clip is visible
*/
update(renderer: Renderer): Promise<void>;
/**
* Triggered for each redraw of the scene
*/
ambientUpdate(renderer: Renderer): void;
/**
* Triggered after the clip was updated
*/
render(renderer: Renderer): void;
/**
* Triggered when the clip exits the scene
*/
exit(renderer: Renderer): Promise<void>;
/**
* Seek the clip to a specific absolute time
*/
seek(renderer: Renderer): Promise<void>;
/**
* Play the clip
*/
play(renderer: Renderer): Promise<void>;
/**
* Pause the clip
*/
pause(renderer: Renderer): Promise<void>;
/**
* Handle layout changes of the parent layer
*/
layout(nextLayout: Size): void;
/**
* Remove the clip from the layer
*/
detach(): this;
/**
* Trim the clip to the specified start and stop
*/
trim(start?: Time, end?: Time): this;
/**
* Split the clip into two clips at the specified time
* @param time split, will use the current time of the composition
* a fallback
* @returns The clip that was created by performing this action
*/
split(time?: Time): Promise<this>;
/**
* Create a copy of the clip. Will have receive a new id
* but share the same source
*/
copy(): this;
/**
* Create a checkpoint of the clip. May include Blob or FileSystemFileHandle.
* @param middleware A function to modify the checkpoint data
* @returns A serialized representation of the clip
*/
createCheckpoint(): Promise<unknown>;
/**
* Restore a checkpoint of the clip.
* @param checkpoint The checkpoint to restore
* @param assets The assets to use for the restoration
* @returns The restored clip
*/
restoreCheckpoint(checkpoint: unknown, assets: Asset[]): Promise<this>;
}