zee944
16th September 2010, 20:35
I have an unstable video part and I'm unable to fix it. The top of the image is moving back and forth sideways, so the image becomes "skewed" then goes back to normal again and again. The bottom of the image is stable. With the Reform() plugin I can perfectly deskew the picture, but it isn't a constant skew, it is a continous, not-realiably-predictable movement between left and right.
What I had in mind: choose one good frame as a reference, then compare all the other frames to the good frame creating one motion mask for each frames, and from the motion mask it could be figured out how much deskewing each frame needs. The top of ot the image shows a constant object (an edge of a curtain) anyway, which wouldn't move if there wasn't the unstability, so the motion vectors should be showing accurate results about the movement.
MPEG2Source("TD_UNI_unstable.d2v")
ConvertToRGB32()
Crop(0,60-19,0,-60+19).Crop(10,64,-10,-58)
ConvertToYV12()
#Animate(last,500,600,"fix",-25,25)
#fix(10)
fix(-25)
function fix(clip cliptofix, int diff)
{
cliptofix
fixSS=2
Lanczos4Resize(width*fixSS,height*fixSS)
AddBorders(32*fixSS,32*fixSS,32*fixSS,32*fixSS)
Subtitle(last, string(diff),50*fixSS,50*fixSS,0,FrameCount,"Arial",48*fixSS)
deskew(last, last.BlankClip(),ltopx=(32*fixSS)-(diff*fixSS),ltopy=(32*fixSS),lbotx=(32*fixSS),
lboty=height-(32*fixSS),rtopx=width-(32*fixSS)-(diff*fixSS),rtopy=(32*fixSS),rbotx=width-(32*fixSS),
rboty=height-(32*fixSS))
Lanczos4Resize((width-(32*fixSS*2))/fixSS,(height-(32*fixSS*2))/fixSS)
return last
}
This above is my script currently, it contains nothing really except the function to easily fix the distortion. Can someone help to transplant the motion mask theory into script? :confused:
proper sample (35 Mbytes): http://www.mediafire.com/file/140e4r87r2rpj2b/TD_UNI_unstable_sample.ZIP
quick sample (11 Mbytes): http://www.mediafire.com/file/r2bhrqbm93vmrm4/TD_UNI_unstable_quick_sample.zip
What I had in mind: choose one good frame as a reference, then compare all the other frames to the good frame creating one motion mask for each frames, and from the motion mask it could be figured out how much deskewing each frame needs. The top of ot the image shows a constant object (an edge of a curtain) anyway, which wouldn't move if there wasn't the unstability, so the motion vectors should be showing accurate results about the movement.
MPEG2Source("TD_UNI_unstable.d2v")
ConvertToRGB32()
Crop(0,60-19,0,-60+19).Crop(10,64,-10,-58)
ConvertToYV12()
#Animate(last,500,600,"fix",-25,25)
#fix(10)
fix(-25)
function fix(clip cliptofix, int diff)
{
cliptofix
fixSS=2
Lanczos4Resize(width*fixSS,height*fixSS)
AddBorders(32*fixSS,32*fixSS,32*fixSS,32*fixSS)
Subtitle(last, string(diff),50*fixSS,50*fixSS,0,FrameCount,"Arial",48*fixSS)
deskew(last, last.BlankClip(),ltopx=(32*fixSS)-(diff*fixSS),ltopy=(32*fixSS),lbotx=(32*fixSS),
lboty=height-(32*fixSS),rtopx=width-(32*fixSS)-(diff*fixSS),rtopy=(32*fixSS),rbotx=width-(32*fixSS),
rboty=height-(32*fixSS))
Lanczos4Resize((width-(32*fixSS*2))/fixSS,(height-(32*fixSS*2))/fixSS)
return last
}
This above is my script currently, it contains nothing really except the function to easily fix the distortion. Can someone help to transplant the motion mask theory into script? :confused:
proper sample (35 Mbytes): http://www.mediafire.com/file/140e4r87r2rpj2b/TD_UNI_unstable_sample.ZIP
quick sample (11 Mbytes): http://www.mediafire.com/file/r2bhrqbm93vmrm4/TD_UNI_unstable_quick_sample.zip