Alphamerge filter only works on first frame

0

I am trying to implement blur filter over specific non rectangle object, I have mask and sample video but the issue is that alphamerge result of first frame of video is applied to the whole video(Like you overlayed a static image over the whole length of video) I used the following command

ffmpeg -y -i sample_video.mp4 -i masked_image.png -filter_complex 
"[0:v][1:v]alphamerge,boxblur=16[alf];[0:v][alf]overlay[v]" -map [v] -map 0:a -c:a copy -preset ultrafast test.mp4

sample_video.mp4 masked_image.png

UPDATE: Your solution is working quite well but now blur intensity value is not effecting blur intensity

Mask Image

Sample Image

Result with boxblur=10

Result with boxblur=30

Zain Ali

Posted 2018-07-22T17:11:13.750

Reputation: 57

Answers

1

Your mask is a single image so it won't track the subject, but I assume your issue is that the overlay pixels are static. You'll need to loop the mask since alphamerge terminates with the shortest input, and the overlay will repeat the last frame of the secondary input.

ffmpeg -y -i sample_video.mp4 -loop 1 -i masked_image.png ...

Gyan

Posted 2018-07-22T17:11:13.750

Reputation: 21 016

I have observed for above case(using mask image to apply blur effect) that as you increase boxblur value then blur effect decrease, like from 1-16 it keeps on increasing and after that it start decreasing(no matter how much high value you choose), do you have any idea that why this could happen or any better suggestion to use masks to blur? – Zain Ali – 2018-08-02T01:39:54.083

Can you post example pics? – Gyan – 2018-08-02T05:32:24.600

I have updated my question – Zain Ali – 2018-08-02T06:23:11.313

Change boxblur=16 to boxblur=16:ap=0. We don't want to blur the alpha plane. – Gyan – 2018-08-02T06:29:27.953