From 69b5eb005f055ffd05e942888a00227acc7f7d29 Mon Sep 17 00:00:00 2001 From: Mert <101130780+mertalev@users.noreply.github.com> Date: Fri, 24 May 2024 04:50:28 -0400 Subject: [PATCH] fix(server): use qsv format for hwmap (#9722) use qsv format for hwmap --- server/src/services/media.service.spec.ts | 16 +++++++++++++--- server/src/utils/media.ts | 4 ++-- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/server/src/services/media.service.spec.ts b/server/src/services/media.service.spec.ts index 3c8200944e..9fe0038232 100644 --- a/server/src/services/media.service.spec.ts +++ b/server/src/services/media.service.spec.ts @@ -1496,7 +1496,12 @@ describe(MediaService.name, () => { '/original/path.ext', 'upload/encoded-video/user-id/as/se/asset-id.mp4', { - inputOptions: expect.arrayContaining(['-hwaccel qsv', '-async_depth 4', '-threads 1']), + inputOptions: expect.arrayContaining([ + '-hwaccel qsv', + '-hwaccel_output_format qsv', + '-async_depth 4', + '-threads 1', + ]), outputOptions: expect.arrayContaining([ expect.stringContaining('scale_qsv=-1:720:async_depth=4:mode=hq:format=nv12'), ]), @@ -1519,10 +1524,15 @@ describe(MediaService.name, () => { '/original/path.ext', 'upload/encoded-video/user-id/as/se/asset-id.mp4', { - inputOptions: expect.arrayContaining(['-hwaccel qsv', '-async_depth 4', '-threads 1']), + inputOptions: expect.arrayContaining([ + '-hwaccel qsv', + '-hwaccel_output_format qsv', + '-async_depth 4', + '-threads 1', + ]), outputOptions: expect.arrayContaining([ expect.stringContaining( - 'hwmap=derive_device=opencl,tonemap_opencl=desat=0:format=nv12:matrix=bt709:primaries=bt709:range=pc:tonemap=hable:transfer=bt709,hwmap=derive_device=vaapi:reverse=1', + 'hwmap=derive_device=opencl,tonemap_opencl=desat=0:format=nv12:matrix=bt709:primaries=bt709:range=pc:tonemap=hable:transfer=bt709,hwmap=derive_device=qsv:reverse=1,format=qsv', ), ]), twoPass: false, diff --git a/server/src/utils/media.ts b/server/src/utils/media.ts index 268f1f60ce..5a57f0f0cf 100644 --- a/server/src/utils/media.ts +++ b/server/src/utils/media.ts @@ -649,7 +649,7 @@ export class QsvHwDecodeConfig extends QsvSwDecodeConfig { throw new Error('No QSV device found'); } - const options = ['-hwaccel qsv', '-async_depth 4', '-threads 1']; + const options = ['-hwaccel qsv', '-hwaccel_output_format qsv', '-async_depth 4', '-threads 1']; const hwDevice = this.getPreferredHardwareDevice(); if (hwDevice) { options.push(`-qsv_device ${hwDevice}`); @@ -691,7 +691,7 @@ export class QsvHwDecodeConfig extends QsvSwDecodeConfig { return [ 'hwmap=derive_device=opencl', `tonemap_opencl=${tonemapOptions.join(':')}`, - 'hwmap=derive_device=vaapi:reverse=1', + 'hwmap=derive_device=qsv:reverse=1,format=qsv', ]; } }