thetoof
18th October 2008, 03:07
On my attempts at creating a mask to do a framerate conversion on bobbed credits to reapply them on an IVTCed background, I ended up with this:
#load the source
source = mpeg2source("source.d2v")
#select the credits
sourceprep = source.trim(credit start, credit end)
#prepare ivtced and bobbed clip
ivtced = sourceprep.tfm().tdecimate()
bobbed = sourceprep.tempgaussmc_beta1()
#apply framerate conversion (basic settings)
bvp = bobbed.MVAnalyse(isb = true, idx=1)
fvp = bobbed.MVAnalyse(isb = false, idx=1)
fpsconv = bobbed.MVFlowFps(bvp, fvp, 24000, 1001, idx=1)
#Create edge mask, expand it to select all the text and expand more to catch lagging credits of the ivtced source (to completely erase the jerky ones when overlaying the good ones)
mask=fpsconv.mt_edge("sobel",7,7,5,5).mt_expand().mt_expand(mode="vertical").mt_expand(mode="vertical").mt_expand(mode="vertical")
#Select only the part of the frame where the credits appear to "minimize the damage" (i.e. to prevent selecting unrelated edges)
cropped=fpsconv.crop(262,0,-38,-0)
#Overlay the corrected credits on the ivtced clip
overlayed=overlay(ivtced,cropped,262,0)
#Merge that overlayed clip on the ivtced clip based on the edge mask
mt_merge(ivtced,overlayed,mask,u=3,v=3)
The problem is that it selects not only the text, but also background edges with plenty of artifacts due to the fps conversion. So, I was wondering if there is any way of changing the mask so that it selects only elements with constant motion in the same direction (straight up or straight down).
If something's unclear, please tell me and I'll try to reformulate it. If it's impossible... nanh, avs is just too powerful :p
#load the source
source = mpeg2source("source.d2v")
#select the credits
sourceprep = source.trim(credit start, credit end)
#prepare ivtced and bobbed clip
ivtced = sourceprep.tfm().tdecimate()
bobbed = sourceprep.tempgaussmc_beta1()
#apply framerate conversion (basic settings)
bvp = bobbed.MVAnalyse(isb = true, idx=1)
fvp = bobbed.MVAnalyse(isb = false, idx=1)
fpsconv = bobbed.MVFlowFps(bvp, fvp, 24000, 1001, idx=1)
#Create edge mask, expand it to select all the text and expand more to catch lagging credits of the ivtced source (to completely erase the jerky ones when overlaying the good ones)
mask=fpsconv.mt_edge("sobel",7,7,5,5).mt_expand().mt_expand(mode="vertical").mt_expand(mode="vertical").mt_expand(mode="vertical")
#Select only the part of the frame where the credits appear to "minimize the damage" (i.e. to prevent selecting unrelated edges)
cropped=fpsconv.crop(262,0,-38,-0)
#Overlay the corrected credits on the ivtced clip
overlayed=overlay(ivtced,cropped,262,0)
#Merge that overlayed clip on the ivtced clip based on the edge mask
mt_merge(ivtced,overlayed,mask,u=3,v=3)
The problem is that it selects not only the text, but also background edges with plenty of artifacts due to the fps conversion. So, I was wondering if there is any way of changing the mask so that it selects only elements with constant motion in the same direction (straight up or straight down).
If something's unclear, please tell me and I'll try to reformulate it. If it's impossible... nanh, avs is just too powerful :p