zoft.link Website Logo

  • Home
  • Categories
  • Search

Applying Gaussian Blur Effect Using FFmpeg on Terminal

This is an article about applying a Gaussian blur effect to video files utilizing the command-line tool ffmpeg. In this article, you will find detailed instructions and examples that walk through how to use various parameters within ffmpeg for creating visually appealing and stylistic effects in your videos. If you’re looking to enhance or modify video footage programmatically on Linux or similar operating systems, mastering the art of applying Gaussian blur using ffmpeg is an essential skill.

Introduction to Gaussian Blur

Gaussian blur is a method used in image processing to soften images by reducing pixel noise and detail while preserving edges better than simpler blurring algorithms. This technique works by taking each pixel and blending it with its neighbors according to the shape of a Gaussian curve, which is why areas near the center have more weight than those far away.

Applying this effect to videos can be particularly useful for achieving a dreamy or vintage look, reducing motion artifacts, and even enhancing privacy by obscuring sensitive details. This article focuses on how you can apply such an effect to video content using ffmpeg.

What is FFmpeg

FFmpeg is a free software project that produces libraries and programs for handling multimedia data. It includes the highly popular ffmpeg command-line tool for manipulating audio/video files and streams. With its extensive range of features, including video format conversion, filtering, and processing tasks like applying effects (such as Gaussian blur), ffmpeg has become indispensable in the media industry.

Installing FFmpeg

Before diving into the examples, ensure you have ffmpeg installed on your system. On most Linux distributions, you can install it via the package manager:

sudo apt-get install ffmpeg # For Debian-based systems (Ubuntu) sudo yum install ffmpeg # For RedHat-based systems (CentOS)

On macOS, you might use Homebrew to get ffmpeg:

brew install ffmpeg

Windows users can download pre-compiled binaries from the official FFmpeg website.

Applying Gaussian Blur

The primary method for applying a Gaussian blur effect in ffmpeg involves using the boxblur, gaussianblur, or unsharp filter. While these filters offer some customization, it’s important to note that ffmpeg does not have an exact “Gaussian” implementation but rather approximations.

Basic Example

Let’s start with a basic example of applying a Gaussian blur effect:

ffmpeg -i input.mp4 -vf gaussianblur=30:25 output_blurred.mp4

Here, the -i flag specifies your input video file (input.mp4), and the -vf (video filter) option applies a simple blur effect. The parameters gaussianblur=30:25 define the degree of blurring horizontally (30) and vertically (25). You can adjust these values to match your needs.

Customizing the Effect

For more control, you might want to specify different horizontal and vertical blur strengths:

ffmpeg -i input.mp4 -vf gaussianblur=10:20 output_blurred.mp4

This example blurs horizontally by 10 and vertically by 20. Adjusting these values can help achieve more precise visual effects.

Combining with Other Filters

Sometimes, combining a Gaussian blur effect with other filters can produce interesting results:

ffmpeg -i input.mp4 -vf "crop=in_w:in_h-50,scale=-1:720,gaussianblur=30:25" output_cropped_blurred.mp4

In this example, we first crop the video to remove 50 pixels from its bottom edge (crop), resize it to a height of 720 pixels while maintaining aspect ratio (scale), and then apply a Gaussian blur effect. This combination can be useful for focusing on specific parts of your footage.

Real-World Example

Consider applying this technique to reduce motion artifacts or soften the appearance in a video:

ffmpeg -i shaky_footage.mp4 -vf "gaussianblur=15:15" smooth_footage.mp4

This command takes shaky_footage.mp4 and applies an equal amount of blur in both directions, resulting in smoother motion. This can be particularly useful for videos recorded with handheld cameras or drones.

Conclusion

In this article, you have learned how to apply a Gaussian blur effect to video files using the versatile ffmpeg. Whether you’re aiming to enhance visuals or obscure details temporarily, mastering these techniques opens up new possibilities in video editing and processing. Experimenting with different parameters can lead to unique and creative outcomes that cater to various aesthetic preferences.

By following the examples provided here, you should now be well-equipped to start applying Gaussian blur effects on your own videos using ffmpeg commands from the terminal.

Last Modified: 23/02/2020 - 08:23:47