VideoHelp Forum




+ Reply to Thread
Results 1 to 8 of 8
  1. 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:

    Code:
    ffmpeg -i inp.png out.mp4
    It produces an output video file with color `rgb 190,177,0`.

    What should I do to preserve the color?
    Quote Quote  
  2. edit double post
    Quote Quote  
  3. Originally Posted by qo4on View Post
    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:

    Code:
    ffmpeg -i inp.png out.mp4
    It produces an output video file with color `rgb 190,177,0`.

    What should I do to preserve the color?


    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
    Image Attached Thumbnails Click image for larger version

Name:	188,188,0.png
Views:	56
Size:	4.2 KB
ID:	56492  

    Image Attached Files
    Quote Quote  
  4. Originally Posted by poisondeathray View Post
    HEVC (e.g. x265) is usually a better choice than AVC (e.g. x264)
    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
    The colors are not exactly the same, they are in a range -2...+2 rgb values.
    Last edited by qo4on; 28th Dec 2020 at 09:51.
    Quote Quote  
  5. Originally Posted by qo4on View Post
    Code:
    ffmpeg -i inp.png -pix_fmt yuv444p -vf scale=out_color_matrix=bt709 -c:v hevc_nvenc -preset lossless -profile rext out.mp4
    The colors are not exactly the same, they are in a range -2...+2 rgb values.
    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#post2603522
    Last edited by jagabo; 28th Dec 2020 at 09:57.
    Quote Quote  
  6. Just to clarify, do I need to add

    Code:
    -x264opts colormatrix=bt709
    after hevc_nvenc in this line:

    Code:
    ffmpeg -i inp.png -pix_fmt yuv444p -vf scale=out_color_matrix=bt709 -c:v hevc_nvenc -preset lossless -profile rext out.mp4
    Or it's not necessary and I won't get quality better than this command produces?
    Quote Quote  
  7. 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.
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!