I'm editing a tape transfer through AviSynth, some frames look like this.
I know how to fix it with a simple
orCode:SeparateFields() e=SelectEven().crop(0,0,0,-1).AddBorders(0,1,0,0) o=SelectOdd() Interleave(e,o) Weave()Code:SeparateFields() e=SelectEven().crop(0,1,0,-0).AddBorders(0,0,0,1) o=SelectOdd() Interleave(e,o) Weave()
However, this is a long and painful process. All this and I'm not even a minute in with this project :P
https://www.youtube.com/watch?v=zyg29QHJ0-o
Also, if I do more than 75 edits, AviSynth freaks out. Gives me a "could not locate decompressor" error. Don't know why, I have plenty of memory available (running 64GB of ram)
Depending on the line I use everything gets all out of wack when I start to deinterlace it (jumpy video ). I could deinterlace then reinterlace to fix that but I don't want to kill quality for no reason if I don't have to.
Is there a faster way to do this? I've stacked the script without the line and the script with the line together with Median to no avail.
Try StreamFab Downloader and download from Netflix, Amazon, Youtube! Or Try DVDFab and copy Blu-rays! or rip iTunes movies!
+ Reply to Thread
Results 1 to 11 of 11
Thread
-
-
SwapFields()
If it's a few frames here and there you may be able to use one of the runtime filters to detect frames with the problem and automatically switch them. -
-
You need to supply a sample video with several instances of frames with swapped fields. But you need to find something about those frames that differentiates them from the "normal" frames. For example, when this happens with capture devices there's often a black scanline at the top of the frame. Or maybe you can search for comb artifacts on non-moving parts of the frame. But the code would look something like:
Code:testclip = SomeIdentifiableDifference() normalclip = QTGMC() swapclip = SwapFields().ComplimentParity().QTGMC() ConditionalFilter(testclip, normalclip, swapclip, "AverageLuma()", "GreaterThan", "3.0")
-
Sample's attached. You explained it really well, the script is a bit confusing though. With the test clip do I trim to where the pixels are shifted?
-
testclip (and the logic in ConditionalFilter) needs to be something that differentiates the normal frames from the field swapped frames. Here I use the static "FEED" text near the bottom left of the frame. I chose that because it is present over the entire clip and easy to test.
Code:################################################### # # Build a mask of areas where a pixel has a # darker pixel above and below it. # ################################################## function FindCombing(clip v, int "threshold") { threshold = default(threshold, 10) # find vertical low to high transitions Subtract(v, v.blur(1.0, 1.0)) GeneralConvolution(0, " 0 -8 0 0 8 0 0 0 0", chroma=false, alpha=false) lth = mt_lut("x 126 -") # find vertical high to low transitions Subtract(v, v.blur(1.0, 1.0)) GeneralConvolution(0, " 0 0 0 0 8 0 0 -8 0", chroma=false, alpha=false) htl = mt_lut("x 126 -") # Logical AND(ish) Overlay(lth, htl, mode="multiply") mt_binarize(threshold) mt_expand() mt_inpand() mt_inpand(chroma="-128") } ################################################## LWlibavVideoSource("shiftpixels.avi") AssumeTFF() testclip = Crop(98,396,56,26).FindCombing().SelectEvery(1,0,0) normalclip = QTGMC() swapclip = SwapFields().QTGMC().Subtitle("swapfields") ConditionalFilter(testclip, swapclip, normalclip, "AverageLuma", "GreaterThan", "50") Overlay(last, testclip, x=20, y=20)
Two copies of the original video are made. One deinterlaced with just QTGMC(), the other deinterlaced with QTGMC() after SwapFields(). ConditionalFilter() picks from those two clips depending on whether there's combing in the "FEED" text. The subtitle text was added to make it obvious which of the two clips is selected, and the overlay of testclip shows how the decision was made.
Some other candidates for swapped field detection are the G4 logo near the top right of the frame, and some of the closed captions at the top of the frame (pretty consistently on line 0 in the normal frames, line 1 in the field swapped frames). -
Wow, that actually helped a lot! Thanks!
I have another sample of a different show but with the same G4 bug, I can't seem to get it working. Sample's attached.
I tried this:
Code:testclip = Crop(600, 45, -70, -401).FindCombing().SelectEvery(1,0,0) normalclip = QTGMC() swapclip = SwapFields().QTGMC() ConditionalFilter(testclip, swapclip, normalclip, "AverageLuma", "GreaterThan", "50")
Last edited by ENunn; 29th Jun 2021 at 20:15.
-
Yeah that ended up fixing it. However now it just jumps up and down, it doesn't stay still. Is there a way to work with multiple points? There's just some cases where I can't get a good hold since there's no graphics or whatever.
Last edited by ENunn; 29th Jun 2021 at 22:48.
-
You may be able to eliminate the remaining small up/down bounce with Stab(). With my current setup, the 64 bit version of Stab() doesn't work right. The 32 bit version does work though.
Here's a version of the script that uses closed caption line to detect the swapped fields:
Code:LWlibavVideoSource("shiftpixels2.avi") AssumeTFF() testclip = Crop(40, 0, 24, 1).PointResize(64,64).ConvertToYV16().SelectEvery(1,0,0) normalclip = QTGMC() swapclip = SwapFields().QTGMC() ConditionalFilter(testclip, swapclip, normalclip, "AverageLuma", "LessThan", "80")
Last edited by jagabo; 30th Jun 2021 at 10:46.
-
Is Stab supposed to shift left and right too? I can't work with 32-bit AviSynth+ unfortunately.
The new script works well, however yet another issue creeps up. 🙃 Attached. Guess it's gonna be difficult trying to do a one size fits most script. I guess I can just trim it out and splice the normal looking version in.Last edited by ENunn; 30th Jun 2021 at 17:44.
Similar Threads
-
Fix a badly de-interlaced video (with avisynth if possible)
By Roemer in forum EditingReplies: 3Last Post: 26th May 2021, 07:18 -
How to correctly remove horizontally shifted frames?
By bruno321 in forum RestorationReplies: 0Last Post: 23rd Feb 2021, 02:31 -
Fix combing in an already interlaced video.
By dabbdubb in forum Video ConversionReplies: 6Last Post: 3rd Feb 2021, 17:52 -
Manually fix pan, shift pixels, with Avisynth
By lordsmurf in forum RestorationReplies: 17Last Post: 19th Dec 2020, 09:34 -
Bottom portion of clip is shifted to left
By nick1977 in forum RestorationReplies: 9Last Post: 22nd Apr 2020, 05:18