0

I'd like to blurr 3 areas of a video. This is the code:

$ ffmpeg -i ACCT.mp4 -an \
-filter_complex \
"[0:v]crop=850:100:140:175,boxblur=10[blur1]; \
 [0:v]crop=125:285:815:395,boxblur=10[blur2]; \
 [0:v]crop=80:30:730:640,boxblur=10[blur3]; \
 [0:v][blur1]overlay=140:175:enable='between(t,0,26)'[ovr1]; \
 [ovr1][blur2]overlay=815:395:enable='between(t,0,2)'[ovr2]; \
 [ovr2][blur3]overlay=730:640:enable='between(t,7,29)'" \
blurredVideo.mp4

Unfortunately, ffmpeg reports the following error:

[Parsed_boxblur_5 @ 0x7fcfbb805b40] Invalid chroma_param radius value 10, must be >= 0 and <= 7
[Parsed_boxblur_5 @ 0x7fcfbb805b40] Failed to evaluate filter params: -22.
[Parsed_boxblur_5 @ 0x7fcfbb805b40] Failed to configure input pad on Parsed_boxblur_5
Error reinitializing filters!
Failed to inject frame into filter network: Invalid argument
Error while processing the decoded data for stream #0:0
Conversion failed!

The code is based on a valid answer to another post.

2 Answers 2

1

Problem

boxblur has size limitations. See the boxblur filter documentation for all of the details.

Solutions

Use a different blur filter

Use as avgblur, dblur, gblur, sab, smartblur, unsharp, yaepblur. See FFmpeg Filters.

$ ffmpeg -i ACCT.mp4 -an \
-filter_complex \
"[0:v]crop=850:100:140:175,avgblur=10[blur1]; \
 [0:v]crop=125:285:815:395,avgblur=10[blur2]; \
 [0:v]crop=80:30:730:640,avgblur=10[blur3]; \
 [0:v][blur1]overlay=140:175:enable='between(t,0,26)'[ovr1]; \
 [ovr1][blur2]overlay=815:395:enable='between(t,0,2)'[ovr2]; \
 [ovr2][blur3]overlay=730:640:enable='between(t,7,29)'" \
blurredVideo.mp4

Or use boxblur before crop

This will be slower than your original command.

$ ffmpeg -i ACCT.mp4 -an \
-filter_complex \
"[0:v]boxblur=10,crop=850:100:140:175[blur1]; \
 [0:v]boxblur=10,crop=125:285:815:395[blur2]; \
 [0:v]boxblur=10,crop=80:30:730:640[blur3]; \
 [0:v][blur1]overlay=140:175:enable='between(t,0,26)'[ovr1]; \
 [ovr1][blur2]overlay=815:395:enable='between(t,0,2)'[ovr2]; \
 [ovr2][blur3]overlay=730:640:enable='between(t,7,29)'" \
blurredVideo.mp4

Or add the format filter

$ ffmpeg -i ACCT.mp4 -an \
-filter_complex \
"[0:v]crop=850:100:140:175,format=yuv444p,boxblur=10[blur1]; \
 [0:v]crop=125:285:815:395,format=yuv444p,boxblur=10[blur2]; \
 [0:v]crop=80:30:730:640,format=yuv444p,boxblur=10[blur3]; \
 [0:v][blur1]overlay=140:175:enable='between(t,0,26)':format=auto[ovr1]; \
 [ovr1][blur2]overlay=815:395:enable='between(t,0,2)':format=auto[ovr2]; \
 [ovr2][blur3]overlay=730:640:enable='between(t,7,29)':format=auto,format=yuv420p" \
blurredVideo.mp4

Also see

0

Video typically has three components that describe a pixel: one luma and two chroma components. In the most common scheme (yuv420), chroma values are only set for half the pixels along the width and height, so the chroma planes are quarter-sized (W/2 x H/2) compared to the luma plane.

In the boxblur filter, the radius for blurring the chroma plane defaults to the radius for the luma plane when not expressly specified. The filter will draw a circle of the computed radius around each pixel to calculate its output value, and the entire circle needs to be inside the video frame, so the blur radius for a plane needs to be at most half of the smaller side.

In [0:v]crop=80:30:730:640,boxblur=10[blur3], the cropped video has height 30 so the chroma plane height is 15 and the chroma radius has to be 7 or less.

You can use an expression to remain within technical limits like this,

[0:v]crop=80:30:730:640,boxblur=10:cr=min(10\,min(cw\,ch)/2)[blur3]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.