VideoHelp Forum
+ Reply to Thread
Results 1 to 12 of 12
Thread
  1. Member
    Join Date
    Oct 2021
    Location
    Poland
    Search PM
    Hello, can someone tell me how to remove those weird bad interlace lines on video that is progressive? Maybe some AviSynth script would help.
    Quote Quote  
  2. Without a short sample of the file you use as source: no
    users currently on my ignore list: deadrats, Stears555
    Quote Quote  
  3. Member
    Join Date
    Oct 2021
    Location
    Poland
    Search PM
    Here's the short sample of file:
    cnpolandecpnextbumpereliotkid.mp4
    Quote Quote  
  4. Those were caused by re-sizing interlaced video without first deinterlacing. They are horizontal lines, but as you can see, they are much taller than a single scan line and are therefore not "interlace lines."

    They cannot easily be repaired, although I did come up with a way to dramatically reduce the problem when I helped someone years ago over in doom9.org. Here is a link to that thread:

    repair bad deinterlacing

    I never took the extra time to generalize the code into a function, so you'll have to tweak it for your frame rate and resolution.

    [edit] Post #42 in the thread I linked to has the "final" code that I posted. However, remember that it will not work on your clip without tweaking.
    Last edited by johnmeyer; 1st Jan 2022 at 11:34.
    Quote Quote  
  5. something like:
    Code:
    Spline36Resize(640,240)
    AssumeTFF()
    QTGMC(Preset="Fast")
    Spline36Resize(640,480)
    should work. (basically throwing away half of the height)
    users currently on my ignore list: deadrats, Stears555
    Quote Quote  
  6. You can reduce the damage by only applying the fix to areas where there are comb artifacts.

    Code:
    ###################################################
    #
    # build a mask of areas where there are 
    # alternating horizontal lines
    #
    ##################################################
    
    function CombMask(clip v, int "threshold")
    {
        threshold = default(threshold, 5)
    
        Subtract(v, v.blur(0.0, 1.0).Sharpen(0.0, 0.6))
        GeneralConvolution(0, "
            0  8  8  8  0
           -0 -8 -8 -8 -0 
            0  8  8  8  0
           -0 -8 -8 -8 -0
            0  8  8  8  0", chroma=false, alpha=false)
        mt_lut("x 125 - abs")
        mt_binarize(threshold) # threshold
        mt_inpand()
        mt_expand()
        mt_expand(chroma="-128")
    }
    
    ##################################################
    
    src = LSMASHVideoSource("cnpolandecpnextbumpereliotkid.mp4").AssumeTFF()
    
    combmask = CombMask(src, 5).Blur(1.4).Blur(1.4)
    blurry = Spline36Resize(src, src.width, src.height/3).Spline36Resize(src.width, src.height)
    
    Overlay(src, blurry, mask=combmask)
    Quote Quote  
  7. Originally Posted by jagabo View Post
    You can reduce the damage by only applying the fix to areas where there are comb artifacts.

    Code:
    ###################################################
    #
    # build a mask of areas where there are 
    # alternating horizontal lines
    #
    ##################################################
    
    function CombMask(clip v, int "threshold")
    {
        threshold = default(threshold, 5)
    
        Subtract(v, v.blur(0.0, 1.0).Sharpen(0.0, 0.6))
        GeneralConvolution(0, "
            0  8  8  8  0
           -0 -8 -8 -8 -0 
            0  8  8  8  0
           -0 -8 -8 -8 -0
            0  8  8  8  0", chroma=false, alpha=false)
        mt_lut("x 125 - abs")
        mt_binarize(threshold) # threshold
        mt_inpand()
        mt_expand()
        mt_expand(chroma="-128")
    }
    
    ##################################################
    
    src = LSMASHVideoSource("cnpolandecpnextbumpereliotkid.mp4").AssumeTFF()
    
    combmask = CombMask(src, 5).Blur(1.4).Blur(1.4)
    blurry = Spline36Resize(src, src.width, src.height/3).Spline36Resize(src.width, src.height)
    
    Overlay(src, blurry, mask=combmask)
    I have a hyperthetical xx video question to help me try your Avisynth Script!
    Lets say I have video, Calling it vid.mp4 1400x770 30fps Progressive from original HD interlaced 1920x1080i 29.97.
    Comb lines like OP of "Comb artifacts in progressive source?" only throughout the video so there are not good frames either side,
    https://forum.videohelp.com/threads/395229-Comb-artifacts-in-progressive-source#post2567143


    I have your script working, still experimenting.
    Last edited by Charles-Roberts; 14th Feb 2024 at 01:46.
    Quote Quote  
  8. Originally Posted by johnmeyer View Post
    Those were caused by re-sizing interlaced video without first deinterlacing. They are horizontal lines, but as you can see, they are much taller than a single scan line and are therefore not "interlace lines."

    They cannot easily be repaired, although I did come up with a way to dramatically reduce the problem when I helped someone years ago over in doom9.org. Here is a link to that thread:

    repair bad deinterlacing

    I never took the extra time to generalize the code into a function, so you'll have to tweak it for your frame rate and resolution.

    [edit] Post #42 in the thread I linked to has the "final" code that I posted. However, remember that it will not work on your clip without tweaking.
    Avisynth open failure:
    Script error: There is no function named 'GScript'.
    AviSynth+ I put GScript_26_64.dll in plugins64+ folder.

    [Plugin errors/warnings]
    __________________________________________________ _________________________________________

    Function duplicates:

    "undefined" : "[InternalFunction]"
    "Undefined" : "C:\Users\1\AviSynth+\plugins64+\Zs_RF_Shared.avsi "

    __________________________________________________ _________________________________________

    Cannot load file 'C:/Users/1/AviSynth+/plugins64+/GScript.dll'. Platform returned code 126:
    The specified module could not be found.

    Dependencies that could not be loaded:
    MSVCR100.dll

    Note: Visual Studio 2010 Runtime doesn't seem to be installed
    __________________________________________________ _________________________________________

    What is the solution for Function duplicates, delete or just ignore?
    "Undefined" : "C:\Users\1\AviSynth+\plugins64+\Zs_RF_Shared.avsi "
    Last edited by Charles-Roberts; 14th Feb 2024 at 04:10.
    Quote Quote  
  9. Take a look at the GScript page, it may help:

    https://forum.doom9.org/showthread.php?t=147846
    Quote Quote  
  10. Originally Posted by johnmeyer View Post
    Take a look at the GScript page, it may help:

    https://forum.doom9.org/showthread.php?t=147846
    I got your script working without errors, but there was no change in the video interlace lines!
    The problem is understanding what settings are related to function, so I could experiment.

    I ended up using Jagabo's CombMask script.
    If his program was in a packaged software with visual UI for adjustment, it would be popular.
    Found it had to be fine tuned with all settings, to get a really good result.

    Here is my slightly modified version of Jagabo's CombMask Script.
    The example settings demonstrate the range of usable numbers!


    Code:
    ###################################################
    # Jagabo Jan 2021
    # Fix combing in an already interlaced video.
    # build a mask of areas where there are 
    # alternating horizontal lines
    # AssumeTFF top field or AssumeBFF bottom field first. 
    
    # Settings I used for different videos.
    # binarize 5.0 - size 515, 143, 768
    # binarize 5.0 - size 511, 217, 1080 
    # binarize 0.8 - size 80,  279, 756
    # binarize 0.8 - size 99,  80,  1080
    # binarize 0.2 - size 101, 129, 396
    
    ##################################################
    
    function AltHzLineMask(clip v, int "threshold")
     {
        threshold = default(threshold, 5)
    
    Subtract(v, v.blur(0.0, 1.0).Sharpen(0.0, 0.6))
    #ConvertToRGB32()
    GeneralConvolution(0, "
    0 8 8 8 0
    -0 -8 -8 -8 -0 
    0 8 8 8 0
    -0 -8 -8 -8 -0
    0 8 8 8 0")
    ConvertToYV24()
    mt_lut("x 125 - abs")
    mt_binarize(0.2) # threshold
    mt_inpand()
    mt_expand()
    mt_expand(chroma="-128")
     }
     ##################################################
    #AVISource-DirectShowSource
    
     DirectShowSource("Jet.avi")
     #ConvertToYV12(interlaced=true)
    
     src = last
    
    
     # build a mask of areas where there is combing
     ConvertToYV24() # convert to YV24 so we can specify an odd height
     Spline36Resize(width,101) # found experimentally
     converttorgb32()
     AltHzLineMask()
    
    
     mask = Blur(1.0).BilinearResize(src.width, src.height).ConvertToYV12()
    
    
     # blur the comb artifacts by downscaling, then upscaling
     src
     Spline36Resize(width, 129)
     Spline36Resize(width,396)
    
     # overlay the blurred image only where there are comb artifacts
     Overlay(src, last, mask=mask)
    Last edited by Charles-Roberts; 22nd Mar 2024 at 16:35.
    Quote Quote  
  11. Originally Posted by Charles-Roberts View Post
    I got your script working without errors, but there was no change in the video interlace lines!The problem is understanding what settings are related to function, so I could experiment.
    The script I developed in that thread was very specific to the number of scan lines contained in each "tooth." I hardwired that, and never went back to generalize the script. This problem shows up a LOT and therefore I keep promising myself to go back and develop a real function. However, life keeps intruding, and I don't think I will get around to that any time soon.

    It's been a decade since I looked at the code I developed in 2014. However, I briefly scanned what I posted in post #42, and it is clear that this is the code you'd need to change:

    Code:
    clip1  = crop(source,0,0,480,9)
    clip2  = crop(source,0,9,480,18)
    clip3  = crop(source,0,27,480,18)
    clip4  = crop(source,0,45,480,18)
    clip5  = crop(source,0,63,480,18)
    clip6  = crop(source,0,81,480,18)
    clip7  = crop(source,0,99,480,18)
    clip8  = crop(source,0,117,480,18)
    clip9  = crop(source,0,135,480,18)
    clip10 = crop(source,0,153,480,18)
    clip11 = crop(source,0,171,480,18)
    clip12 = crop(source,0,189,480,18)
    clip13 = crop(source,0,207,480,18)
    clip14 = crop(source,0,225,480,18)
    clip15 = crop(source,0,243,480,18)
    clip16 = crop(source,0,261,480,18)
    clip17 = crop(source,0,279,480,18)
    clip18 = crop(source,0,297,480,18)
    clip19 = crop(source,0,315,480,18)
    clip20 = crop(source,0,333,480,18)
    clip21 = crop(source,0,351,480,9)
    You'd also need to change:
    Code:
    RowStart= 9
    RowStep = 18
    As you can see, each clip has starting rows which are 18 greater than the previous start, except for the first row which is half that amount (9).

    You will need to zoom in on your clips and count the number of scan lines in each "tooth" in your damaged footage. Use that number and then adjust these two sections of the script accordingly.
    Quote Quote  
  12. Originally Posted by Charles-Roberts View Post
    I ended up using Jagabo's CombMask script.
    If his program was in a packaged software with visual UI for adjustment, it would be popular.
    Found it had to be fine tuned with all settings, to get a really good result.
    Yes, the script was specifically tuned for the OP's video. You can use Animate() to examine the effect of a filter over different values. It's still not as easy as a GUI but it's definitely helpful in circumstances like this. For Example:

    Code:
    ###################################################
    #
    # build a mask of areas where there are 
    # alternating horizontal lines
    #
    ##################################################
    
    function CombMask(clip v, int "threshold")
    {
        threshold = default(threshold, 5)
    
        Subtract(v, v.blur(0.0, 1.0).Sharpen(0.0, 0.6))
        GeneralConvolution(0, "
            0  8  8  8  0
           -0 -8 -8 -8 -0 
            0  8  8  8  0
           -0 -8 -8 -8 -0
            0  8  8  8  0", chroma=false, alpha=false)
        mt_lut("x 125 - abs")
        mt_binarize(threshold) # threshold
        mt_inpand()
        mt_expand()
        mt_expand(chroma="-128")
    
        Subtitle(String(threshold)) # note I print the threshold value here for convenience
    }
    
    ###################################################
    
    src = LWLibavVideoSource("cnpolandecpnextbumpereliotkid.mp4", cache=false, prefer_hw=2) 
    
    Trim(350, 350) # examine only frame 350
    Loop(100,0,0) # repeat that frame to make 100
    Animate(0, 100, "CombMask", src,0, src,100) # animate frames 0 to 99, applying CombMask with values 0 to 99)
    StackHorizontal(src, last) # stack the source and the animated mask side by side
    You can open that script in an editor like VirtualDub and scrub through it to see the effect of different threhold values.

    Image
    [Attachment 77869 - Click to enlarge]
    Quote Quote  



Similar Threads

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