FFmpeg Bilinear vs Bicubic vs Lanczos Scaling
When resizing video in FFmpeg, choosing the right scaling algorithm is crucial for balancing output quality and processing speed. This article compares three of the most common FFmpeg scaling algorithms—bilinear, bicubic, and lanczos—detailing how they work, their performance trade-offs, and how to choose the best option for your video encoding workflow.
Bilinear Scaling
The bilinear algorithm calculates the color value of a new pixel by taking the weighted average of the four surrounding pixels (a 2x2 grid) from the original image.
- Speed: Extremely fast. It requires minimal computational power.
- Quality: Low to moderate. Because it only analyzes a small area, the scaled output often looks soft or blurry, particularly when upscaling.
- Best Use Case: Real-time streaming, low-power devices, or quick draft renders where encoding speed is prioritized over visual sharpness.
- FFmpeg Command Example:
ffmpeg -i input.mp4 -vf "scale=1280:720:flags=bilinear" output.mp4
Bicubic Scaling
The bicubic algorithm is a step up from bilinear. It analyzes a 16-pixel neighborhood (a 4x4 grid) and uses cubic spline interpolation to calculate the new pixels. This results in smoother gradations and sharper edges.
- Speed: Moderate. It requires more CPU cycles than bilinear but is still highly optimized and fast on modern hardware.
- Quality: Good. It offers a great balance of sharpness and smoothness without introducing significant visual artifacts.
- Best Use Case: General-purpose video encoding, standard downscaling, and everyday use where you need a balance of speed and quality.
- FFmpeg Command Example:
ffmpeg -i input.mp4 -vf "scale=1280:720:flags=bicubic" output.mp4
Lanczos Scaling
Named after Cornelius Lanczos, this algorithm uses a windowed sinc function to interpolate pixels, typically analyzing an 8x8 grid of surrounding pixels (Lanczos3).
- Speed: Slow. It is the most computationally expensive of the three algorithms.
- Quality: High. It preserves fine details, text, and sharp edges exceptionally well, making it the superior choice for high-quality upscaling.
- Drawbacks: Because of its high sharpness, it can sometimes introduce “ringing” artifacts (faint halo effects or ghosting around high-contrast edges).
- Best Use Case: High-quality upscaling, archiving, and encoding videos with lots of text, fine details, or graphics.
- FFmpeg Command Example:
ffmpeg -i input.mp4 -vf "scale=1920:1080:flags=lanczos" output.mp4
Summary Comparison
| Algorithm | Processing Speed | Visual Sharpness | Computational Resource | Primary Use Case |
|---|---|---|---|---|
| Bilinear | Fast | Soft / Blurry | Low | Live streaming & fast drafts |
| Bicubic | Medium | Balanced | Medium | General-purpose encoding |
| Lanczos | Slow | Very Sharp | High | High-quality upscaling & archiving |