03-19-2022, 10:50 PM
|
|
Free Member
|
|
Join Date: Jan 2016
Posts: 434
Thanked 87 Times in 78 Posts
|
|
My VHS captures have occasional vertical jitter, I believe the problem to be a weak "start of frame" signal from the VCR causing the capture card to delay the start of frame for a line or two. So I wrote an AviSynth function that lets you manually correct these glitches, frame by frame:
Code:
function MoveFieldDownAndBackfill(clip c, int numRows) {
c
line1=Crop(0,0,-1,numRows)
Crop(0,0,-0,-numRows)
AddBorders(0,numRows,0,0)
Overlay(last, line1, mode="blend", x=0, y=0)
return last
}
function ShiftFieldsDownAndBackfill(clip c, int frameNumber, int r0_offset, int r1_offset) {
c
SeparateFields()
ApplyRange(frameNumber*2, frameNumber*2, "MoveFieldDownAndBackfill", r0_offset)
ApplyRange(frameNumber*2+1, frameNumber*2+1, "MoveFieldDownAndBackfill", r1_offset)
Weave()
}
MoveFieldDownAndBackfill is just a helper function. Call ShiftFieldsDownAndBackfill with the number of lines you want to shift the odd fields down, and the number of lines you want to shift the even fields down, and it fixes that frame. For example:
Code:
ShiftFieldsDownAndBackfill(6,0,1)
This takes frame #6, shifts the even fields down by 0 lines, and the odd fields down by 1 line, and backfills the top of the frame with a duplicate of the top line of the top field(s) you just shifted down. So it replaces a whole-frame glitch with an almost unnoticeable top-of-the-frame glitch.
Sometimes you will need to shift both fields down by up to 2 lines each.
This code is very inefficient, and locating the glitched frames is a manual process, so it's best not to use this on more than a couple of dozen glitches in a video file. But it stabilizes the frame pretty well without resorting to brute force like using something like stab(). I've attached a restored jitter clip that was posted in this thread.
Also, another useful thing to do is call FreezeFrame() when the image is static. For example:
Code:
FreezeFrame(2,10,7)
This duplicates "good" frame 7 across "bad" frames 2 through 10.
Last edited by traal; 03-19-2022 at 10:51 PM.
Reason: misspelling
|
Someday, 12:01 PM
|
|
Ads / Sponsors
|
|
Join Date: ∞
Posts: 42
Thanks: ∞
Thanked 42 Times in 42 Posts
|
|
|
03-20-2022, 11:42 AM
|
|
Free Member
|
|
Join Date: Jan 2016
Posts: 434
Thanked 87 Times in 78 Posts
|
|
Negative numbers will now move the field up. Only one function changed:
Code:
function MoveFieldDownAndBackfill(clip c, int numRows) {
c
if(numRows < 0) { # moving up
numRows = -numRows
line1=Crop(0,(c.Height-1)-numRows,-0,numRows)
Crop(0,1,-0,c.Height-numRows)
AddBorders(0,0,0,numRows)
Overlay(last, line1, mode="blend", x=0, y=c.Height-1)
}
else if(numRows > 0) { # moving down
line1=Crop(0,0,-0,numRows)
Crop(0,0,-0,-numRows)
AddBorders(0,numRows,0,0)
Overlay(last, line1, mode="blend", x=0, y=0)
}
return last
}
|
The following users thank traal for this useful post:
lordsmurf (02-25-2024)
|
07-24-2022, 07:00 PM
|
|
Free Member
|
|
Join Date: Jan 2016
Posts: 434
Thanked 87 Times in 78 Posts
|
|
To check my work, I like to put the following line into a 2nd .avs file that loads the first:
Code:
clip = AviSource("MyVideo.avs")
clip.AssumeTFF()
Subtract(clip, clip.Trim(1, 0))
It makes glitches much easier to see with tired eyes.
I also use FreezeFrame to fix some timebase errors, and occasionally JDL_FreezeRegion when the error is only in part of the frame with little movement.
|
The following users thank traal for this useful post:
lordsmurf (02-25-2024)
|
01-11-2025, 11:34 PM
|
|
Site Staff | Video
|
|
Join Date: Dec 2002
Posts: 14,599
Thanked 2,653 Times in 2,258 Posts
|
|
I can't believe that I've had this bookmarked for almost 3 years now. I have a project where I want to try this, but it just never happened.
|
02-05-2025, 12:38 AM
|
|
Premium Member
|
|
Join Date: Jul 2023
Posts: 139
Thanked 52 Times in 47 Posts
|
|
Quote:
Originally Posted by lordsmurf
I can't believe that I've had this bookmarked for almost 3 years now. I have a project where I want to try this, but it just never happened.
|
The script is pretty useful, and I'm glad it exists as I've used it myself. Especially because usually I've seen only one field of a given frame be offset by one pixel (sometimes two pixels, rarely three and four), very easy to correct and since I'd be cropping some pixels from the top and bottom anyway, no defects are detected. Of course, most time consuming part is locating the frames.
You probably already know this but for anyone wanting a tip, the second number set in the script (first is the number of the frame you want to be adjusted) represents the bottom field and the third number set represents the top field. Use the remove top/keep bottom field & remove bottom/keep top field deinterlace options in VirtualDub to check which field has the offending pixel offset that'll need to be corrected.
|
The following users thank Aya_Rei for this useful post:
USAF_wingnut (02-05-2025)
|
Similar Threads
|
Thread |
Thread Starter |
Forum |
Replies |
Last Post |
Repeating vertical line pixels stretching across frame?
|
danielscreed |
Capture, Record, Transfer |
3 |
09-13-2020 02:29 PM |
Jitter / Frame rate issue
|
JamieStar99 |
Restore, Filter, Improve Quality |
6 |
04-06-2018 09:37 PM |
Remove vertical jitter from interlaced footage?
|
hysteriah |
Restore, Filter, Improve Quality |
13 |
02-17-2015 09:43 AM |
Old VHS-C tapes transfer jitter, blue frame issues?
|
Courtica |
Restore, Filter, Improve Quality |
19 |
09-01-2014 04:04 PM |
Interlaced video to progressive (double frame rate)
|
metaleonid |
Edit Video, Audio |
23 |
09-29-2013 09:51 PM |
Thread Tools |
Search this Thread |
|
|
All times are GMT -5. The time now is 06:21 AM
|