mirror of
https://github.com/KevinMidboe/immich.git
synced 2025-10-29 17:40:28 +00:00
feat(all): transcoding improvements (#2171)
* test: rename some fixtures and add text for vertical video conversion * feat: transcode video asset when audio or container don't match target * chore: add niceness to the ffmpeg command to allow other processes to be prioritised * chore: change video conversion queue to one concurrency * feat: add transcode disabled preset to completely turn off transcoding * linter * Change log level and remove unused await * opps forgot to save * better logging --------- Co-authored-by: Alex Tran <alex.tran1502@gmail.com>
This commit is contained in:
@@ -37,6 +37,7 @@ export enum TranscodePreset {
|
||||
ALL = 'all',
|
||||
OPTIMAL = 'optimal',
|
||||
REQUIRED = 'required',
|
||||
DISABLED = 'disabled',
|
||||
}
|
||||
|
||||
export interface SystemConfig {
|
||||
|
||||
@@ -50,20 +50,33 @@ export class MediaRepository implements IMediaRepository {
|
||||
const results = await probe(input);
|
||||
|
||||
return {
|
||||
streams: results.streams.map((stream) => ({
|
||||
height: stream.height || 0,
|
||||
width: stream.width || 0,
|
||||
codecName: stream.codec_name,
|
||||
codecType: stream.codec_type,
|
||||
frameCount: Number.parseInt(stream.nb_frames ?? '0'),
|
||||
rotation: Number.parseInt(`${stream.rotation ?? 0}`),
|
||||
})),
|
||||
format: {
|
||||
formatName: results.format.format_name,
|
||||
formatLongName: results.format.format_long_name,
|
||||
duration: results.format.duration || 0,
|
||||
},
|
||||
videoStreams: results.streams
|
||||
.filter((stream) => stream.codec_type === 'video')
|
||||
.map((stream) => ({
|
||||
height: stream.height || 0,
|
||||
width: stream.width || 0,
|
||||
codecName: stream.codec_name,
|
||||
codecType: stream.codec_type,
|
||||
frameCount: Number.parseInt(stream.nb_frames ?? '0'),
|
||||
rotation: Number.parseInt(`${stream.rotation ?? 0}`),
|
||||
})),
|
||||
audioStreams: results.streams
|
||||
.filter((stream) => stream.codec_type === 'audio')
|
||||
.map((stream) => ({
|
||||
codecType: stream.codec_type,
|
||||
codecName: stream.codec_name,
|
||||
})),
|
||||
};
|
||||
}
|
||||
|
||||
transcode(input: string, output: string, options: string[]): Promise<void> {
|
||||
return new Promise((resolve, reject) => {
|
||||
ffmpeg(input)
|
||||
ffmpeg(input, { niceness: 10 })
|
||||
//
|
||||
.outputOptions(options)
|
||||
.output(output)
|
||||
|
||||
Reference in New Issue
Block a user