import * as PIXI from "pixi.js"; import { ExportOptions } from '../../../../Engine'; import { AudioClip, MediaProcessStatusEnum, IFilmstripData, ReplaceMediaOptions } from '../../../../index'; import { FadeCurveEnum } from '../../../../types'; import { Clip, ClipOptions } from "../../Clip"; import { ClipStyle } from "../../ClipStyle"; /** * Options for creating a video-backed clip. */ export interface VideoClipOptions extends ClipOptions { mediaDataId: string; volume?: number; muted?: boolean; playbackSpeed?: number; perservePitch?: boolean; volumeFadeInDuration?: number; volumeFadeInCurve?: FadeCurveEnum; volumeFadeOutDuration?: number; volumeFadeOutCurve?: FadeCurveEnum; freezeTime?: number; } /** * Clip implementation that renders video media, handles preview playback, and supports audio extraction and frame access. */ export declare class VideoClip extends Clip> { private videoElement; private audioElement; private isPlaying; private volume; private muted; private playbackSpeed; private perservePitch; private volumeFadeInDuration; private volumeFadeInCurve; private volumeFadeOutDuration; private volumeFadeOutCurve; private freezeTime?; private actions; private isProcessing; private lastProcessingAction; private lastUpdateTime; private lastStartTime; private lastLeftTrim; private lastRightTrim; private mediaDataDuration; private audioDataDuration; private decoder; private frameQueue; private isRendering; private decoderFlushed; private decoderFlushPromise; private renderWithPlayer; private forceSoftwareDecoder; private ffmpeg; private callbacks; private isDestroying; private isVideoSourceLoaded; private restoreVideoSourceIfMissing; private loadVideoSource; private unloadVideoSource; private ensureWorkerDir; private mountMediaInWorker; private createUncachedVideoTexture; /** * Creates a video clip bound to a library media asset. * * @param options Initial video clip configuration. */ constructor(options: VideoClipOptions); /** * Creates the backing video and optional split-audio elements, binds media data, and initializes runtime playback state. * * @param layerId Layer ID that owns this clip. * @returns A promise that resolves after initialization completes. */ init(layerId: string): Promise; private updateRenderFlags; private updateAudioDuration; /** * Returns the earliest timeline time where the clip may need to render, including incoming transition coverage. * * @returns The left render bound in seconds. */ getLeftRenderBound(): number; /** * Returns the latest timeline time where the clip may need to render, including outgoing transition coverage. * * @returns The right render bound in seconds. */ getRightRenderBound(): number; private getGlobalTimeToClipTime; /** * Indicates whether the clip is currently processing a queued seek, play, pause, or render-preparation action. * * @returns `true` if asynchronous clip work is still in progress; otherwise `false`. */ getIsProcessing(): boolean; /** * Clears any queued media actions waiting to run on the video or split-audio elements. * * @returns Nothing. */ discardProcessing(): void; /** * Rebinds the clip to updated video media and refreshes derived timing, render mode, textures, and optional split-audio state. * * @param newMediaId Optional replacement media asset ID. * @param options Optional media replacement behavior such as fit and crop handling. * @returns A promise that resolves to `true` if the media update succeeds; otherwise `false`. */ updateMediaData(newMediaId?: string, options?: ReplaceMediaOptions): Promise; /** * Preloads the clip by seeking the media elements near the requested timeline time. * * @param currentTime Current timeline time in seconds. * @returns Nothing. */ preload(currentTime: number): void; private addActionToQueue; private setProcessingAction; private processNextQueue; private seekedCallback; private playingCallback; private pausedCallback; private endedCallback; private errorCallback; private videoLoadedCallback; private isVideoReady; private isAudioReady; isReady(): boolean; private getVolumeFadeRelativeBounds; private getFadeVolume; /** * Applies clip, layer, timeline, and fade multipliers to the underlying video and split-audio element volume. * * @returns Nothing. */ applyVolume(): void; /** * Sets the clip volume multiplier. * * @param volume Clip volume multiplier. * @returns Nothing. */ setVolume(volume: number): void; /** * Returns the clip volume multiplier. * * @returns The clip volume multiplier. */ getVolume(): number; /** * Sets the audible fade-in duration at the start of the clip. * * @param duration Fade-in duration in seconds. * @returns Nothing. */ setVolumeFadeInDuration(duration: number): void; /** * Returns the configured fade-in duration. * * @returns The fade-in duration in seconds. */ getVolumeFadeInDuration(): number; /** * Sets the interpolation curve used for the clip fade-in. * * @param curve Fade curve to use. * @returns Nothing. */ setVolumeFadeInCurve(curve: FadeCurveEnum): void; /** * Returns the fade curve used for the clip fade-in. * * @returns The configured fade-in curve. */ getVolumeFadeInCurve(): FadeCurveEnum; /** * Sets the audible fade-out duration at the end of the clip. * * @param duration Fade-out duration in seconds. * @returns Nothing. */ setVolumeFadeOutDuration(duration: number): void; /** * Returns the configured fade-out duration. * * @returns The fade-out duration in seconds. */ getVolumeFadeOutDuration(): number; /** * Sets the interpolation curve used for the clip fade-out. * * @param curve Fade curve to use. * @returns Nothing. */ setVolumeFadeOutCurve(curve: FadeCurveEnum): void; /** * Returns the fade curve used for the clip fade-out. * * @returns The configured fade-out curve. */ getVolumeFadeOutCurve(): FadeCurveEnum; /** * Changes video playback speed and updates duration and trims to preserve the requested timing behavior. * * @param speed Playback speed multiplier. * @param perserveLeftBound When `true`, keeps the visible left edge fixed in timeline space. * @param perserveTrimmedDuration When `true`, preserves the trimmed visible duration after the speed change. * @returns Nothing. */ setPlaybackSpeed(speed: number, perserveLeftBound?: boolean, perserveTrimmedDuration?: boolean): void; /** * Returns the playback speed multiplier. * * @returns The playback speed multiplier. */ getPlaybackSpeed(): number; /** * Sets whether pitch correction should be preserved while changing playback speed. * * @param perservePitch Whether pitch should be preserved. * @returns Nothing. */ setPerservePitch(perservePitch: boolean): void; /** * Indicates whether pitch preservation is enabled during speed changes. * * @returns `true` if pitch preservation is enabled; otherwise `false`. */ getPerservePitch(): boolean; private play; private pause; private renderSeek; private willSeekAtTime; private seek; private renderVideoFrameOutputCallback; private getNextRenderPacket; private searchRenderFrame; private getTextureRotation; private initializeDecoder; private destroyDecoder; /** * Prepares the clip for export rendering, including decoder/player mode setup. * * @param options Export options for the current render pass. * @returns A promise that resolves after render-start preparation completes. */ onRenderStart(options: ExportOptions): Promise; /** * Cleans up clip state after an export render pass finishes. * * @param canceled Whether the render was canceled before completion. * @returns A promise that resolves after render cleanup completes. */ onRenderDone(canceled: boolean): Promise; /** * Primes the clip for timeline playback and seeks media elements to the requested time. * * @param currentTime Current timeline time in seconds. * @returns A promise that resolves after playback pre-roll work completes. */ onPlay(currentTime: number): Promise; /** * Pauses clip playback and seeks media elements back to the requested timeline time. * * @param currentTime Current timeline time in seconds. * @returns A promise that resolves after pause handling completes. */ onPause(currentTime: number): Promise; updateVisibility(currentTime: number): void; /** * Synchronizes video playback, lazy loading, visibility, and effect state with the timeline playhead. * * @param currentTime Current timeline time in seconds. * @returns Nothing. */ update(currentTime: number): void; /** * Mutes or unmutes the clip audio output. * * @param muted Whether the clip should be muted. * @returns Nothing. */ setMuted(muted: boolean): void; /** * Indicates whether the clip audio is muted. * * @returns `true` if the clip is muted; otherwise `false`. */ isMuted(): boolean; /** * Creates a timeline audio clip from the video's audio track. * * @param muteAudio Whether the original video clip should be muted after extraction. * @param createNewMediaData Whether a new audio-only media asset should be created in the library. * @param audioTrackIndex Audio stream index to extract. * @returns A promise that resolves to the created audio clip, or `null` if extraction fails. */ extractAudioClip(muteAudio?: boolean, createNewMediaData?: boolean, audioTrackIndex?: number): Promise; /** * Retrieves audio samples for a specified time range relative to the startTime from the associated media data. * * @param startTime - The start time in seconds relative to the startTime from which to extract audio samples. * @param duration - The duration in seconds for which to extract audio samples. * @returns An array of Float32Array representing the audio samples, or null if the media data is unavailable. */ /** * Returns decoded audio samples from the video's underlying media asset. * * @param startTime Start time in seconds, relative to the source media. * @param duration Optional duration in seconds to extract. * @returns The audio sample channels, or `null` if the media data is unavailable. */ getAudioSamples(startTime: number, duration?: number): Float32Array[] | null; /** * Retrieves the current state of the filmstrip extraction process for the associated media data. * * @return {MediaProcessStatusEnum } The current state of the filmstrip extraction process. * It can be one of the following values: * - `FilmStripStateEnum.NONE`: No filmstrip extraction process is currently running. * - `FilmStripStateEnum.PARTIAL`: The filmstrip extraction process is partially complete. * - `FilmStripStateEnum.DONE`: The filmstrip extraction process is complete. * - `FilmStripStateEnum.ERROR`: An error occurred during the filmstrip extraction process. */ /** * Returns the current filmstrip generation state for the backing media asset. * * @returns The filmstrip processing state. */ getFilmstripState(): MediaProcessStatusEnum; /** * Retrieves the data for the filmstrip associated with this clip. * * @return {IFilmstripData[]} An array of IFilmstripData objects representing the filmstrip data. * If the clip is not associated with any media data or the media data does not have a filmstrip, * an empty array is returned. */ /** * Returns all available filmstrip frames for the backing media asset. * * @returns The filmstrip frame metadata. */ getFilmstripData(): IFilmstripData[]; /** * Retrieves a range of data from the filmstrip associated with this clip. * * @param {number} start - The start time of the range in seconds, in case it lands between two filmstrip data points returns the lowest. * @param {number} end - The end time of the range in seconds, in case it lands between two filmstrip data points returns the highest. * @return {IFilmstripData[]} An array of IFilmstripData objects representing the filmstrip data in the specified range. * If the clip is not associated with any media data or the media data does not have a filmstrip, * or if the range is invalid, an empty array is returned. */ /** * Returns filmstrip frames that fall within the provided time range. * * @param start Range start time in seconds. * @param end Range end time in seconds. * @returns The matching filmstrip frame metadata. */ getFilmstripDataRange(start: number, end: number): IFilmstripData[]; /** * Clears any frozen playback time and resumes normal timeline-driven seeking. * * @returns Nothing. */ removeFreezeTime(): void; /** * Freezes video playback to a fixed local media time. * * @param time Local media time in seconds, or `undefined` to clear the freeze. * @returns Nothing. */ setFreezeTime(time?: number): void; /** * Returns the frozen local media time, if one is set. * * @returns The frozen media time in seconds, or `undefined` if freeze is disabled. */ getFreezeTime(): number | undefined; /** * Captures the current rendered video frame as a base64-encoded image. * * @param options Output image encoding options. * @returns A promise that resolves to the encoded image, or `null` if frame extraction is unavailable. */ extractFrameAsBase64Image(options?: { mimeType: string; quality: number; }): Promise; /** * * @deprecated Use getAudioSamples instead, don't forget to enable them in the settings */ extractMonoAudioData(startTime: number, endTime: number): Promise; private applyFirefoxRotationFix; private clearSpriteTextureCache; /** * Releases video/audio elements, decoder resources, texture state, and clip runtime data. * * @returns Nothing. */ destroy(): void; /** * Creates a cloned video clip instance from serialized data. * * @returns A cloned video clip. */ clone(): VideoClip; /** * Serializes the video clip. * * @returns The serialized video clip payload. */ serialize(): { type: string; id: string; duration: number; mediaDataId: string; subtitlesOffset: number; startTime: number; leftTrim: number; rightTrim: number; filters: { intensity: number; id: string; provider: string; filterId: string; clipId?: string | undefined; }[]; effects: any[]; isVisible: boolean; playbackSpeed: number; perservePitch: boolean; volumeFadeInDuration: number; volumeFadeInCurve: FadeCurveEnum; volumeFadeOutDuration: number; volumeFadeOutCurve: FadeCurveEnum; text?: string | undefined; name?: string | undefined; customData?: [string, unknown][] | undefined; wrapMode?: import('../../../../types').WrapModeEnum | undefined; blendMode?: import('../../../../types').BlendModeEnum | undefined; style?: unknown; subtitlesId?: string | undefined; animationController?: { animationInDuration: number; animationOutDuration: number; animationLoopCount: number; loopSmoothing: number; animationDataIn?: { name: string; inOutOfRange: import('../../../../index').OutOfRangeEnum; outOutOfRange: import('../../../../index').OutOfRangeEnum; propertyAnimations: { property: string; keyframes: { value: string | number; time: number; easing: import('../../../../index').EasingEnum; space: import('../../../../index').AnimationSpaceEnum; relativeProperty?: string | undefined; }[]; inOutOfRange: import('../../../../index').OutOfRangeEnum; outOutOfRange: import('../../../../index').OutOfRangeEnum; }[]; speed?: number | undefined; offset?: number | undefined; amplification?: number | undefined; } | undefined; animationDataOut?: { name: string; inOutOfRange: import('../../../../index').OutOfRangeEnum; outOutOfRange: import('../../../../index').OutOfRangeEnum; propertyAnimations: { property: string; keyframes: { value: string | number; time: number; easing: import('../../../../index').EasingEnum; space: import('../../../../index').AnimationSpaceEnum; relativeProperty?: string | undefined; }[]; inOutOfRange: import('../../../../index').OutOfRangeEnum; outOutOfRange: import('../../../../index').OutOfRangeEnum; }[]; speed?: number | undefined; offset?: number | undefined; amplification?: number | undefined; } | undefined; animationDataLoop?: { name: string; inOutOfRange: import('../../../../index').OutOfRangeEnum; outOutOfRange: import('../../../../index').OutOfRangeEnum; propertyAnimations: { property: string; keyframes: { value: string | number; time: number; easing: import('../../../../index').EasingEnum; space: import('../../../../index').AnimationSpaceEnum; relativeProperty?: string | undefined; }[]; inOutOfRange: import('../../../../index').OutOfRangeEnum; outOutOfRange: import('../../../../index').OutOfRangeEnum; }[]; speed?: number | undefined; offset?: number | undefined; amplification?: number | undefined; } | undefined; } | undefined; clipMasks?: { wrapMode: import('../../../../index').MaskWrapModeEnum; id: string; clipId: string; }[] | undefined; propertyAnimator?: { tracks: { type: import('../../../../index').PropertyDescriptionTypeEnum; property: string; keyframes: { value: (string | number | boolean | number[]) & (string | number | boolean | number[] | undefined); time: number; handleIn: { value: number; time: number; }; handleOut: { value: number; time: number; }; hold?: boolean | undefined; }[]; defaults?: { handleIn?: { value: number; time: number; } | undefined; handleOut?: { value: number; time: number; } | undefined; hold?: boolean | undefined; } | undefined; customData?: [string, unknown][] | undefined; }[]; initialValues?: [string, string | number | boolean | number[]][] | undefined; } | undefined; volume?: number | undefined; muted?: boolean | undefined; freezeTime?: number | undefined; }; /** * Creates a video clip instance from serialized data. * * @param payload Serialized video clip payload. * @returns The deserialized video clip. */ static deserialize(payload: object): VideoClip; }