Log in

View Full Version : use mask with MVTools to speed up motion vector detection?


bennynihon
11th March 2016, 23:01
I use MVTools and MDegrain to do motion compensated degraining on my videos. Ultimately I end up using a luma+edge mask to only degrain those portions of the clip which are non-dark/non-flat (to avoid degraining portions that would be susceptible to banding) by merging the degrained clip with the original clip (using the mask I mentioned above).

But this seems wasteful, as MVTools must still analyze each entire frame, even though I end up only using a portion of it due to the mask. Is there any way to have MVTools take a mask into consideration so that it doesn't spend time analyzing blocks which will be masked out anyways? Would simply masking the original clip first (perhaps by blacking or whiting out the masked out portions) before feeding it to MVTools speed up the process, since the complexity of the clip will be reduced significantly?

colours
16th March 2016, 12:47
(to avoid degraining portions that would be susceptible to banding)

Alternative: use 16-bit output with MDegrain. If the rest of your filter chain needs 8-bit filters, just stick a DitherPost(mode=6) after it.

Would simply masking the original clip first (perhaps by blacking or whiting out the masked out portions) before feeding it to MVTools speed up the process, since the complexity of the clip will be reduced significantly?

You could try this, and I'd expect a slight speed improvement out of it, but my gut feel also says that there's some potential for things to go very wrong. You might want to do something like this in order to make the blacked out area be 8×8 blocks:
# assuming you want your mask to be white for edges/non-dark parts, black otherwise
mask = mt_edge(blah).mt_logic(blah)
blockmask = mask.mt_expand().mt_expand().bilinearresize(mask.width()/8, mask.height()/8).mt_binarize(10).pointresize(mask.width(), mask.height())
prefilter = mt_merge(blockmask.greyscale(), source, blockmask, luma=true)
super = source.msuper()
superfilt = prefilter.msuper() # see MVTools docs for more info
# MAnalyse, MDegrainN blah blah blah
mt_merge(source, filtered, mask)


(Usual caveat applies: I didn't test this at all and you may have to modify it significantly for your needs. I don't even know if it makes a difference.)