mirror of
https://github.com/KevinMidboe/immich.git
synced 2026-01-05 16:55:48 +00:00
feat(server): transcode bitrate and thread settings (#2488)
* support for two-pass transcoding * added max bitrate and thread to transcode api * admin page setting desc+bitrate and thread options * Update web/src/lib/components/admin-page/settings/setting-input-field.svelte Co-authored-by: Michel Heusschen <59014050+michelheusschen@users.noreply.github.com> * Update web/src/lib/components/admin-page/settings/setting-input-field.svelte Co-authored-by: Michel Heusschen <59014050+michelheusschen@users.noreply.github.com> * two-pass slider, `crf` and `threads` as numbers * updated and added transcode tests * refactored `getFfmpegOptions` * default `threads`, `maxBitrate` now 0, more tests * vp9 constant quality mode * fixed nullable `crf` and `threads` * fixed two-pass slider, added apiproperty * optional `desc` for `SettingSelect` * disable two-pass if settings are incompatible * fixed test * transcode interface --------- Co-authored-by: Michel Heusschen <59014050+michelheusschen@users.noreply.github.com>
This commit is contained in:
@@ -1,9 +1,21 @@
|
||||
import { IsEnum, IsString } from 'class-validator';
|
||||
import { IsEnum, IsString, IsInt, IsBoolean, Min, Max } from 'class-validator';
|
||||
import { TranscodePreset } from '@app/infra/entities';
|
||||
import { Type } from 'class-transformer';
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
|
||||
export class SystemConfigFFmpegDto {
|
||||
@IsString()
|
||||
crf!: string;
|
||||
@IsInt()
|
||||
@Min(0)
|
||||
@Max(51)
|
||||
@Type(() => Number)
|
||||
@ApiProperty({ type: 'integer' })
|
||||
crf!: number;
|
||||
|
||||
@IsInt()
|
||||
@Min(0)
|
||||
@Type(() => Number)
|
||||
@ApiProperty({ type: 'integer' })
|
||||
threads!: number;
|
||||
|
||||
@IsString()
|
||||
preset!: string;
|
||||
@@ -17,6 +29,12 @@ export class SystemConfigFFmpegDto {
|
||||
@IsString()
|
||||
targetResolution!: string;
|
||||
|
||||
@IsString()
|
||||
maxBitrate!: string;
|
||||
|
||||
@IsBoolean()
|
||||
twoPass!: boolean;
|
||||
|
||||
@IsEnum(TranscodePreset)
|
||||
transcode!: TranscodePreset;
|
||||
}
|
||||
|
||||
@@ -9,11 +9,14 @@ export type SystemConfigValidator = (config: SystemConfig) => void | Promise<voi
|
||||
|
||||
const defaults: SystemConfig = Object.freeze({
|
||||
ffmpeg: {
|
||||
crf: '23',
|
||||
crf: 23,
|
||||
threads: 0,
|
||||
preset: 'ultrafast',
|
||||
targetVideoCodec: 'h264',
|
||||
targetAudioCodec: 'aac',
|
||||
targetResolution: '720',
|
||||
maxBitrate: '0',
|
||||
twoPass: false,
|
||||
transcode: TranscodePreset.REQUIRED,
|
||||
},
|
||||
oauth: {
|
||||
|
||||
@@ -7,17 +7,20 @@ import { ISystemConfigRepository } from './system-config.repository';
|
||||
import { SystemConfigService } from './system-config.service';
|
||||
|
||||
const updates: SystemConfigEntity[] = [
|
||||
{ key: SystemConfigKey.FFMPEG_CRF, value: 'a new value' },
|
||||
{ key: SystemConfigKey.FFMPEG_CRF, value: 30 },
|
||||
{ key: SystemConfigKey.OAUTH_AUTO_LAUNCH, value: true },
|
||||
];
|
||||
|
||||
const updatedConfig = Object.freeze({
|
||||
ffmpeg: {
|
||||
crf: 'a new value',
|
||||
crf: 30,
|
||||
threads: 0,
|
||||
preset: 'ultrafast',
|
||||
targetAudioCodec: 'aac',
|
||||
targetResolution: '720',
|
||||
targetVideoCodec: 'h264',
|
||||
maxBitrate: '0',
|
||||
twoPass: false,
|
||||
transcode: TranscodePreset.REQUIRED,
|
||||
},
|
||||
oauth: {
|
||||
@@ -85,7 +88,7 @@ describe(SystemConfigService.name, () => {
|
||||
|
||||
it('should merge the overrides', async () => {
|
||||
configMock.load.mockResolvedValue([
|
||||
{ key: SystemConfigKey.FFMPEG_CRF, value: 'a new value' },
|
||||
{ key: SystemConfigKey.FFMPEG_CRF, value: 30 },
|
||||
{ key: SystemConfigKey.OAUTH_AUTO_LAUNCH, value: true },
|
||||
]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user