[FFmpeg-trac] #8056(undetermined:closed): Convert BMP/JPG to YUV420p video color shift, but not PNG
FFmpeg
trac at avcodec.org
Tue Sep 17 08:51:44 EEST 2019
#8056: Convert BMP/JPG to YUV420p video color shift, but not PNG
-------------------------------------+-------------------------------------
Reporter: fireattack | Owner:
Type: defect | Status: closed
Priority: normal | Component:
| undetermined
Version: unspecified | Resolution: duplicate
Keywords: | Blocked By:
Blocking: | Reproduced by developer: 0
Analyzed by developer: 0 |
-------------------------------------+-------------------------------------
Comment (by pdr0):
It's been "fixed" a long time ago with the proper flags. It's just not
well documented
The popular way to do it these days is zscale . Format comes last in the
filter chain, the earlier flags get passed to it
[code]
ffmpeg -i colortest_hd.bmp -vf zscale=matrix=709,format=yuv420p -c:v
libx264 -crf 18 -x264opts colormatrix=bt709 zscale709.mp4
[/code]
It's a good idea to flag the colormatrix as 709
Acceptable rounding error for 8bit conversions should be +/-3 for
YUV<=>RGB conversions
If using swscale, you need -sws_flags full_chroma_int+accurate_rnd to
reduce the rounding errors (accurate_rnd is the important one)
[code]
ffmpeg -i colortest_hd.bmp -vf
scale=out_color_matrix=bt709:flags=full_chroma_int+accurate_rnd,format=yuv420p
-c:v libx264 -crf 18 -x264opts colormatrix=bt709
swscale709accurate_rnd.mp4
[/code]
[/code]
ffmpeg -i colortest_hd.bmp -vf scale=out_color_matrix=bt709,format=yuv420p
-c:v libx264 -crf 18 -x264opts colormatrix=bt709 swscale709.mp4
[/code]
As you see, "white" is 255,255,255 with the sws accurate_rnd flag, but
discolored (252,255, 252) without.
--
Ticket URL: <https://trac.ffmpeg.org/ticket/8056#comment:6>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker
More information about the FFmpeg-trac
mailing list