How to Use FFmpeg SPP Filter for High Quality Deblocking

This article explains how to use the Simple Post Processing (spp) filter in FFmpeg to reduce compression artifacts and apply high-quality deblocking to your videos. You will learn the basic syntax, key parameters such as quality and threshold, and practical command-line examples to significantly improve video visual quality.

The spp (Simple Post Processing) filter in FFmpeg is a highly effective tool for removing blockiness and ringing artifacts commonly found in highly compressed videos. It works by applying Discrete Cosine Transform (DCT) and Inverse Discrete Cosine Transform (IDCT) coefficients to smooth out blocks while preserving actual image details.

Basic Syntax

The basic syntax for applying the spp filter in an FFmpeg command is:

ffmpeg -i input.mp4 -vf "spp=quality:qp:mode" output.mp4

Parameter Breakdown

To get the best results, you can customize the three primary parameters of the spp filter:

  1. quality (1 to 6): Controls the quality of the post-processing.
    • 1 is the fastest but lowest quality.
    • 6 offers the highest quality deblocking but is highly CPU-intensive.
    • The default value is 3.
  2. qp (Quantization Parameter): Forces a specific quantization parameter.
    • By default, the filter automatically reads the QP from the input video stream.
    • If your input video does not contain QP metadata (or you want to override it), you can manually set a value (usually between 1 and 31 for MPEG videos).
  3. mode (0 or 1): Sets the thresholding mode.
    • 0: Hard thresholding (default).
    • 1: Soft thresholding (produces smoother results but may blur fine details).

Practical Command Examples

1. Basic Deblocking (Default Settings)

If you want a quick improvement using the default settings, run:

ffmpeg -i input.mp4 -vf "spp" output.mp4

2. Maximum Quality Deblocking

To apply the highest quality deblocking (quality level 6), which is ideal for archival purposes where encoding speed is not a priority:

ffmpeg -i input.mp4 -vf "spp=6" output.mp4

3. Custom QP with Soft Thresholding

If the source video has heavy compression artifacts and you want a smoother look, manually set a QP value of 20 and enable soft thresholding (1):

ffmpeg -i input.mp4 -vf "spp=5:20:1" output.mp4

Performance Consideration

Because the spp filter performs complex mathematical transformations on every frame, it is computationally expensive. If you experience slow encoding speeds, consider lowering the quality parameter to 3 or 4 to find the right balance between processing speed and visual quality.