BGR48BE to yuv420p10le conversion - which rgb2yuv coefficients are actually used?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

BGR48BE to yuv420p10le conversion - which rgb2yuv coefficients are actually used?

Michał Kudelski
Hi All,

I am converting 16-bit PNG frames to yuv420p10le (and encoding them to
HDR10 videos) with the following command:

ffmpeg \
    -pix_fmt bgr48be \
    -framerate 23.976 \
    -i "${1}%05d${extension}" \
    -color_primaries 9 \
    -color_trc 16 \
    -colorspace 9 \
    -color_range 1 \
    -c:v libx265 \
    -pix_fmt yuv420p10le \
    -crf 1 \
    -b:v 0 \
    output.mkv


It seems to work correct, but I need to reproduce the BGR48BE to
yuv420p10le conversion outside of the ffmpeg. For this, I need to know the
underlying rgb2yuv coefficients.

Assuming Y' = WR⋅R′ + WG⋅G′ + WB⋅B′, is it:
a) WR = 0.2627, WB = 0.0593, WG = 1−KR−KB = 0.678 [bt.601]
b) WR = 0.299, WB = 0.114, WG = 1−WR−WB = ...          [bt.709]
c) WR = 0.2126, WB = 0.0722, WG =  1−WR−WB = ...     [bt.2020]
d) other?

Best regards,
Michal Kudelski
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: BGR48BE to yuv420p10le conversion - which rgb2yuv coefficients are actually used?

Carl Eugen Hoyos-2
Am Do., 14. Mai 2020 um 14:51 Uhr schrieb Michał Kudelski
<[hidden email]>:

> I am converting 16-bit PNG frames to yuv420p10le (and encoding them to
> HDR10 videos) with the following command:

(I am not convinced that the output is HDR10 but I may misunderstand.)

> ffmpeg \
>     -pix_fmt bgr48be \
>     -framerate 23.976 \
>     -i "${1}%05d${extension}" \
>     -color_primaries 9 \
>     -color_trc 16 \
>     -colorspace 9 \
>     -color_range 1 \
>     -c:v libx265 \
>     -pix_fmt yuv420p10le \
>     -crf 1 \
>     -b:v 0 \
>     output.mkv
>
> It seems to work correct, but I need to reproduce the BGR48BE to
> yuv420p10le conversion outside of the ffmpeg. For this, I need to
> know the underlying rgb2yuv coefficients.

I believe they are set in fill_rgb2yuv_table() in libswscale/utils.c and
you should be able to request different coefficients.

Carl Eugen
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".