diff --git a/server/src/services/media.service.spec.ts b/server/src/services/media.service.spec.ts index 65d35047d7..6152c47218 100644 --- a/server/src/services/media.service.spec.ts +++ b/server/src/services/media.service.spec.ts @@ -2260,7 +2260,7 @@ describe(MediaService.name, () => { ); }); - it('should use software tone-mapping if opencl is not available', async () => { + it('should use software decoding and tone-mapping if opencl is not available', async () => { storageMock.readdir.mockResolvedValue(['renderD128']); storageMock.stat.mockResolvedValue({ isFile: () => false, isCharacterDevice: () => false } as Stats); mediaMock.probe.mockResolvedValue(probeStub.videoStreamHDR); @@ -2273,10 +2273,10 @@ describe(MediaService.name, () => { '/original/path.ext', 'upload/encoded-video/user-id/as/se/asset-id.mp4', expect.objectContaining({ - inputOptions: expect.any(Array), + inputOptions: [], outputOptions: expect.arrayContaining([ expect.stringContaining( - 'tonemapx=tonemap=hable:desat=0:p=bt709:t=bt709:m=bt709:r=pc:peak=100:format=', + 'tonemapx=tonemap=hable:desat=0:p=bt709:t=bt709:m=bt709:r=pc:peak=100:format=yuv420p', ), ]), twoPass: false, diff --git a/server/src/utils/media.ts b/server/src/utils/media.ts index 119c3db8fd..b242be8507 100644 --- a/server/src/utils/media.ts +++ b/server/src/utils/media.ts @@ -924,7 +924,8 @@ export class RkmppSwDecodeConfig extends BaseHWConfig { return false; } - getBaseInputOptions(): string[] { + // eslint-disable-next-line @typescript-eslint/no-unused-vars + getBaseInputOptions(videoStream: VideoStreamInfo): string[] { if (this.devices.length === 0) { throw new Error('No RKMPP device found'); } @@ -977,12 +978,16 @@ export class RkmppHwDecodeConfig extends RkmppSwDecodeConfig { this.hasMaliOpenCL = hasMaliOpenCL; } - getBaseInputOptions() { + getBaseInputOptions(videoStream: VideoStreamInfo) { if (this.devices.length === 0) { throw new Error('No RKMPP device found'); } - return ['-hwaccel rkmpp', '-hwaccel_output_format drm_prime', '-afbc rga', '-noautorotate']; + if (!this.shouldToneMap(videoStream) || (this.shouldToneMap(videoStream) && this.hasMaliOpenCL)) { + return ['-hwaccel rkmpp', '-hwaccel_output_format drm_prime', '-afbc rga', '-noautorotate']; + } + + return []; } getFilterOptions(videoStream: VideoStreamInfo) { @@ -997,13 +1002,8 @@ export class RkmppHwDecodeConfig extends RkmppSwDecodeConfig { 'format=drm_prime', ]; } - return [ // use RKMPP for scaling, CPU for tone mapping - `scale_rkrga=${this.getScaling(videoStream)}:format=nv12`, - 'hwdownload', - 'format=nv12', - `tonemapx=tonemap=${this.config.tonemap}:desat=0:p=${primaries}:t=${transfer}:m=${matrix}:r=pc:peak=100:format=nv12`, - 'hwupload', - ]; + // use CPU for scaling & tone mapping + return super.getFilterOptions(videoStream); } else if (this.shouldScale(videoStream)) { return [`scale_rkrga=${this.getScaling(videoStream)}:format=nv12:afbc=1`]; }