2024-02-02 04:18:00 +01:00
|
|
|
import { Writable } from 'node:stream';
|
2024-04-02 00:56:56 -04:00
|
|
|
import { ImageFormat, TranscodeTarget, VideoCodec } from 'src/entities/system-config.entity';
|
2023-08-01 21:56:10 -04:00
|
|
|
|
2023-02-25 09:12:03 -05:00
|
|
|
export const IMediaRepository = 'IMediaRepository';
|
|
|
|
|
|
2024-05-08 09:09:34 -04:00
|
|
|
export interface CropOptions {
|
|
|
|
|
top: number;
|
|
|
|
|
left: number;
|
|
|
|
|
width: number;
|
|
|
|
|
height: number;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface ThumbnailOptions {
|
2023-02-25 09:12:03 -05:00
|
|
|
size: number;
|
2024-04-02 00:56:56 -04:00
|
|
|
format: ImageFormat;
|
2023-09-03 02:21:51 -04:00
|
|
|
colorspace: string;
|
|
|
|
|
quality: number;
|
2024-05-08 09:09:34 -04:00
|
|
|
crop?: CropOptions;
|
2023-02-25 09:12:03 -05:00
|
|
|
}
|
|
|
|
|
|
2023-04-04 10:48:02 -04:00
|
|
|
export interface VideoStreamInfo {
|
2023-08-29 05:01:42 -04:00
|
|
|
index: number;
|
2023-04-04 10:48:02 -04:00
|
|
|
height: number;
|
|
|
|
|
width: number;
|
|
|
|
|
rotation: number;
|
|
|
|
|
codecName?: string;
|
|
|
|
|
frameCount: number;
|
2023-08-07 16:35:25 -04:00
|
|
|
isHDR: boolean;
|
2024-02-14 11:24:39 -05:00
|
|
|
bitrate: number;
|
2023-04-04 10:48:02 -04:00
|
|
|
}
|
|
|
|
|
|
2023-04-06 04:32:59 +01:00
|
|
|
export interface AudioStreamInfo {
|
2023-08-29 05:01:42 -04:00
|
|
|
index: number;
|
2023-04-06 04:32:59 +01:00
|
|
|
codecName?: string;
|
2023-08-29 05:01:42 -04:00
|
|
|
frameCount: number;
|
2023-04-06 04:32:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface VideoFormat {
|
|
|
|
|
formatName?: string;
|
|
|
|
|
formatLongName?: string;
|
|
|
|
|
duration: number;
|
2024-01-31 02:25:07 +01:00
|
|
|
bitrate: number;
|
2023-04-06 04:32:59 +01:00
|
|
|
}
|
|
|
|
|
|
2024-04-19 11:50:13 -04:00
|
|
|
export interface ImageDimensions {
|
|
|
|
|
width: number;
|
|
|
|
|
height: number;
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-04 10:48:02 -04:00
|
|
|
export interface VideoInfo {
|
2023-04-06 04:32:59 +01:00
|
|
|
format: VideoFormat;
|
|
|
|
|
videoStreams: VideoStreamInfo[];
|
|
|
|
|
audioStreams: AudioStreamInfo[];
|
2023-04-04 10:48:02 -04:00
|
|
|
}
|
|
|
|
|
|
2023-05-22 14:07:43 -04:00
|
|
|
export interface TranscodeOptions {
|
2023-07-08 22:43:11 -04:00
|
|
|
inputOptions: string[];
|
2023-05-22 14:07:43 -04:00
|
|
|
outputOptions: string[];
|
|
|
|
|
twoPass: boolean;
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-08 22:43:11 -04:00
|
|
|
export interface BitrateDistribution {
|
|
|
|
|
max: number;
|
|
|
|
|
target: number;
|
|
|
|
|
min: number;
|
|
|
|
|
unit: string;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface VideoCodecSWConfig {
|
2024-02-14 11:24:39 -05:00
|
|
|
getOptions(target: TranscodeTarget, videoStream: VideoStreamInfo, audioStream: AudioStreamInfo): TranscodeOptions;
|
2023-07-08 22:43:11 -04:00
|
|
|
}
|
|
|
|
|
|
2023-08-01 21:56:10 -04:00
|
|
|
export interface VideoCodecHWConfig extends VideoCodecSWConfig {
|
|
|
|
|
getSupportedCodecs(): Array<VideoCodec>;
|
|
|
|
|
}
|
|
|
|
|
|
2023-02-25 09:12:03 -05:00
|
|
|
export interface IMediaRepository {
|
2023-04-04 10:48:02 -04:00
|
|
|
// image
|
2024-04-19 11:50:13 -04:00
|
|
|
extract(input: string, output: string): Promise<boolean>;
|
2024-05-08 09:09:34 -04:00
|
|
|
generateThumbnail(input: string | Buffer, output: string, options: ThumbnailOptions): Promise<void>;
|
2023-06-17 23:22:31 -04:00
|
|
|
generateThumbhash(imagePath: string): Promise<Buffer>;
|
2024-04-19 11:50:13 -04:00
|
|
|
getImageDimensions(input: string): Promise<ImageDimensions>;
|
2023-04-04 10:48:02 -04:00
|
|
|
|
|
|
|
|
// video
|
|
|
|
|
probe(input: string): Promise<VideoInfo>;
|
2023-09-03 02:21:51 -04:00
|
|
|
transcode(input: string, output: string | Writable, options: TranscodeOptions): Promise<void>;
|
2023-02-25 09:12:03 -05:00
|
|
|
}
|