diff --git a/server/Dockerfile b/server/Dockerfile index 205eaeb208..0e588066f6 100644 --- a/server/Dockerfile +++ b/server/Dockerfile @@ -1,5 +1,5 @@ # dev build -FROM ghcr.io/immich-app/base-server-dev:20240507@sha256:ca3b8f7ca4ef72cb191b97d2715bfa0e3decdf39e666c5020536e41cf14cee1e as dev +FROM ghcr.io/immich-app/base-server-dev:main as dev RUN apt-get install --no-install-recommends -yqq tini WORKDIR /usr/src/app @@ -41,7 +41,7 @@ RUN npm run build # prod build -FROM ghcr.io/immich-app/base-server-prod:20240507@sha256:1394878615cc665fd6b04f07b78d6586bb5d888423cdf8987cea072d1d72fd1f +FROM ghcr.io/immich-app/base-server-prod:main WORKDIR /usr/src/app ENV NODE_ENV=production \ diff --git a/server/src/utils/media.ts b/server/src/utils/media.ts index ff38ded631..859cd3f4bc 100644 --- a/server/src/utils/media.ts +++ b/server/src/utils/media.ts @@ -440,7 +440,7 @@ export class NVENCConfig extends BaseHWConfig { } getBaseInputOptions() { - return ['-init_hw_device cuda=cuda:0', '-filter_hw_device cuda']; + return ['-hwaccel cuda', '-hwaccel_output_format cuda']; } getBaseOutputOptions(target: TranscodeTarget, videoStream: VideoStreamInfo, audioStream?: AudioStreamInfo) { @@ -461,13 +461,27 @@ export class NVENCConfig extends BaseHWConfig { return options; } + getToneMapping() { + const colors = this.getColors(); + + // https://stackoverflow.com/a/65542002 + return [ + 'hwupload=derive_device=vulkan', + `libplacebo=tonemapping=${this.config.tonemap}:colorspace=${colors.matrix}:color_primaries=${colors.primaries}:color_trc=${colors.transfer}:format=yuv420p:preset=high_quality:downscaler=lanczos`, + 'hwupload=derive_device=cuda', + ]; + } + getFilterOptions(videoStream: VideoStreamInfo) { - const options = this.shouldToneMap(videoStream) ? this.getToneMapping() : []; - options.push('format=nv12', 'hwupload_cuda'); + const options = []; if (this.shouldScale(videoStream)) { options.push(`scale_cuda=${this.getScaling(videoStream)}`); } + if (this.shouldToneMap(videoStream)) { + options.push(...this.getToneMapping()); + } + return options; } @@ -501,7 +515,7 @@ export class NVENCConfig extends BaseHWConfig { } getThreadOptions() { - return []; + return [`-threads ${this.config.threads <= 0 ? 1 : this.config.threads}`]; } getRefs() {