Bug 498263 - Exporting with pix_fmt=yuv444p does not use 4:4:4 chroma subsampling
Summary: Exporting with pix_fmt=yuv444p does not use 4:4:4 chroma subsampling
Status: CONFIRMED
Alias: None
Product: kdenlive
Classification: Applications
Component: Rendering & Export (show other bugs)
Version: 24.12.0
Platform: Arch Linux Linux
: NOR normal
Target Milestone: ---
Assignee: Jean-Baptiste Mardelle
URL:
Keywords: triaged
Depends on:
Blocks:
 
Reported: 2025-01-04 22:00 UTC by bugreports.l7dy6
Modified: 2025-01-17 20:19 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
Source image, Kdenlive project file, Kdenlive render script, Kdenlive video, FFmpeg video (110.00 KB, application/x-tar)
2025-01-04 22:00 UTC, bugreports.l7dy6
Details
A comparison showing that Kdenlive renders a lossy image, even when yuv444p and qp=0 are specified. (34.98 KB, image/png)
2025-01-17 20:19 UTC, bugreports.l7dy6
Details

Note You need to log in before you can comment on or make changes to this bug.
Description bugreports.l7dy6 2025-01-04 22:00:15 UTC
Created attachment 177114 [details]
Source image, Kdenlive project file, Kdenlive render script, Kdenlive video, FFmpeg video

SUMMARY
I have H.264 videos encoded in the yuv444p pixel format, and I would like to edit them in Kdenlive and export them in yuv444p. I've tried creating a custom render preset with the "pix_fmt=yuv444p" flag added, exporting with crf=0 which is supposed to be lossless, and enabling "Render full color range", but the exported video still shows subsampling artifacts, despite being in the yuv444p format according to VLC and FFmpeg.

STEPS TO REPRODUCE
1. Add a PNG image or yuv444p video to the timeline
2. Use a custom render preset that has "pix_fmt=yuv444p"
3. Take a screenshot of the rendered video with VLC or FFmpeg

OBSERVED RESULT
Video is encoded in yuv444p format, but still shows chroma subsampling artifacts

EXPECTED RESULT
Video is encoded in yuv444p format and has no chroma subsampling artifacts (and is identical to the original if exported with crf=0)

SOFTWARE/OS VERSIONS
Arch Linux
Kernel Version: 6.12.7-arch1-1 (64-bit)
KDE Plasma Version: 6.2.4
KDE Frameworks Version: 6.9.0
Qt Version: 6.8.1

ADDITIONAL INFORMATION
I've attached the project files used to demonstrate this issue, along with an FFmpeg-rendered video that shows the correct behavior (has no chroma subsampling artifacts).
Comment 1 emohr 2025-01-05 19:49:56 UTC
Thank you for reporting. Kdenlive works with 8-bit sampling only.
Update to 10bit is ongoing.
Comment 2 bugreports.l7dy6 2025-01-06 21:14:19 UTC
(In reply to emohr from comment #1)
> Thank you for reporting. Kdenlive works with 8-bit sampling only.
> Update to 10bit is ongoing.

Thank you for the fast response.
I'm not an expert with video terminology, but I believe that we're talking about two different things. I was referring to chroma subsampling (https://en.wikipedia.org/wiki/Chroma_subsampling) while 8-bit and 10-bit refer to color depth (https://en.wikipedia.org/wiki/Color_depth). I'm only working with 8-bit videos.
Comment 3 emohr 2025-01-11 08:53:09 UTC
Do not use H264 encoding due to YUY 4:4:4 encoding limitations.
Use x264 encoding with -qp 0 parameter to get a lossless YUY 4:4:4 output file.

In detail:
YUV 4:4:4 pixel format (yuv444p) can be used for H.264 encoding, but it has limitations. While x264 supports lossless encoding with yuv444p, it requires specific configurations, such as using -qp 0 for lossless output. However, many H.264 encoders primarily support yuv420p due to compatibility issues with various players and devices

Additionally, profiles like high444 are not compatible with lossless encoding in x264
Therefore, while technically possible, practical use may be limited depending on the encoder and target playback devices.

Therefore, it is not suggested to use h264 for encoding in yuv444.

For example NVIDIA's NVENC can encode H.264 video in the YUV 4:4:4 format, as confirmed by user experiences with FFmpeg and the h264_nvenc encoder. However, while encoding is supported, decoding H.264 YUV 4:4:4 is not supported by NVDEC, which only handles YUV 4:2:0 for H.264. Thus, you can encode using NVENC but will need software decoding methods for YUV 4:4:4 content.
Comment 4 bugreports.l7dy6 2025-01-17 20:17:23 UTC
(In reply to emohr from comment #3)
> Do not use H264 encoding due to YUY 4:4:4 encoding limitations.
> Use x264 encoding with -qp 0 parameter to get a lossless YUY 4:4:4 output file.
H264 is what x264 encodes to. I'm assuming that you're talking about hardware H264 encoders (as opposed to x264 which is a software encoder). I've always used x264 because I know that my hardware encoder can't do 4:4:4.

> YUV 4:4:4 pixel format (yuv444p) can be used for H.264 encoding, but it has
> limitations. While x264 supports lossless encoding with yuv444p, it requires
> specific configurations, such as using -qp 0 for lossless output.
According to FFmpeg's wiki (https://trac.ffmpeg.org/wiki/Encode/H.264#a1.ChooseaCRFvalue), using -crf 0 is lossless for 8-bit videos, but I did run another test using -qp 0 to see if anything changed. See the image I attached. Unfortunately, Kdenlive still renders with inaccurate colors, even though I set qp=0 in the render script. The artifacts look similar to an FFmpeg render at yuv422p.
Comment 5 bugreports.l7dy6 2025-01-17 20:19:56 UTC
Created attachment 177468 [details]
A comparison showing that Kdenlive renders a lossy image, even when yuv444p and qp=0 are specified.