mirror of
https://github.com/immich-app/immich
synced 2025-06-11 01:28:30 +00:00

* do crop and resize together * redundant `pipelineColorspace` call * formatting * fix rebase * handle orientation * remove unused import * formatting * use oriented dimensions for half size calculation * default case for orientation * simplify orientation code --------- Co-authored-by: Alex <alex.tran1502@gmail.com>
88 lines
2.0 KiB
TypeScript
88 lines
2.0 KiB
TypeScript
import { Writable } from 'node:stream';
|
|
import { ImageFormat, TranscodeTarget, VideoCodec } from 'src/entities/system-config.entity';
|
|
|
|
export const IMediaRepository = 'IMediaRepository';
|
|
|
|
export interface CropOptions {
|
|
top: number;
|
|
left: number;
|
|
width: number;
|
|
height: number;
|
|
}
|
|
|
|
export interface ThumbnailOptions {
|
|
size: number;
|
|
format: ImageFormat;
|
|
colorspace: string;
|
|
quality: number;
|
|
crop?: CropOptions;
|
|
}
|
|
|
|
export interface VideoStreamInfo {
|
|
index: number;
|
|
height: number;
|
|
width: number;
|
|
rotation: number;
|
|
codecName?: string;
|
|
frameCount: number;
|
|
isHDR: boolean;
|
|
bitrate: number;
|
|
}
|
|
|
|
export interface AudioStreamInfo {
|
|
index: number;
|
|
codecName?: string;
|
|
frameCount: number;
|
|
}
|
|
|
|
export interface VideoFormat {
|
|
formatName?: string;
|
|
formatLongName?: string;
|
|
duration: number;
|
|
bitrate: number;
|
|
}
|
|
|
|
export interface ImageDimensions {
|
|
width: number;
|
|
height: number;
|
|
}
|
|
|
|
export interface VideoInfo {
|
|
format: VideoFormat;
|
|
videoStreams: VideoStreamInfo[];
|
|
audioStreams: AudioStreamInfo[];
|
|
}
|
|
|
|
export interface TranscodeOptions {
|
|
inputOptions: string[];
|
|
outputOptions: string[];
|
|
twoPass: boolean;
|
|
}
|
|
|
|
export interface BitrateDistribution {
|
|
max: number;
|
|
target: number;
|
|
min: number;
|
|
unit: string;
|
|
}
|
|
|
|
export interface VideoCodecSWConfig {
|
|
getOptions(target: TranscodeTarget, videoStream: VideoStreamInfo, audioStream: AudioStreamInfo): TranscodeOptions;
|
|
}
|
|
|
|
export interface VideoCodecHWConfig extends VideoCodecSWConfig {
|
|
getSupportedCodecs(): Array<VideoCodec>;
|
|
}
|
|
|
|
export interface IMediaRepository {
|
|
// image
|
|
extract(input: string, output: string): Promise<boolean>;
|
|
generateThumbnail(input: string | Buffer, output: string, options: ThumbnailOptions): Promise<void>;
|
|
generateThumbhash(imagePath: string): Promise<Buffer>;
|
|
getImageDimensions(input: string): Promise<ImageDimensions>;
|
|
|
|
// video
|
|
probe(input: string): Promise<VideoInfo>;
|
|
transcode(input: string, output: string | Writable, options: TranscodeOptions): Promise<void>;
|
|
}
|