[FFmpeg-user] Converting BT2020 HVEC Videos to H.264 without Color Washout

Craig L. ffmpeg at trafficality.com
Fri Mar 26 01:55:27 EET 2021


Sorry. I don't think I responded to this correctly before.


I think I tried exactly that based upon this stackoverflow question:

https://stackoverflow.com/questions/64981984/ffmpeg-transcode-uhd-h265-to-sdr-h264-without-color-loss 


The example in that post uses this command:

|ffmpeg -i 4K.ts -vf 
zscale=t=linear:npl=100,format=gbrpf32le,zscale=p=bt709,tonemap=tonemap=hable:desat=0,zscale=t=bt709:m=bt709:r=tv,format=yuv420p 
-c:v h264 -crf 19 -preset ultrafast output.mp4 |

Which I thought might be my solution but when I tried it, it ended up 
making the video too red.

Does that look like the route I need to take?

- Craig

On 3/25/21 4:09 PM, Pavel Koshevoy wrote:
> On Thu, Mar 25, 2021 at 9:27 AM Craig L. <ffmpeg at trafficality.com> wrote:
>
>> I recently started finding certain videos were washing out upon H.264
>> conversion.
>>
>>
>> After doing some research I found that if I added -color_primaries
>> bt2020 to the command, the color would come out correctly, but ONLY if
>> the video was played in Quicktime.  When played in Chrome, it would look
>> washed out.
>>
>> Here is a link to a screengrab showing the video in quicktime on the
>> left and in Chrome on the right.  Same video.
>>
>>
>> *https://snipboard.io/N8nYv0.jpg* <https://snipboard.io/N8nYv0.jpg>
>>
>>
>>
>>
>> After much research I can't figure out how to handle this?
>>
>> What is the correct way to convert these videos that I suppose are 10
>> bit HDR  into H.264 so that they will play correctly in Chrome, etc.
>>
>>
>>
>> This is my current command:
>>
>> /usr/local/bin/ffmpeg  -i "156237-Video2.mov"   -filter_complex
>> "scale=480:270"  -color_trc smpte2084 -color_primaries bt2020 -c:v
>> libx264 -profile:v high -pix_fmt yuv420p -level 5.1 -preset ultrafast
>> -movflags faststart       -vsync 2  -c:a aac -b:a 128k     -y
>> 156237-Video2.mov-16-9-1616621202.mp4
>>
>>
>>
>>
>>
> For best possible player compatibility you really need to convert from
> HDR10 to SDR (bt709).
>
> To do that you need to use either colorspace or zscale ffmpeg filter.  The
> colorspace filter didn't support HLG the last time I checked, but that
> wouldn't matter if your source is HDR10, not HLG.
> Since you'd be converting from high dynamic range to standard dynamic range
> you would also need to use the tonemap filter.
>
> There is probably a LUT file somewhere that implements HDR10 -> BT709 color
> space conversion and tone mapping in one step, skipping zscale/tonemap.  If
> you had such LUT you could use it with lut3d filter.
>
> Pavel.
> _______________________________________________
> ffmpeg-user mailing list
> ffmpeg-user at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-user
>
> To unsubscribe, visit link above, or email
> ffmpeg-user-request at ffmpeg.org with subject "unsubscribe".


More information about the ffmpeg-user mailing list