How to Use CAS Filter in FFmpeg
This article provides a quick and practical guide on how to use the Contrast Adaptive Sharpen (CAS) filter in FFmpeg to improve video clarity. You will learn the purpose of the CAS filter, its syntax, its key parameters, and how to apply it to your video processing workflows with concrete command-line examples.
What is the CAS Filter?
The Contrast Adaptive Sharpen (CAS) filter is an implementation of
AMD’s FidelityFX CAS technology. Unlike traditional sharpening filters
(like unsharp) that apply uniform sharpening across the
entire frame, CAS adjusts the sharpening intensity based on local
contrast. This results in cleaner edges and enhanced details without
introducing distracting halos or ringing artifacts.
Basic Syntax
The basic syntax for applying the CAS filter in FFmpeg is:
ffmpeg -i input.mp4 -vf "cas=strength=value" output.mp4Key Parameters
The cas filter has two primary options:
strength(oramount): Controls the sharpening intensity.- Range:
0.0(no sharpening) to1.0(maximum sharpening). - Default:
0.0
- Range:
planes: Specifies which color planes to filter.- Range:
0to15(flag-based). - Default:
7(which processes all planes: luma and chroma).
- Range:
Practical Examples
1. Medium Sharpening
To apply a moderate amount of sharpening to your video, set the
strength to 0.5. This is generally the sweet spot for
enhancing details without making the video look artificial.
ffmpeg -i input.mp4 -vf "cas=strength=0.5" output.mp42. Maximum Sharpening
If you have a very blurry source video and want to apply the maximum
contrast-adaptive sharpening effect, set the strength to
1.0.
ffmpeg -i input.mp4 -vf "cas=strength=1.0" output.mp43. Sharpening Luma Only (Y Plane)
If you want to sharpen only the brightness (luma) channel to avoid
color noise amplification, you can target specific planes. Setting
planes=1 restricts the CAS filter to the first plane
(Y).
ffmpeg -i input.mp4 -vf "cas=strength=0.6:planes=1" output.mp44. Combining CAS with Scaling
It is common to use the CAS filter after upscaling a video to restore lost sharpness. In this example, the video is upscaled to 1080p using the bicubic algorithm and then sharpened.
ffmpeg -i input.mp4 -vf "scale=1920:1080:flags=bicubic,cas=strength=0.4" output.mp4