Apply 3D LUT to Video with FFmpeg
Applying a custom 3D Color Lookup Table (LUT) to a video is a highly
efficient way to color grade or color-correct your footage. This article
provides a clear, step-by-step guide on how to use FFmpeg to apply
.cube or .3dl LUT files directly to your
videos via the command line, ensuring high-quality color transformation
without the need for heavy video editing software.
To apply a 3D LUT to a video in FFmpeg, you need to use the
lut3d video filter. This filter reads the color
transformation coordinates from your LUT file and maps them to the video
frames.
The Basic Command
Open your terminal or command prompt and run the following command:
ffmpeg -i input.mp4 -vf "lut3d=preset.cube" -c:v libx264 -pix_fmt yuv420p -c:a copy output.mp4Command Breakdown
-i input.mp4: Specifies the path to your source video file.-vf "lut3d=preset.cube": This is the video filter flag. Thelut3dfilter is called, and the path to your 3D LUT file (e.g.,preset.cubeorpreset.3dl) is passed as the argument.-c:v libx264: Re-encodes the video using the H.264 codec. Re-encoding is required when applying visual filters.-pix_fmt yuv420p: Ensures maximum compatibility across media players by setting the pixel format to YUV 4:2:0.-c:a copy: Copies the audio stream directly from the source without re-encoding, saving time and preserving original audio quality.output.mp4: The name and format of your output file.
Advanced Options: Choosing Interpolation
3D LUTs rely on interpolation to calculate colors that fall between
the defined points in the lookup table. FFmpeg allows you to specify the
interpolation method using the interp option.
The command looks like this:
ffmpeg -i input.mp4 -vf "lut3d=file=preset.cube:interp=tetrahedral" -c:v libx264 -pix_fmt yuv420p -c:a copy output.mp4Available interpolation methods include: *
nearest: Fastest processing, but lowest
quality (can introduce color banding). *
trilinear: Good balance between speed and
quality. * tetrahedral: Best quality
(default). It provides the smoothest color transitions and minimizes
banding artifacts.