VideoHelp Forum
+ Reply to Thread
Results 1 to 6 of 6
Thread
  1. Hello everybody. Recently, I began archiving my family's old home videos, which are stored on some VHS tapes. There seem to be severe problems with rainbows, haloing, chroma bleed, and other stuff. I think I've fixed most of these issues but was wondering if I could please get some input about my script. Also, I don't know if there's anything else I can do about the chroma bleeding.

    Script:

    Code:
    AVISource("C:\sample.avi")
    
    # Fix left and right haloing
    FixVHSOversharp(20, 18, 10)
    FixVHSOversharpL(10, 20, 10)
    
    converttoyv12(interlaced=true)
    
    aWarpSharp2(depth=60, chroma=6) # Fix chroma bleed
    
    #Fix white balance
    Overlay(last, ColorYUV(off_y=-8, off_u=9, off_v=-2), 0, 0, GreyScale(last).ColorYUV(cont_y=30)) # use with mergechroma line above
    
    chubbyrain2(th=1, radius=15, interlaced=true) # remove moire rainbows
    chroma=Cnr2("oxx",8,16,191,100,255,32,255,false)
    mdegrain2i2(chroma, 8,4,0) # denoise
    
    QTGMC( Preset="Slower", SrchClipPP=2) # second parameter?
    
    SmoothLevels(16,1.0,255,16,255,chroma=200,limiter=0,tvrange=true,dither=100,protect=6)
    tweak(hue=10, coring=false) # fix green tinge
    
    Crop(4, 4, -22, -10)
    spline36resize(640,480) # resize to 4:3 video
    
    # -------------------------------------------------------------------------
    
    function MDegrain2i2(clip source, int "blksize", int "overlap", int "dct")
    {
        Vshift=0 # 2 lines per b obbed-field per tape generation (PAL); original=2; copy=4 etc
        Hshift=0 # determine experimentally -- I've used values up to 12 (can be + or -)
        overlap=default(overlap,0) # overlap value (0 to 4 for blksize=8)
        dct=default(dct,0) # use dct=1 for clip with light flicker
    
        fields=source.SeparateFields() # separate by fields because this function is for interlaced video
    
        #This line gets rid of vertical chroma halo -- eliminate if this isn't a problem (i.e., for digital video)
        fixed_fields=MergeChroma(fields,crop(fields,Hshift,Vshift,0,0).addborders(0,0,Hshift,Vshift))
        #fixed_fields=fields #Use this line instead of the one above when doing digital video
    
        super = fixed_fields.MSuper(pel=2, sharp=1)
        backward_vec2 = super.MAnalyse(isb = true, delta = 2, blksize=blksize, overlap=overlap, dct=dct)
        forward_vec2 = super.MAnalyse(isb = false, delta = 2, blksize=blksize, overlap=overlap, dct=dct)
        backward_vec4 = super.MAnalyse(isb = true, delta = 4, blksize=blksize, overlap=overlap, dct=dct)
        forward_vec4 = super.MAnalyse(isb = false, delta = 4, blksize=blksize, overlap=overlap, dct=dct)
    
        #Change thSAD to increase/decrease de-noising
        MDegrain2(fixed_fields,super, backward_vec2,forward_vec2,backward_vec4,forward_vec4,thSAD=400) #400=original setting
        Weave() #Convert fields back into interlaced video
    }
    Before:


    After:


    Here's a short (original) sample of the video:

    https://files.videohelp.com/u/199049/sample.avi

    Also, in the QTGMC line, if I don't specify the second parameter as being 2 (default is 3 at the "Slower" preset), then there seems to be a strange blurring in the video. It seems deliberate, as this is what the wiki says:

    SrchClipPP (0,1,2,3) Pre-filtering for motion search clip, 0 = none, 1 = simple blur, 2 = Gauss blur, 3 = Gauss blur + edge soften
    Should I keep the setting at 2 then or is the additional edge softening normal? Because when I pause the video, there seems to be less detail than with the parameter at 2, so maybe it's not obvious during motion?
    Quote Quote  
  2. To me, the colors in the "after" looks much worse than they do in the "before."
    Quote Quote  
  3. Member
    Join Date
    May 2014
    Location
    Memphis TN, US
    Search PM
    I agree about the colors. Difficult correction because most of he problems are due to the VCR and, I assume, the local ,lighting which seems to have been artificial light -- the poor contrast and off-color output of the VCR make guessing a little rough here. Question to ask is, what's the main color imbalance (crippled blue comes to mind). The original is too yellow and the correction is too red).

    Did you notice the crooked borders? A lot of the noise is from the VCR, which apparently has no line tbc. It's more obvious in the right border, which is crooked and notched, and it wiggles during play.




    The corrections above are basic colors only -- no denoising, no chroma or border cleanup. The corrections above were done in RGB. The best you can do in YUV is probably adding some brighter YUV offset to blue (which won't work very well in YUV, since it will discolor blacks and grays). Correcting bad color like this is a nightmare in YUV.

    One reason your script has trouble with color edges and noise is that you're using chroma cleaners, oversharp correction, awarpsharp, etc., on interlaced video. One side effect is smeared edges. What you get for output is obviously not for DVD or BluRay and not disc output for grandma, but internet, PC-only, and/or external media player. You'll have to make up your own mind about cropping and resizing. For denosiing, try looking into some of QTGMC's own chroma cleaning, since you're filtering aggressively with "slow" presets (isn't "slow" the default anyway?") and the presets clean luma only. I didn't try cleaning all that bad playback noise from the VCR. If you can get a better player you'll save yourself a lot of work.
    Last edited by LMotlow; 2nd Jun 2017 at 07:18.
    - My sister Ann's brother
    Quote Quote  
  4. Member
    Join Date
    May 2014
    Location
    Memphis TN, US
    Search PM
    I borrowed your original script, but changed some of the logic and replaced a couple of things. I broke processing into 2 steps -- if you have a slow PC (like mine) running QTGMC and stuff like MDeghrain2 in the same script slows things to a crawl wit memory swapping. I also made two version, one that has cleaned-up borders and one that resizes to 640x480. I don't know why people do this, because filling the frame that way means TV overscan will cut off 15% of the image anyway (yes, modern TVs have overscan enabled by default, despite what the crowd at BestBuy tells you).

    There's still some tape noise remnants and shimmer. There are ways to get rid of more of it, but they would also get rid of more of your video. The best fix would be a better VCR, or one in better shape with a working line tbc or pass-thru. So much camera twitter and motion requires a higher bitrate, while inferior playback makes it look worse than it should. The video is darker at the end than at the start -- your camera's AGC lowered gamma when zooming back. You can make the end brighter, or vice versa, choose your poison. I tried for a compromise between the two.

    Two VirtualDub filters were used for color correction. I'm attaching a VirtualDub .vcf file that loads the settings used and those two filters, which are gradation curves (curves.vdf) and ColorMill.vdf.

    I hope some of the script ideas prove useful. It uses a YUY2-compati8ble version of QTGMC for Avisynth 2.6. You can find it here: http://avisynth.nl/index.php/QTGMC. Otherwise you have to convert beforehand to YV12.

    Step 1:
    Code:
    # ================== QTGMC for AVS26 & YUY2 ==================
    Qpath="D:\Avisynth 2.5\plugins\AVS26\QTGMC\"   #<- change the plugin path for your system
    Import(Qpath+"qtgmc_333s_for_avs_260.avs")
    LoadPlugin(Qpath+"avstp.dll")
    LoadPlugin(Qpath+"dfttest.dll")
    LoadPlugin(Qpath+"RgTools.dll")
    LoadPlugin(Qpath+"MVTools2.dll")
    LoadPlugin(Qpath+"masktools2.dll")
    
    AviSource("sample.avi")
    AssumeTFF()
    QTGMC(preset="medium",EZDenoise=6,denoiser="dfttest",ChromaMotion=true,\
       border=true,ChromaNoise=true,DenoiseMC=true,GrainRestore=0.5)
    FixChromaBleeding()
    FixVHSOversharp(20, 18, 10)
    FixVHSOversharpL(10, 20, 10)
    
    ConvertToYV12(interlaced=false)
    SmoothLevels(16,1.0,255,16,250,chroma=200,limiter=0,tvrange=true,dither=100,protect=6)
    ChromaShift(C=2,L=-2)
    return last
    # === save as Lagarith de-interlaced YV12 for Step 2 === ##
    Step2 for 720x480i:
    Code:
    AviSource("Flower_Step1.avi")
    chubbyrain2(th=1, radius=15) # remove moire rainbows
    
      source=last
    
      super = source.MSuper(pel=2, sharp=1)
      backward_vec2 = MAnalyse(super, isb = true, delta = 2, blksize=8, overlap=4, dct=0)
      backward_vec1 = MAnalyse(super, isb = true, delta = 1, blksize=8, overlap=4, dct=0)
      forward_vec1 = MAnalyse(super, isb = false, delta = 1, blksize=8, overlap=4, dct=0)
      forward_vec2 = MAnalyse(super, isb = false, delta = 2, blksize=8, overlap=4, dct=0)
      MDegrain2(source,super, backward_vec1,forward_vec1,backward_vec2,forward_vec2,thSAD=400) 
    
    TemporalSoften(4,4,8,15,2)
    MergeChroma(aWarpSharp2(depth=20))  # Tighten edge colors
    LSFMod()
    AddGrainC(2.0, 2.0)
    Crop(4,4,-24,-14).AddBorders(14,8,14,10)
    SeparateFields().SelectEvery(4,0,3).Weave()
    
    ### === for Virtualdub filters === ###
    ConverttoRGB32(interlaced=true,matrix="Rec601")
    return last
    Step 2 for 640x480i:
    Code:
    AviSource("Step1.avi")
    chubbyrain2(th=1, radius=15) # remove moire rainbows
    
      source=last
    
      super = source.MSuper(pel=2, sharp=1)
      backward_vec2 = MAnalyse(super, isb = true, delta = 2, blksize=8, overlap=4, dct=0)
      backward_vec1 = MAnalyse(super, isb = true, delta = 1, blksize=8, overlap=4, dct=0)
      forward_vec1 = MAnalyse(super, isb = false, delta = 1, blksize=8, overlap=4, dct=0)
      forward_vec2 = MAnalyse(super, isb = false, delta = 2, blksize=8, overlap=4, dct=0)
      MDegrain2(source,super, backward_vec1,forward_vec1,backward_vec2,forward_vec2,thSAD=400) 
    
    TemporalSoften(4,4,8,15,2)
    Crop(4,4,-24,-14)
    Spline36Resize(640,480)
    MergeChroma(aWarpSharp2(depth=20))  # Tighten edge colors
    LSFMod()
    AddGrainC(2.0, 2.0)
    SeparateFields().SelectEvery(4,0,3).Weave()
    
    ### === for Virtualdub filters === ###
    ConverttoRGB32(interlaced=true,matrix="Rec601")
    return last
    Image Attached Files
    Last edited by LMotlow; 2nd Jun 2017 at 15:49. Reason: correct aWarpSharp2 script entries
    - My sister Ann's brother
    Quote Quote  
  5. That sample may have been a poor choice on my part, since the original lighting seems to not have been natural. Here is a before/after of another still, this time illuminated with natural lighting:

    Before:



    After:




    For reference, here's a photo I took of the same object, facing a window:

    https://files.videohelp.com/u/199049/rsz_high-res.jpg

    I removed the slight hue adjustment in the script, in the tweak() line, since the image was too red.

    How should I order the filters? The only filter that occurs before deinterlacing that doesn't work on each field or scanline, is aWarpSharp2, which I use to fix some of the chroma bleed. But if I move that to after the deinterlace, it makes the bleed even worse.
    Last edited by ballsoup; 2nd Jun 2017 at 16:00.
    Quote Quote  
  6. Thank you for the script, LMotlow. I just finished writing my previous post and didn't refresh the page, so I just saw your post. I will take a took at the script.
    Quote Quote  



Similar Threads

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