Using ffmpeg to create a video from a sequence of TGA images, with a depth of field blur effect sourced from the TGA's alpha channel

I'm working on turning a sequence of TGA images into a video using ffmpeg. I want the video to have a depth of field blur effect. The alpha channel of each TGA contains a depth-mask, where black=close and white=far. I want to use this info to add DOF blur to the final output of that frame. After searching, the closest answer I could find was this FFMPEG filter to boxblur and greyscale a video using alpha mask, but it is for a static dof-mask. The DOF mask I would be using is obviously changing every frame, and an alpha channel instead of a seperate png.

Here is my current cmd line

ffmpeg -framerate 60 -i image.%10d.tga -c:v libx264 -preset slow -crf 0 -c:a copy -pix_fmt yuv420p output0.mp4

It seems the answer would involve some use of alphamerge/alphaextract/boxblur, but I'm brand new to ffmpeg so I don't know how to formulate the command.

Here is an example of the type of TGA I would use https://dl.dropboxusercontent.com/u/19482624/alphachanneltest.tga

Thanks in advance.


Solution 1:

The syntax is along the same lines as in the linked Q/A.

ffmpeg -framerate 60 -i image.%10d.tga \
       -filter_complex "[0:v]boxblur=5[v];[0:v][v]overlay[vout]" \
       -map "[vout]" -preset slow -crf 0 -pix_fmt yuv420p output0.mp4