2026-01-20 00:25:55 +03:00
|
|
|
|
/**
|
|
|
|
|
|
* Video codec type for encoding
|
|
|
|
|
|
*/
|
2026-01-20 14:24:51 +03:00
|
|
|
|
export type CodecType = 'av1' | 'h264';
|
2026-01-20 00:25:55 +03:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* Streaming format type
|
|
|
|
|
|
*/
|
2026-01-20 14:24:51 +03:00
|
|
|
|
export type StreamingFormat = 'dash' | 'hls';
|
|
|
|
|
|
|
2026-01-20 00:25:55 +03:00
|
|
|
|
/**
|
|
|
|
|
|
* Тип аппаратного ускорителя
|
|
|
|
|
|
*/
|
|
|
|
|
|
export type HardwareAccelerator = 'nvenc' | 'qsv' | 'amf' | 'vaapi' | 'videotoolbox' | 'v4l2' | 'cpu';
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* Опция выбора ускорителя (конкретный или auto)
|
|
|
|
|
|
*/
|
|
|
|
|
|
export type HardwareAccelerationOption = HardwareAccelerator | 'auto';
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* Набор доступных энкодеров для конкретного ускорителя
|
|
|
|
|
|
*/
|
|
|
|
|
|
export interface HardwareEncoderInfo {
|
|
|
|
|
|
accelerator: HardwareAccelerator;
|
|
|
|
|
|
h264Encoder?: string;
|
|
|
|
|
|
av1Encoder?: string;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-01-20 10:38:25 +03:00
|
|
|
|
/**
|
|
|
|
|
|
* Набор доступных декодеров/accel
|
|
|
|
|
|
*/
|
|
|
|
|
|
export interface HardwareDecoderInfo {
|
|
|
|
|
|
accelerator: HardwareAccelerator;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-01-20 00:25:55 +03:00
|
|
|
|
/**
|
|
|
|
|
|
* Quality settings for a codec
|
|
|
|
|
|
*/
|
|
|
|
|
|
export interface CodecQualitySettings {
|
|
|
|
|
|
/** CQ (Constant Quality) for GPU encoders (0-51, lower = better quality) */
|
|
|
|
|
|
cq?: number;
|
|
|
|
|
|
|
|
|
|
|
|
/** CRF (Constant Rate Factor) for CPU encoders (0-51 for h264, 0-63 for av1, lower = better quality) */
|
|
|
|
|
|
crf?: number;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* Quality settings for video encoding
|
|
|
|
|
|
*/
|
|
|
|
|
|
export interface QualitySettings {
|
|
|
|
|
|
/** Quality settings for H.264 codec */
|
|
|
|
|
|
h264?: CodecQualitySettings;
|
|
|
|
|
|
|
|
|
|
|
|
/** Quality settings for AV1 codec */
|
|
|
|
|
|
av1?: CodecQualitySettings;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* Configuration options for DASH conversion
|
|
|
|
|
|
*/
|
|
|
|
|
|
export interface DashConvertOptions {
|
|
|
|
|
|
/** Input video file path */
|
|
|
|
|
|
input: string;
|
|
|
|
|
|
|
|
|
|
|
|
/** Output directory path */
|
|
|
|
|
|
outputDir: string;
|
|
|
|
|
|
|
|
|
|
|
|
/** Segment duration in seconds (default: 2) */
|
|
|
|
|
|
segmentDuration?: number;
|
|
|
|
|
|
|
|
|
|
|
|
/** Video quality profiles to generate */
|
|
|
|
|
|
profiles?: VideoProfile[];
|
|
|
|
|
|
|
|
|
|
|
|
/** Custom resolution profiles as strings (e.g., ['360p', '480p', '720p@60']) */
|
|
|
|
|
|
customProfiles?: string[];
|
|
|
|
|
|
|
2026-01-20 14:52:59 +03:00
|
|
|
|
/** Video codec selection: one or multiple (default: ['h264']) */
|
|
|
|
|
|
codec?: CodecType | CodecType[];
|
2026-01-20 00:25:55 +03:00
|
|
|
|
|
2026-01-20 14:52:59 +03:00
|
|
|
|
/** Streaming formats: list (default: ['dash','hls']) */
|
|
|
|
|
|
formats?: StreamingFormat[];
|
2026-01-20 00:25:55 +03:00
|
|
|
|
|
|
|
|
|
|
/** Предпочитаемый аппаратный ускоритель (auto по умолчанию) */
|
|
|
|
|
|
hardwareAccelerator?: HardwareAccelerationOption;
|
2026-01-20 10:38:25 +03:00
|
|
|
|
/** Предпочитаемый аппаратный ускоритель для декодера (auto по умолчанию) */
|
|
|
|
|
|
hardwareDecoder?: HardwareAccelerationOption;
|
2026-01-20 00:25:55 +03:00
|
|
|
|
|
|
|
|
|
|
/** Quality settings for video encoding (CQ/CRF values) */
|
|
|
|
|
|
quality?: QualitySettings;
|
|
|
|
|
|
|
|
|
|
|
|
/** Generate thumbnail sprite (default: true) */
|
|
|
|
|
|
generateThumbnails?: boolean;
|
|
|
|
|
|
|
|
|
|
|
|
/** Thumbnail sprite configuration */
|
|
|
|
|
|
thumbnailConfig?: ThumbnailConfig;
|
|
|
|
|
|
|
|
|
|
|
|
/** Generate poster image (default: true) */
|
|
|
|
|
|
generatePoster?: boolean;
|
|
|
|
|
|
|
|
|
|
|
|
/** Poster timecode in format HH:MM:SS or seconds (default: 00:00:01) */
|
|
|
|
|
|
posterTimecode?: string;
|
|
|
|
|
|
|
|
|
|
|
|
/** Parallel encoding (default: true) */
|
|
|
|
|
|
parallel?: boolean;
|
|
|
|
|
|
|
|
|
|
|
|
/** Callback for progress updates */
|
|
|
|
|
|
onProgress?: (progress: ConversionProgress) => void;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* Video quality profile
|
|
|
|
|
|
*/
|
|
|
|
|
|
export interface VideoProfile {
|
|
|
|
|
|
/** Profile name (e.g., "1080p", "720p") */
|
|
|
|
|
|
name: string;
|
|
|
|
|
|
|
|
|
|
|
|
/** Video width in pixels */
|
|
|
|
|
|
width: number;
|
|
|
|
|
|
|
|
|
|
|
|
/** Video height in pixels */
|
|
|
|
|
|
height: number;
|
|
|
|
|
|
|
|
|
|
|
|
/** Video bitrate (e.g., "5000k") */
|
|
|
|
|
|
videoBitrate: string;
|
|
|
|
|
|
|
|
|
|
|
|
/** Audio bitrate (e.g., "128k") */
|
|
|
|
|
|
audioBitrate: string;
|
|
|
|
|
|
|
|
|
|
|
|
/** Target FPS for this profile (default: 30) */
|
|
|
|
|
|
fps?: number;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* Thumbnail sprite configuration
|
|
|
|
|
|
*/
|
|
|
|
|
|
export interface ThumbnailConfig {
|
|
|
|
|
|
/** Width of each thumbnail (default: 160) */
|
|
|
|
|
|
width?: number;
|
|
|
|
|
|
|
|
|
|
|
|
/** Height of each thumbnail (default: 90) */
|
|
|
|
|
|
height?: number;
|
|
|
|
|
|
|
|
|
|
|
|
/** Interval between thumbnails in seconds (default: 1) */
|
|
|
|
|
|
interval?: number;
|
|
|
|
|
|
|
|
|
|
|
|
/** Number of thumbnails per row (default: 10) */
|
|
|
|
|
|
columns?: number;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* Conversion progress information
|
|
|
|
|
|
*/
|
|
|
|
|
|
export interface ConversionProgress {
|
|
|
|
|
|
/** Current stage of conversion */
|
|
|
|
|
|
stage: 'analyzing' | 'encoding' | 'thumbnails' | 'manifest' | 'complete';
|
|
|
|
|
|
|
|
|
|
|
|
/** Progress percentage (0-100) - overall progress */
|
|
|
|
|
|
percent: number;
|
|
|
|
|
|
|
|
|
|
|
|
/** Current profile being processed */
|
|
|
|
|
|
currentProfile?: string;
|
|
|
|
|
|
|
|
|
|
|
|
/** Progress percentage for current profile (0-100) */
|
|
|
|
|
|
profilePercent?: number;
|
|
|
|
|
|
|
|
|
|
|
|
/** Additional message */
|
|
|
|
|
|
message?: string;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* Result of DASH conversion
|
|
|
|
|
|
*/
|
|
|
|
|
|
export interface DashConvertResult {
|
2026-01-20 14:24:51 +03:00
|
|
|
|
/** Path to generated DASH manifest (если форматы включают DASH) */
|
2026-01-20 00:25:55 +03:00
|
|
|
|
manifestPath?: string;
|
|
|
|
|
|
|
2026-01-20 14:24:51 +03:00
|
|
|
|
/** Path to generated HLS manifest (если форматы включают HLS) */
|
2026-01-20 00:25:55 +03:00
|
|
|
|
hlsManifestPath?: string;
|
|
|
|
|
|
|
|
|
|
|
|
/** Paths to generated video segments */
|
|
|
|
|
|
videoPaths: string[];
|
|
|
|
|
|
|
|
|
|
|
|
/** Path to thumbnail sprite (if generated) */
|
|
|
|
|
|
thumbnailSpritePath?: string;
|
|
|
|
|
|
|
|
|
|
|
|
/** Path to thumbnail VTT file (if generated) */
|
|
|
|
|
|
thumbnailVttPath?: string;
|
|
|
|
|
|
|
|
|
|
|
|
/** Path to poster image (if generated) */
|
|
|
|
|
|
posterPath?: string;
|
|
|
|
|
|
|
|
|
|
|
|
/** Video duration in seconds */
|
|
|
|
|
|
duration: number;
|
|
|
|
|
|
|
|
|
|
|
|
/** Generated profiles */
|
|
|
|
|
|
profiles: VideoProfile[];
|
|
|
|
|
|
|
|
|
|
|
|
/** Whether NVENC was used */
|
|
|
|
|
|
usedNvenc: boolean;
|
|
|
|
|
|
|
|
|
|
|
|
/** Выбранный аппаратный ускоритель */
|
|
|
|
|
|
selectedAccelerator: HardwareAccelerator;
|
2026-01-20 10:38:25 +03:00
|
|
|
|
/** Выбранный аппаратный декодер */
|
|
|
|
|
|
selectedDecoder: HardwareAccelerator;
|
2026-01-20 00:25:55 +03:00
|
|
|
|
|
2026-01-20 14:24:51 +03:00
|
|
|
|
/** Список использованных кодеков */
|
|
|
|
|
|
codecs: CodecType[];
|
2026-01-20 00:25:55 +03:00
|
|
|
|
|
2026-01-20 14:24:51 +03:00
|
|
|
|
/** Список сгенерированных форматов */
|
|
|
|
|
|
formats: StreamingFormat[];
|
2026-01-20 00:25:55 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* Video metadata
|
|
|
|
|
|
*/
|
|
|
|
|
|
export interface VideoMetadata {
|
|
|
|
|
|
width: number;
|
|
|
|
|
|
height: number;
|
|
|
|
|
|
duration: number;
|
|
|
|
|
|
fps: number;
|
|
|
|
|
|
codec: string;
|
|
|
|
|
|
hasAudio: boolean; // Есть ли аудиодорожка
|
|
|
|
|
|
audioBitrate?: number; // Битрейт аудио в kbps
|
|
|
|
|
|
videoBitrate?: number; // Битрейт видео в kbps
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* Video optimizations (for future use)
|
|
|
|
|
|
*/
|
|
|
|
|
|
export interface VideoOptimizations {
|
|
|
|
|
|
/** Apply deinterlacing */
|
|
|
|
|
|
deinterlace?: boolean;
|
|
|
|
|
|
|
|
|
|
|
|
/** Apply denoising filter */
|
|
|
|
|
|
denoise?: boolean;
|
|
|
|
|
|
|
|
|
|
|
|
/** Color correction / LUT file path */
|
|
|
|
|
|
colorCorrection?: string;
|
|
|
|
|
|
|
|
|
|
|
|
/** Audio normalization */
|
|
|
|
|
|
audioNormalize?: boolean;
|
|
|
|
|
|
|
|
|
|
|
|
/** Custom FFmpeg filters */
|
|
|
|
|
|
customFilters?: string[];
|
|
|
|
|
|
}
|