11

I need to blur some uploaded videos and encoded them. Infact by blur, it means pixellate them so "big squares" appear and blur it.

Any idea on how I can do that ? (ffmpeg would be great, by any command line windows tool should be ok)

Thanks.

1
  • Yarek, did you figure out how to do it with a section rather than the full video? Commented Mar 21, 2015 at 1:21

3 Answers 3

10

If you don't want to install the frei0r plugin for this, there's an alternative way.

dimensions=$(ffprobe -v error -select_streams v:0 -show_entries stream=width,height -of "csv=p=0:s=\:" input)

ffmpeg -i input -filter_complex \
"[0:v] scale='iw/15:-1', scale='$dimensions:flags=neighbor'" output

This scales down the input size (in this example, by 15) and then scales it back up to the original dimensions. The flags=neighbor tells ffmpeg to use the nearest neighbor rescaling algorithm which results in the pixelated effect. You can change the block size by changing the number 15.

The first line is needed to find out the input's original dimensions and scale back directly to it, otherwise the scaling down and scaling up might result in rounding errors that slightly alter the size of the output.

Sign up to request clarification or add additional context in comments.

6 Comments

You can eliminate head and sed by using "csv=p=0:s=\:".
@llogan thanks, good point. Edited, but I'll leave the head in for when the input has a video and audio stream, because you get a blank line for the dimensions of the audio stream.
The blank line can be avoided with the addition of -select_streams v:0.
One more pro of this solution is that it works with High output profile, whereas frei0r can only output High Progressive. This is important if you want to merge videos without re-encoding, as profile must be identical.
Why you calculate the dimentions using ffprobe? You already have it in "iw". You could simply: ffmpeg -i input -filter_complex "[0:v] scale='iw/15:-1', scale='iw*15:-1:flags=neighbor'" output
|
9

FFmpeg can support the frei0r filters which includes pixeliz0r

original pixeliz0r

Example:

ffmpeg -i input -vf "frei0r=filter_name=pixeliz0r:filter_params=0.02|0.02" output

The two pixeliz0r filter_params parameters are:

  • BlockSizeX: horizontal size of one "pixel"
  • BlockSizeY: vertical size of one "pixel"

Larger values will create larger blocks.

Where to get ffmpeg with frei0r support

  • Windows users can get the "full build" from gyan.dev.

  • Linux users can download or compile:

    • Download ffmpeg with frei0r support at johnvansickle.com.
    • Or compile ffmpeg by installing whatever package provides frei0r.h (such as frei0r-plugins-dev in Ubuntu or frei0r-devel in CentOS) and then add --enable-frei0r to your ffmpeg configure. See FFmpeg Wiki: Compile Guides.
  • macOS users can use Homebrew. You may need the --with-frei0r option.

More info

7 Comments

How do you do this just for an area of the shot (such as when you want to cover someone face?)
@Doug any chance you found the answer to your question?
I have ffmpeg but how can I enable frei0r with it. Consider me a novice to ffmpeg,
@FaisalMq What is your OS?
Ok got it. I downloaded ffmpeg that's already enabled for pixeliz0r from the link given on mplayer site: ffmpeg
|
1

The pixelize filter can do the trick:

ffmpeg -i input -vf pixelize=300 output

Replace 300 with your intensity (limited to 1024).

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.