Published in


Blur Out Videos with FFmpeg

Or how to utilize filter_complex

Harnessing filter_complex

FFmpeg’s filter_complex works in a similar fashion as Unix pipes. Take a input, modify, output, then rinse and repeat. A filtergraph contains one or more filterchains, each which contains a certain order of filters to be applied to the input source. Like Unix pipes, you can get pretty creative and generate some great results.

Splitting Outputs

First, we will split a single input into 2 outputs with scaled resolutions.

  • 0:v: Select the first input source’s videostream only
  • split=2: Split the stream into 2 and store them as 360pand 720p
  • [360p]scale=-2:360[360p] and [720p]scale=-2:720[720p] scales the input to 360px and 720pxheight respectively while preserving aspect ratio and sends the output back to the same input name. The -2 is to tell the scaler to scale to a even number as some formats do not support a odd number of pixels
  • -map "[360p]" 360p.mp4 and -map "[720p]" 720p.mp4 take each respective output and encodes it to a file.

The result will be 2 files with different resolutions. Keep in mind, all outputs created in the filtergraph must be connected to an output.


The next component is to generate a blurred video. There are many blurring algorithms available, but for this task, we will be using boxblur. This blur has 3 tunable settings each with radius (box radius to apply to the frame) and power (how many times to apply to the frame):

  • luma (luma_radius and luma_power): Brightness
  • chroma (chroma_radius and chroma_power): Color
  • alpha (alpha_radius and alpha_power): Transparency

Fading In

The last part we need is a fade. This is filter is fairly simple as it takes a start and a end with either a fade in or fade out. It supports both frames and time/duration. For our case, we will use the time/duration and skip calculating frames.

Fade in starting at 1s and complete the fade at 9s

Peanut Butter Jelly Time

Now that we have all the tools we need, let’s put this all together. The plan is to put each of the filters above to create a Blur Out effect. A Blur Out is essentially 2 videos (the original and a blurred version) overlayed on top of each other with the one of the videos fading.

For this example, we will choose the original video as the baseand the blurred video as the fade in.

  1. We will will need to split the input into 2, base and blurred, so we use the split filter
  2. Next we need to generate a blurred version using boxblur
  3. Taking the blurred input, we add a fade in start time 1s and duration 3s. The extra alpha=1 mentioned here is to allow the video to be transparent when faded out else the background color will be black
  4. The final step is to use overlay to put input sources on top of each other (like an onion). The alpha=1 from above would then allow the base to show through the blurred layer as it is being faded in.
Final results




Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store