How to Use the CAS Filter in FFmpeg
This article provides a concise guide on using the Contrast Adaptive
Sharpening (cas) filter in FFmpeg. You will learn what the
filter does, its available parameters, and practical command-line
examples ranging from basic sharpening to combining it with video
upscaling.
What is the CAS Filter?
Originally developed by AMD as part of FidelityFX, Contrast Adaptive
Sharpening (CAS) enhances high-frequency details while minimizing
ringing artifacts and noise amplification. In FFmpeg, the
cas filter is an efficient, high-performance tool ideal for
cleaning up soft footage or post-processing upscaled video.
Filter Syntax and Options
The cas filter accepts two primary parameters:
strength: Controls the sharpening intensity. The value ranges from0.0(minimum/no effect) to1.0(maximum sharpening). The default is0.0.planes: Specifies which color planes to filter. The value is a bitmask (1 for the first plane/luma, 2 for the second, 4 for the third, etc.). The default is7, which filters the first three planes (Y, U, and V in YUV, or R, G, and B in RGB).
Basic Command Example
To apply moderate sharpening to a video file, specify the filter
using the -vf flag:
ffmpeg -i input.mp4 -vf "cas=strength=0.5" -c:v libx264 -crf 18 -c:a copy output.mp4In this command:
cas=strength=0.5sets the sharpening level to a balanced midpoint.-c:v libx264 -crf 18re-encodes the video with high visual quality.-c:a copycopies the audio stream without re-encoding.
Sharpening Luma Only
Sharpening chroma channels can sometimes introduce color noise or
artifacts. To apply CAS exclusively to the luma (brightness) channel,
set planes=1:
ffmpeg -i input.mp4 -vf "cas=strength=0.6:planes=1" -c:v libx264 -crf 18 -c:a copy output.mp4Combining CAS with Upscaling
A common use case for CAS is restoring edge clarity after upscaling video with a standard interpolation filter like Lanczos:
ffmpeg -i input.mp4 -vf "scale=1920:1080:flags=lanczos,cas=strength=0.4" -c:v libx264 -crf 18 -c:a copy output.mp4Recommended Strength Values
- Subtle (0.2 – 0.4): Best for natural footage or mild clean-up after minor scaling.
- Moderate (0.5 – 0.7): Ideal for slightly blurry sources or significant upscaling steps.
- Aggressive (0.8 – 1.0): Suitable for stylized high-contrast looks, though it may accentuate compression artifacts in low-bitrate sources.