How to Use the spp Filter in FFmpeg
This article provides a straightforward guide on how to use the
spp (Simple Postprocessing) filter in FFmpeg to reduce
compression artifacts and improve video quality. You will learn the
basic syntax of the filter, understand its key parameters, and see
practical examples of how to apply it to your video processing
workflows.
Understanding the spp Filter
The spp (Simple Postprocessing) filter in FFmpeg is
designed to reduce compression artifacts, such as blockiness and
ringing, which often occur in highly compressed MPEG-like videos. It
works by applying a deblocking and deringing algorithm to the video
frames, making the output look smoother and more visually appealing.
Filter Syntax and Parameters
The basic syntax for applying the filter in an FFmpeg command is:
-vf "spp=parameter1=value1:parameter2=value2"The filter accepts several optional parameters to customize its behavior:
quality: Sets the quality of the postprocessing. The value ranges from1to6, where1is the fastest (lowest quality) and6is the slowest (highest quality). The default value is3.qp: Forces a constant quantization parameter (QP). If not specified, the filter uses the QP from the source video. Specifying a manual QP can be useful if the source QP table is unavailable or incorrect.mode: Sets the thresholding mode. It can be0(hard thresholding, default),1(soft thresholding), or2(comparison).use_bframe: Enables or disables the use of B-frames for postprocessing. This can be set to1(enable) or0(disable).
Practical Examples
Here are the most common ways to use the spp filter in
your FFmpeg commands.
1. Basic Usage (Default Settings)
To apply the filter with its default settings (quality level 3), use the following command:
ffmpeg -i input.mp4 -vf "spp" output.mp42. Enhancing Quality
To get the best possible artifact reduction, increase the quality
parameter to 6. Note that this will require more processing
power and take longer to encode:
ffmpeg -i input.mp4 -vf "spp=quality=6" output.mp43. Setting a Custom Quantization Parameter (QP)
If you are working with a video that has lost its original QP
metadata, you can manually force a QP value (for example,
20) to control the strength of the deblocking effect:
ffmpeg -i input.mp4 -vf "spp=quality=4:qp=20" output.mp44. Using Soft Thresholding
For a smoother, less aggressive filtering effect, you can change the
mode to soft thresholding (1):
ffmpeg -i input.mp4 -vf "spp=mode=1" output.mp4