litang0908
litang0908

Reputation: 103

How to apply a LUT filter with FFmpeg

I want to apply a LUT-filter on a video,so i decide to use FFMPEG,but i don't know how to apply this LUT image on the video ,

This is the LUT image: enter image description here

Can anyone tell me how to do this With FFMPEG ?

Thanks.

Upvotes: 1

Views: 7689

Answers (2)

SuslikV
SuslikV

Reputation: 11

This is OBS Studio compatible LUT file. It is different from the format that is supported by the FFmpeg lut3d filters.

Because it is different you need to apply similar color adjustments to the FFmpeg supported LUT and use it instead. The closes FFmpeg's alternative is haldclut filter (storage is different). To generate 8-bit FFmpeg compatible neutral Hald LUT use next command:

ffmpeg -f lavfi -i haldclutsrc=8 -frames:v 1 neutral_hald_clut_ffmpeg.png

Now you can add it to the OBS Studio as Image Source, set Base and Canvas to match the image size (512x512) and add Apply LUT filter (specify your LUT filepath). Since v26.x.x of the OBS Studio you can take Screenshot (Source) that will be saved in PNG format (don't forget to use RGB, Full Range in the Advanced Settings of the application to not get hit by chroma planes conversions if you are try to save it in other way).

The new modified hald clut can be used in FFmpeg like:

ffmpeg -i "source.mp4" -i "modified_hald_clut_ffmpeg.png" -filter_complex "haldclut" "result.mp4"

or (uses filter graph, OS paths escaped, Windows)

ffmpeg -i "C:\temp\source.mp4" -vf "movie=C\\:\\\\temp\\\\modified_hald_clut_ffmpeg.png [clut];[in][clut] haldclut" -c:v libx264 -crf 23 "C:\temp\result.mp4"

Maybe you will need to apply some additional FFmpeg filters too (to set output color space, range, matrix etc.)

Upvotes: 1

nico_lab
nico_lab

Reputation: 1194

You can use haldclut filter.

ffplay input -vf "movie=uUyIr.png, [in] haldclut"

Upvotes: 2

Related Questions