Log in

View Full Version : stabilizing sideway skewing movement?


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

zee944
23rd September 2010, 13:41
I didn't get any answers; is that because of the complexity of the problem? Perhaps it isn't even possible to fix this?

I'd be grateful for a few expert responses...

Hagbard23
23rd September 2010, 14:28
Hmm - difficult problem....i can only suggest this

http://avisynth.org.ru/depan/depan.html

sorry, but there is nothing more in my brain...

BTW: where is your media from? what's the source? is it interlaced, telecined or something similar? this is, what i believe, very important for further steps...

good luck!

zee944
25th September 2010, 12:58
Thank, I know about DePan and DeShaker but they aren't designed for this unstability.


BTW: where is your media from? what's the source? is it interlaced, telecined or something similar? this is, what i believe, very important for further steps...


It's telecined film material took from an NTSC 4:3 DVD. The sample .m2v file you've seen is unaltered. It isn't a problem to display it in the original progressive format.

zee944
14th October 2010, 07:33
Do I have to give it up for good? :(

2Bdecided
14th October 2010, 11:23
I've downloaded your sample. It's gate weave on an old telecine machine where the film moves in an unwanted way while it's being scanned - hence the resulting scan is geometrically distorted.

It happens in your case that the particular movement causes the picture to be skewed, though lots of other distortions are possible depending on the movement.

I've always imagined a fix would be something like you suggest: use mvtools to track "stationary" parts of the frame, and fix the frame geometry to make them truly stationary. However, I've never seen anyone post a script that does this, and while it sounds simple, there are huge challenges!

Simplest answer is to re-can the film on a good modern telecine, but of course us mortals can't do that!

Shame - this is a common problem - all older film scans suffer from it to some extent, but sometimes it's really objectionable!

Cheers,
David.

zee944
17th January 2011, 22:12
Thanks for checking my sample and for the explanation David.

Eventually I captured the movement of the top of the curtain with DeShaker, and used the motion data from the logfile (read through ConditionalFilter) to "deskew" all the frames with the deskew filter and with the little function I've written above. It must've been possible to do it on-the-fly without a logfile, but hell... that would've needed some expert knowledge of DePan. The keyword wasn't DePan or DeShaker solely, but the tricky way of using it since they're not capable of fixing this problem by default.