import { F as File, g as FileReturn, B as BaseStorage } from "../packem_shared/storage.d-C9EdfTf1.js"; import { V as VideoTransformerConfig, F as VideoTransformResult, H as VideoResizeOptions, K as VideoCropOptions, N as VideoRotateOptions, O as VideoTransformOptions, Q as VideoTransformationStep, B as BaseTransformer } from "../packem_shared/types.d-D1TIRqKW.js"; import 'node:stream'; import 'node:timers'; import 'node:crypto'; import 'node:http'; import 'lru-cache'; /** * Video transformer that uses storage backends and Mediabunny library to retrieve and transform videos. * @template TFile The file type used by this transformer. * @template TFileReturn The return type for file retrieval operations. * * Supports video transformations with query parameters for on-demand video processing. * @example * ```ts * const transformer = new VideoTransformer(storage, { * maxVideoSize: 100 * 1024 * 1024, // 100MB * cache: new Map() * }); * * // Programmatic usage - resize a video * const result = await transformer.resize('video-id', { * width: 1920, * height: 1080, * fit: 'contain' * }); * * // URL-based transformations * // GET /files/video-id?width=1280&height=720&fit=cover&bitrate=2000000 * // GET /files/video-id?codec=vp9&bitrate=1000000 * ``` * * ## Supported Query Parameters * * - `width`: Width in pixels (Number) * - `height`: Height in pixels (Number) * - `fit`: Resize fit mode - cover/contain/fill/inside/outside * - `codec`: Video codec - avc/hevc/vp8/vp9/av1 * - `bitrate`: Video bitrate in bits per second (Number) * - `frameRate`: Frame rate in Hz (Number) * - `format`: Output format - mp4/webm/mkv/ogg */ declare class VideoTransformer extends BaseTransformer, TFile, TFileReturn> { /** * Creates a new VideoTransformer instance. * @param storage The storage backend for retrieving and storing video files. * @param config Configuration options for video transformation including cache settings, codec defaults, and size limits. */ constructor(storage: BaseStorage, config?: VideoTransformerConfig); /** * Resizes a video to specified dimensions with optional fit mode. * @param fileId Unique identifier of the video file to resize. * @param options Resize options including width, height, and fit mode. * @returns Promise resolving to transformed video result. */ resize(fileId: string, options: VideoResizeOptions): Promise>; /** * Crops a video to the specified region. * @param fileId Unique identifier of the video file to crop. * @param options Crop options including region coordinates. * @returns Promise resolving to transformed video result. */ crop(fileId: string, options: VideoCropOptions): Promise>; /** * Rotates a video by the specified angle. * @param fileId Unique identifier of the video file to rotate. * @param options Rotation configuration with angle in degrees and optional background color. * @returns Promise resolving to transformed video result. */ rotate(fileId: string, options: VideoRotateOptions): Promise>; /** * Converts video format or codec. * @param fileId Unique identifier of the video file to convert. * @param format Target video format (e.g., "mp4", "webm", "mkv"). * @param options Video transformation options including quality, bitrate, and codec settings. * @returns Promise resolving to transformed video result with updated format metadata. */ convertFormat(fileId: string, format: string, options?: VideoTransformOptions): Promise>; /** * Transcodes video to different codec. * @param fileId Unique identifier of the video file to transcode. * @param codec Target video codec (e.g., "avc", "hevc", "vp9"). * @param options Additional transform options. * @returns Promise resolving to transformed video result. */ transcode(fileId: string, codec: VideoTransformOptions["codec"], options?: Omit): Promise>; /** * Applies a custom transformation pipeline to a video. * @param fileId Unique identifier of the video file to transform. * @param steps Array of transformation steps to apply in sequence. * @returns Promise resolving to transformed video result. */ transform(fileId: string, steps: VideoTransformationStep[]): Promise>; /** * Applies multiple transformations in sequence using Mediabunny. * @param buffer The original video buffer. * @param steps Array of video transformation steps to apply. * @returns Promise resolving to transformed video buffer. * @private */ private applyTransformations; /** * Converts transformation steps to Mediabunny video options. * @param steps Array of video transformation steps to convert. * @returns Mediabunny video options object for conversion. * @private */ private stepsToVideoOptions; /** * Determines output format based on transformation steps. * @param steps Array of video transformation steps. * @returns Mediabunny output format instance (defaults to MP4). * @private */ private determineOutputFormat; /** * Converts format string to Mediabunny output format. * @param format Video format string (mp4, webm, mkv, ogg). * @returns Mediabunny output format instance. * @private */ private formatStringToOutputFormat; /** * Validates that the file is a supported video. * @param file The file to validate. * @returns Promise that resolves if validation passes. * @throws Error if file size exceeds limits, wrong content type, unsupported format, or invalid video. * @private */ private validateVideo; /** * Creates transformation result with metadata. * @param buffer The transformed video buffer. * @param originalFile The original file information. * @returns Video transformation result with metadata. * @private */ private createTransformResult; /** * Generates cache key for transformation. * @param fileId The file identifier. * @param steps Array of transformation steps. * @returns Unique cache key string. * @private */ private generateCacheKey; } export { VideoTransformer as default };