Im trying to scale video down. No matter what I do the colors are always washed up as a result.
Code I run for it
ffmpeg -i input.mkv -vf scale=1028:-1 output.mkv
Original file codec info
New file codec info
ideally I would want to convert the video to h264 and scale down. I tried googling for x hours, tried a lot of random attemps, and in the end I tracked it down to scale filter. I have no idea how or why the filter messes up the colors.
I also tried some overkill commands(below) I found on the internet, and it is able to convert to h264 perfectly, but once I try to add scaling to that command it will also produce washed up colors like example above.
ffmpeg -i "input" -c:v libx265 -preset fast -crf 21 -x265-params keyint=60:bframes=3:vbv-bufsize=75000:vbv-maxrate=75000:hdr-opt=1:repeat-headers=1:colorprim=bt2020:transfer=smpte-st-2084:colormatrix=bt2020nc:master-display="G(13250,34500)B(7500,3000)R(34000,16000)WP(15635,16450)L(10000000,500)" -c:a aac -vf colorspace=bt2020,transfer=smpte2084,scale=1280:-1 "small_output"
ffmpeg -hide_banner -pix_fmtsand check if you have
yuv420p10lein the list. If the source video is encoded using a 10-bit colorspace, this may be an issue with your build of FFmpeg being restricted to 8-bit colorspaces. Adding
-pix_fmt +before your
-vffilters will also reveal if this is the case, or possibly fix the issue. This answer may also shed more light on the issue.
yuv420p10le 3 15. This means the ffmpeg is compiled with 10bit colorspaces in mind, right? Adding
yuv444p10le) produces the same output. Trough the link you provided I tried to add
-profile:v main444-10, and get
Error setting profile main444-10.
Possible profiles: baseline main high high10 high422 high444
-pix_fmt +keep the same color/pix format? Because even with
-pix_fmt +the produced file says "Decoded format: Planar 4:2:0 YUV 10-bit LE", while the original is prim:ITU-R BT.2020, trans:SMPTE ST2084 (PQ), space: ITU-R BT.2020 Range ??
-pix_fmtsreturns 10-bit options, then yes, you've got 10-bit FFmpeg. The
main444-10profile is no longer used, the
high444profile includes 10-bit support now. You are correct in that
-pix_fmt +maintains the input color format, so that eliminates that variable. The prim/trans/space parameters you see are related to but not the same as color format, but could definitely be the problem. Try using the
-color_primariesflags to set your output to the same values that the input is using. Also try setting the
-color_rangeflag to either
colorspacefilter, as described here. You should try adding the filter both before and after the scaling filter. You should be able to convert the colorspace to something like bt709 or the same values as the input and immediately see an improvement if this is indeed the problem. Again, combine this with the
-color_rangeflag (after your
-iflag so that it applies to output) in your testing.