Ffmpeg: how to add a pixel effect?

I need to blur some downloaded videos and encode them. Infact by blur, this means that they pixelate them so that "big squares" appear and blur it.

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

Thanks.

+5
source share
2 answers

FFmpeg can support frei0r filters, which include pixeliz0r. Example:

ffmpeg -i input -filter:v frei0r=pixeliz0r=0.02:0.02 output 

Two parameters:

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

Larger value, of course, will create larger blocks. Zeranoe FFmpeg builds includes frei0r, however I am not sure if it works, as some users run into problems with IRP #ffmpeg, although this was likely at least 6 months ago.

As for compiling Linux, it's simple. Ubuntu users can follow the HOWTO: install and use the latest FFmpeg and x264 and just add frei0r-plugins-dev as the quality and then add --enable-frei0r to the ffmpeg configuration.

originalpixeliz0r

+8
source

If you do not want to install the frei0r plugin for this, there is an alternative way.

 dimensions=$(ffprobe -v error -show_entries stream=width,height -of "csv=p=0:s=\:" input | head -1) ffmpeg -i input -filter_complex \ "[0:v] scale='iw/15:-1', scale='$dimensions:flags=neighbor'" output 

This reduces the size of the input file (in this example, by 15), and then reduces it to its original size. flags=neighbor tells ffmpeg to use the nearest neighbor scaling algorithm, which results in a pixelated effect. You can resize the block by changing the number 15.

The first line is necessary to determine the input source size and scale directly to it, otherwise reducing or increasing it can lead to rounding errors that will slightly change the size of the output.

+1
source

Source: https://habr.com/ru/post/1394142/


All Articles