[FFmpeg-user] overlaying a clut over a picture

Michael Koch astroelectronic at t-online.de
Mon Jan 14 11:32:16 EET 2019

Am 14.01.2019 um 09:48 schrieb Paul B Mahol:
> On 1/14/19, Michael Koch <astroelectronic at t-online.de> wrote:
>> Am 14.01.2019 um 08:40 schrieb Michael Koch:
>>> Am 14.01.2019 um 07:28 schrieb Michael Koch:
>>>> When I create a color-look-up-table with this command line, the
>>>> result is a 512x512 clut saved as 16-bit PNG. It works as expected
>>>> and I checked that the top left pixel is black (R=0, G=0, B=0) and
>>>> the bottom right pixel is white (R=65026, G=65026, B=65026).
>>>> c:\ffmpeg\ffmpeg -f lavfi -i haldclutsrc=8 -frames 1 -pix_fmt rgb48be
>>>> -y clut.png
>>>> In the next example I wanted to extract one frame from a video,
>>>> overlay the clut in the top left corner, and save it as 16-bit PNG. I
>>>> need 16-bit PNG because my video is 10-bit. At first glimpse the
>>>> result looks good, but a closer examination finds that the top left
>>>> pixel is not pure black, it's R=0, G=1285, B=0, and the bottom right
>>>> pixel of the clut (at coordinates 511,511) is not pure white, it's
>>>> R=65535, G=63736, B=65535. Why are the colors wrong?
>>>> c:\ffmpeg\ffmpeg -ss 5 -i P1000099.mov -f lavfi -i haldclutsrc=8
>>>> -filter_complex overlay -frames 1 -pix_fmt rgb48be -y
>>>> Image_with_CLUT.png
>>> I found a solution myself:  overlay=format=rgb
>> But the output of the overlay filter seems to be RGB24. Is it possible
>> to get RGB48 out of the overlay filter? Or is there any other filter for
>> overlaying two RGB48 images?
> Try maskedmerge filter with gbrp16 pixel format.

In the meantime a found this solution with the xstack filter:

c:\ffmpeg\ffmpeg -ss 5 -i P1000099.mov -f lavfi -i haldclutsrc=8 
-frames 1 -y Image_with_CLUT.png

It's not an overlay but a horizontal stack, but that doesn't care. It's 
only important that I have the clut and the picture combined in one 
16-bit picture, so that they can be processed simultaneously. By the way 
xstack is much better than hstack because it accepts pictures of 
different height. Problem solved!


More information about the ffmpeg-user mailing list