[FFmpeg-user] ffmpeg makes some sources darker

Jim Worrall coniophora at gmail.com
Mon Jan 4 23:57:51 CET 2016


> On 2016 Jan 4, at 3:29 PM, Andy Furniss <adf.lists at gmail.com> wrote:
> I think it's because the master is flagged as rec709 but the yuv and I
> guess hevc aren’t.

Although my opinion is not worth much, I suspect you are onto it here.
> 
> Some players (not mplayer) would assume 709 for >= 720p so you wouldn't
> notice with them.
> 
> It seems ffmpeg swscale/png honors the 709 for the master.
> 
> testing -
> 
> ffmpeg -i in.mkv -vframes 1  frame1-master.png
> 
> ffmpeg -i in.mkv -vframes 1  -vcodec rawvideo -f rawvideo frame1-master.yuv
> 
> ffmpeg -f rawvideo -pix_fmt yuv420p -s 1920x1080 -i frame1-master.yuv frame1-yuv.png
> 
> and frame1-yuv.png is darker than frame1-master.png
> 
> do
> 
> ffmpeg -f rawvideo -pix_fmt yuv420p -s 1920x1080 -i frame1-master.yuv -vf scale=in_color_matrix=bt709  frame1-yuv-709.png
> 
> and frame1-yuv-709.png visually (but not md5sum) matches frame1-master.png

I’m not sure if you’ve already done this, or you’re predicting.  
In any case, you’re not going to like the result.   
frame1-yuv-709.png is actually intermediate in darkness to the other two,
but closer to frame1-yuv.png.

However, I should add that the x265 guy, Ma0, went ahead and transcoded my minute of video
with what I think would be this, and got no difference in darkness:

ffmpeg -i min_source.mkv -f yuv4mpegpipe - | x265 --y4m - --preset placebo --subme 7 --merange 121 --deblock -1 --rdoq-level 1 --colormatrix bt709 --bitrate 3000 --pass 1 -o slow.hevc && \
ffmpeg -i min_source.mkv -f yuv4mpegpipe - | x265 --y4m - --preset placebo --subme 7 --merange 121 --deblock -1 --rdoq-level 1 --colormatrix bt709 --bitrate 3000 --pass 2 -o slow.hevc

Aside from the insane settings (my computer is doing this at 0.1 fps!!), note the --colormatrix bt709 - 
I’m guessing that was the key.  Not sure why it comes out intermediate in your test - probably
because it is already darkened during the conversion to yuv, but not in the above?

I will test this further when my processor allows.  In the meantime, thanks
very much to Andy and Carl for taking the time to look at this.


More information about the ffmpeg-user mailing list