I have an input image `png rgba, color #bcbc00 rgb 188,188,0`.
I'd like to convert it to `yuv mp4` and keep the color unchanged. I tried this command:
It produces an output video file with color `rgb 190,177,0`.Code:ffmpeg -i inp.png out.mp4
What should I do to preserve the color?
+ Reply to Thread
Results 1 to 8 of 8
-
-
You need 10bit YUV to preserve exact 8bit RGB colors . For 8bit YUV it's normal to have the rounding errors for the round trip back to RGB
You need full color (no subsampling) 4:4:4, to get perfect colors in all situation (e.g. you have more than 1 color, real photos).
The playback device/software/player must do a proper YUV=>RGB conversion back for display. Many software /hardware/pipelines do not have proper 10bit support, and many do not support 4:4:4
For 10bit consumer video, HEVC (e.g. x265) is usually a better choice than AVC (e.g. x264), it has more hardware support, but not necessarily for 4:4:4 profiles, usually only 4:2:0
If "close" is enough, 8bit 4:2:0 is more widely supported ; then make sure you use 709 for HD, 601 for SD
Code:ffmpeg -r 24 -loop 1 -i 188,188,0.png -vf scale=out_color_matrix=bt709,format=yuv444p10le -c:v libx264 -crf 18 -x264opts colormatrix=bt709 -an -t 00:00:10 swscale10bit444.mp4
-
Thank you!
I'd like to use hardware encoding and 8 bit output, sorry for not mentioned that. Is it OK to use this command instead? Or I need to change anything to get better quality?
Code:ffmpeg -i inp.png -pix_fmt yuv444p -vf scale=out_color_matrix=bt709 -c:v hevc_nvenc -preset lossless -profile rext out.mp4
Last edited by qo4on; 28th Dec 2020 at 09:51.
-
That's life with 8 bit YUV. You need 10 bit YUV to retain all 16M RGB colors.
https://forum.videohelp.com/threads/399846-Not-able-to-change-any-advanced-video-playb...be#post2603522Last edited by jagabo; 28th Dec 2020 at 09:57.
-
Just to clarify, do I need to add
Code:-x264opts colormatrix=bt709
Code:ffmpeg -i inp.png -pix_fmt yuv444p -vf scale=out_color_matrix=bt709 -c:v hevc_nvenc -preset lossless -profile rext out.mp4
-
x264opts are specific to x264 encoding. I don't know if the NVENC encoder has an equivalent. To be clear, the option is just flagging the colormatrix. Players may or may not pay attention to the flag. Some will use rec.601 for SD, rec.709 for HD. Some will always use one or the other. Unfortunately, it's the wild west out there.
Similar Threads
-
Virtualdub is skipping frames when converting to png sequence
By vegas13 in forum Video ConversionReplies: 6Last Post: 18th Sep 2020, 02:05 -
Preserve 29.97 frame rate?
By colonel0812 in forum DVD RippingReplies: 19Last Post: 12th Aug 2020, 14:35 -
Converting TTML2+PNG Subtitles to BDN(XML+PNG)
By MounaLafi in forum SubtitleReplies: 6Last Post: 25th Jan 2019, 06:48 -
Convert PNG into MP4!!
By Cauptain in forum Video ConversionReplies: 5Last Post: 22nd Aug 2018, 08:26 -
converting vbr mp4 file to cbr mp4
By brandcc in forum Video ConversionReplies: 13Last Post: 19th Jun 2017, 08:43