VideoHelp Forum
+ Reply to Thread
Results 1 to 11 of 11
Thread
  1. Member
    Join Date
    Mar 2019
    Location
    Henderson, KY, USA
    Search PM
    I'm editing a tape transfer through AviSynth, some frames look like this.
    Click image for larger version

Name:	9dofs1N.png
Views:	92
Size:	818.2 KB
ID:	59614

    I know how to fix it with a simple
    Code:
    SeparateFields() e=SelectEven().crop(0,0,0,-1).AddBorders(0,1,0,0) o=SelectOdd() Interleave(e,o) Weave()
    or
    Code:
    SeparateFields() e=SelectEven().crop(0,1,0,-0).AddBorders(0,0,0,1) o=SelectOdd() Interleave(e,o) Weave()
    Click image for larger version

Name:	OgsvSPX.png
Views:	79
Size:	816.6 KB
ID:	59615

    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.
    Quote Quote  
  2. 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.
    Quote Quote  
  3. Member
    Join Date
    Mar 2019
    Location
    Henderson, KY, USA
    Search PM
    Originally Posted by jagabo View Post
    SwapFields()
    works on most frames, however it creates jumpy video due to the field swap. I wouldn't mind making everything BFF, as long as it doesn't screw everything else up.

    Originally Posted by jagabo View Post
    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.
    got any recommendations?
    Quote Quote  
  4. 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")
    Quote Quote  
  5. Member
    Join Date
    Mar 2019
    Location
    Henderson, KY, USA
    Search PM
    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?
    Image Attached Files
    Quote Quote  
  6. 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)
    The FindCombing() filter looks for something that looks like combing in the word FEED. Normal frames show virtually no combing. The field swapped frames show significant combing.

    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).
    Image Attached Files
    Quote Quote  
  7. Member
    Join Date
    Mar 2019
    Location
    Henderson, KY, USA
    Search PM
    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")
    B̶u̶t̶ ̶i̶t̶ ̶d̶o̶e̶s̶n̶'̶t̶ ̶s̶e̶e̶m̶ ̶t̶o̶ ̶h̶e̶l̶p̶.̶ Lowering the ConditionalFilter number helps, however everything's jumping up and down whenever the shift happens.
    Image Attached Files
    Last edited by ENunn; 29th Jun 2021 at 20:15.
    Quote Quote  
  8. You need to lower the threshold in ConditionalFilter. 10 worked for me.
    Quote Quote  
  9. Member
    Join Date
    Mar 2019
    Location
    Henderson, KY, USA
    Search PM
    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.
    Quote Quote  
  10. 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.
    Quote Quote  
  11. Member
    Join Date
    Mar 2019
    Location
    Henderson, KY, USA
    Search PM
    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.
    Image Attached Files
    Last edited by ENunn; 30th Jun 2021 at 17:44.
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!