Skip to content

[VAAPI] [AMD] Slightly wrong HDR colors after transcoding with no tonemapping #23631

@mik9

Description

@mik9

I have searched the existing issues, both open and closed, to make sure this is not a duplicate report.

  • Yes

The bug

VAAPI hardware: Radeon Vega integrated into 5600g

I tries to setup video transcoding without tonemapping (since most modern devices support HDR) and observed that in transcoded video colors are slightly off. After some investigation I found the cause: out_range=pc parameter in scale_vaapi filter. When I run transcoding without that parameter colors are fine.

Observed result (left to right Original/Transcoded with out_range=pc/Transcoded without out_range=pc). Had to take a photo because SDR screenshot of HDR content on mac looks absolutely wrong. Green leaf on the middle image are slightly brighter than other 2.

Image

The OS that Immich Server is running on

ubuntu-server 24.04

Version of Immich Server

v2.1.0

Version of Immich Mobile App

v2.1.0

Platform with the issue

  • Server
  • Web
  • Mobile

Device make and model

No response

Your docker-compose.yml content

from documentation

Your .env content

from documentation

Reproduction steps

  1. Transcoding settings: Video codec = hevc
  2. Target resolution = original
  3. CRF = 35
  4. Preset = fast
  5. Maximum bitrate = 0
  6. Tone-mapping = disabled
  7. Acceleration API = VAAPI
  8. ======
  9. Take HDR video on iPhone
  10. Upload
  11. Let it transcode
  12. Download transcoded video
  13. Compare colors

Relevant log output

Additional information

ffmpeg args from ps aux
ffmpeg command with issue:

/usr/bin/ffmpeg -hwaccel vaapi -hwaccel_output_format vaapi -noautorotate -hwaccel_device /dev/dri/renderD128 -threads 1 -i /data/library/admin/... -y -c:v hevc_vaapi -c:a copy -movflags faststart -fps_mode passthrough -map 0:0 -map_metadata -1 -map 0:1 -g 256 -tag:v hvc1 -v verbose -vf scale_vaapi=2160:-2:mode=hq:out_range=pc:format=nv12 -compression_level 5 -qp:v 35 -global_quality:v 35 -rc_mode 1 /data/encoded-video/...

ffmpeg command without issue:
/usr/bin/ffmpeg -hwaccel vaapi -hwaccel_output_format vaapi -noautorotate -hwaccel_device /dev/dri/renderD128 -threads 1 -i /data/library/admin/... -y -c:v hevc_vaapi -c:a copy -movflags faststart -fps_mode passthrough -map 0:0 -map_metadata -1 -map 0:1 -g 256 -tag:v hvc1 -v verbose -vf scale_vaapi=format=nv12 -compression_level 5 -qp:v 35 -global_quality:v 35 -rc_mode 1 /data/encoded-video/...

UPD: out_range=tv also produces correct colors

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    To triage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions