Apply depth of field blur effect from a grayscale video using ffmpeg

1

I have two videos.
One is a normal video, the other is a grayscale video.
Supposedly, merging the videos I can have a video with a depth of field blur effect.
I wish to know how I could do it using ffmpeg.
The videos are generated with WolfCamQL, is a program to capture Quake Live demos.

Carlos Martínez Medina

Posted 2017-12-30T00:18:21.240

Reputation: 11

Question was closed 2017-12-30T19:47:21.560

Do you mean that the greyscale video is a depth map for the other? Don't think this is possible with ffmpeg – you can only set one particular level of blur for a certain area. After Effects or Foundry Nuke would be an option. – slhck – 2017-12-30T11:04:08.277

Yes! Exactly! I know that's possible to do it with After Effects. But I do not want to use propietary software, and even less if I must pay for it. I don't stand piracy, so the only option is using open source software (if it's cheap, maybe I would pay for the software). The most similar to my question that I found is this: https://superuser.com/questions/1054940/using-ffmpeg-to-create-a-video-from-a-sequence-of-tga-images-with-a-depth-of-fi?rq=1 But I don't understand the -filter_complex and -map parameters. So I don't know if I could adapt that parameters having two input videos.

– Carlos Martínez Medina – 2017-12-30T11:25:50.833

Maybe I could expand the two videos into png frames, and make use of another program like ImageMagick to merge the normal frames with depth map frames, and then joining again with ffmpeg? – Carlos Martínez Medina – 2017-12-30T11:40:01.750

You can try ffmpeg -i main.mp4 -i depth.mp4 -filter_complex "[0:v]boxblur=5[v];[v][1]alphamerge[v];[0:v][v]overlay" out.mp4 -- it may not be the exact effect you seek. – Gyan – 2017-12-30T16:51:42.870

Well, using that at least don't crash. I mean, in theory merges the two videos. But I don't perceive any difference. Maybe I need to adjust the DoF settings in WolfCamQL. – Carlos Martínez Medina – 2017-12-30T17:51:53.277

No answers