Another solution (single pass):
Code:
# Your source here
h = Height ()
m = ImageSource("mask.png", end=FrameCount()-1).ShowRed ("YV12")
c = mt_merge (last, m, m, luma=true)
StackVertical (c, last)
TFM (y0=h, y1=h*2-1)
Crop (0, h, 0, 0)
You'll have to define a mask file where the masked parts are pure white, and valid parts pure black.