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

Dennis Mungai dmngaie at gmail.com
Sat Oct 21 23:43:06 EEST 2023


On Sat, 21 Oct 2023 at 22:34, pehache <pehache.7 at gmail.com> wrote:

> Le 26/03/2021 à 00:55, Craig L. a écrit :
> > 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.
> >
>
> Same here, much too red output in the shadows.
>
> (I'm leaving the rest the rest of the discussion below, as it is an old
> one)
>
>
>
>
>
> >
> > 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.
>
>
Hey there,

Could you share a sample of the file with the mailing list?


More information about the ffmpeg-user mailing list