View Single Post
Old 21st August 2008, 16:30   #7  |  Link
4evrplan
Registered User
 
Join Date: Feb 2008
Posts: 46
Here's the code I came up with to correct this.

function BumpEven(clip inc, int offset, float thresh)
{
inc = ConditionalFilter(inc,inc.Crop(0,offset,0,0).AddBorders(0,0,0,offset),inc,"RGBDifference(ConvertToRGB().Crop(0," + String(offset) + "-1,0," + String(offset) + "-240),ConvertToRGB().Crop(0," + String(offset) + ",0," + String(offset) + "-239))","greaterthan",String(thresh))
return (offset > 1) ? BumpOdd(inc, offset-1, thresh) : inc
}

function BumpOdd(clip inc, int offset, float thresh)
{
inc = ConditionalFilter(inc,inc.ConvertToRGB().Crop(0,offset,0,0).AddBorders(0,0,0,offset).ConvertToYV12(),inc,"RGBDifference(ConvertToRGB().Crop(0," + String(offset) + "-1,0," + String(offset) + "-240),ConvertToRGB().Crop(0," + String(offset) + ",0," + String(offset) + "-239))","greaterthan",String(thresh))
return (offset > 1) ? BumpEven(inc, offset-1, thresh) : inc
}

function Bump(clip inc, int maxOffset, float thresh)
{
Assert(maxOffset > 0)
inc = (maxOffset % 2 == 0) ? BumpEven(inc, maxOffset, thresh) : BumpOdd(inc, maxOffset, thresh)
return inc
}

It's sloppy, slow, and not generalized at all, but it corrects over half of the shifted frames without damaging good ones, depending on the threshold value. However, after seeing several consecutive shifted frames in their corrected positions, I realized that they're all dropped frames. It's an old tape, so maybe the VCR dropped the frames, but I have a feeling it was the horrible video camera used to record it in the first place.

That opens a whole new can of worms. I would like to use mvtools to replace these bad frames with interpolated frames, but is there a way to automatically detect and replace dropped frames with interpolated frames? The issue is complicated by the fact that dropped frames are not identical to previous frames (shifted + noise). Ahrrrgh! Someone please help.
4evrplan is offline   Reply With Quote