[FFmpeg-trac] #979(swscale:open): Abnormal colorspace conversion of BGR -> YUV comparing the RGB variant
FFmpeg
trac at avcodec.org
Sat Aug 24 09:16:23 EEST 2024
#979: Abnormal colorspace conversion of BGR -> YUV comparing the RGB variant
------------------------------------+-----------------------------------
Reporter: natt | Owner: (none)
Type: defect | Status: open
Priority: normal | Component: swscale
Version: git-master | Resolution:
Keywords: | Blocked By:
Blocking: | Reproduced by developer: 0
Analyzed by developer: 0 |
------------------------------------+-----------------------------------
Comment (by Balling):
͏>"accurate_rnd" passed in alike manner shall work? Per my observation in
<colorspace>. Probably just failed this case..?
Okay, apparently -sws_flags accurate_rnd only works if you use it after -i
option. Good to know. Still it is more simple to use it inside vf scale.
Let's have some reference md5 here. I will convert the strange raw file
ffmpeg -f rawvideo -video_size 256x256 -pix_fmt bgr24 -i testin.raw
gfajfa.bmp and attach this file. This file has the same issue with
ffplay -i gfajfa.bmp -vf scale=out_color_matrix=bt709,format=yuv420p
Let's have some reference md5 here:
ffmpeg -i gfajfa.bmp -vf scale=out_color_matrix=bt709,format=yuv420p -f
framemd5 -
says md5 34e64aa3a7268a6002381af53366ad09
Now convert bmp to png, this now has rgb24:
ffmpeg -i gfajfa.bmp anfca.png
and
ffmpeg -i anfca.png -vf scale=out_color_matrix=bt709,format=yuv420p -f
framemd5 -
fef01c4f4721b3ab650088081ac6616d
yep, **md5 is not the same**, this is the bug. But if you add -sws_flags
accurate_rnd after -i both md5 become
52c2faebb1c31fba70487f43887b46de.
Now we need to understand where is the problem is and which is closer to
52c2faebb1c31fba70487f43887b46de: 255, 255, 255 color problem is gone, so
it is harder to tell where the issue is. Indeed, in older version from
2020 the md5 of png file to yuv420p frame is the same, but bmp to yuv420p
differs in old and in new, so this issue is partially fixed. Let's compare
the files between accurate_rnd and without (two files without) in hex
editor.
INDEED, the accurate_rnd and ffmpeg -i anfca1.png -vf
scale=out_color_matrix=bt709,format=yuv420p filee.yuv are mostly the same
(in the start of the file), yet ffmpeg -i gfajfa.bmp -vf
scale=out_color_matrix=bt709,format=yuv420p file.yuv is not even close.
--
Ticket URL: <https://trac.ffmpeg.org/ticket/979#comment:21>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker
More information about the FFmpeg-trac
mailing list