VideoHelp Forum
+ Reply to Thread
Results 1 to 10 of 10
Thread
  1. Noob
    Join Date
    Sep 2021
    Location
    New Zealand
    Search Comp PM
    "Hello lollo, I had previously sent you messages based on why I was getting some purple/green lines on my screen (SwagArmy on your youtube video). I have now fixed that issue by replacing my VCR, luckily I found an old Panasonic NV-HS950 of my grandad's just sitting around in his attic! what a find and it still works. I am using a Hauppauge USB live 2 device to capture my footage to a laragith lossless video codec and all is mostly well. What I do have a question about is, and this is because I have very little information on VHS and VCRs. I was wondering, in some videotapes that I have captured there are mostly always points where some black/white lines go across the screen, and in some tapes, there is a constant line of fuzz along with the screen. Is this due to the tape being dirty or is it because the tape is damaged? I will attach some images below and hopefully, you can answer my question. How could I fix this issue with these certain tapes and will it damage them If I try to clean them? Image
    [Attachment 61336 - Click to enlarge] - For the Colour Distortioned tape, it would appear every now and then and was worse in certain parts of the tape, I assume its just that the tape is getting older and is possibly damaged (You will know best I hope what the problem is)
    Image
    [Attachment 61337 - Click to enlarge] - These black and white lines show in most tapes that I have, they show every know and then like a flicker on the screen I think that it is due to dirt but I have no idea could you explain what is happening in this image?
    Image
    [Attachment 61338 - Click to enlarge] - This image here is from a tape where this line on the image is shown throughout most of the tape on the screen, like it is stuck there. I assume it is just a damaged section of the tape? (Awnser If you know what it is)
    Thanks for all the help I am a newbie to all this stuff so every awnser helps." (The message quoted from Lollo, in my messages.)

    Setup: Panasonic NV-HS950 - Hauppauge Usb Live2 - Amarectv. I am capturing my VHS tapes in lagarith video codec and they are PAL tapes (720x576, 25fps).

    Lollo replied and believes that my issue could be from the tapes themselves. I think that they may be either damaged or dirty. What I want to know before I try cleaning the tapes is, If I could use filters on avisynth to fix the video examples shown below. Please could someone give me information on what plugins I will need for avisynth to help get rid of the distortions in these videos. And for the best quality? At the moment I am just starting to learn how to use avisynth and have recently started turning my video from avi to mp4 and have used the QTGMC filter because I have wanted to deinterlace the videos. What I want for the end result of my videos is to either store it on a cloud like onedrive for friends and family to be able to also view the videos or upload them on youtube (not public). If their are filters(plugins?) for making the video upscaled to look better on youtube etc could someone name them? because this would be useful on top of the filters that could fix the damaged tapes. To shorten down what I want, what can I use (plugin and filter wise) to get the best restoration results from VHS videos on avisynth as well as fixing the damage on the video.

    Thanks I hope this isnt to much to ask. (side note, the videos I have attached obviously havent been edited in avisynth yet.)
    Image Attached Files
    Last edited by VideoGeezer; 26th Oct 2021 at 02:21. Reason: Fixing Files
    Quote Quote  
  2. and they are PAL tapes (720x576, 25fps).
    In that case why is the video in 30fps
    Quote Quote  
  3. Noob
    Join Date
    Sep 2021
    Location
    New Zealand
    Search Comp PM
    Originally Posted by s-mp View Post
    and they are PAL tapes (720x576, 25fps).
    In that case why is the video in 30fps
    I forgot to mention I used HandNrake to convert it from the avi file. This will be why it is in 30fps, I can just clip the original avi file and hopefully it stays at the original 25fps if you like. Thanks (SOLVED!)
    Last edited by VideoGeezer; 26th Oct 2021 at 02:14.
    Quote Quote  
  4. Captures & Restoration lollo's Avatar
    Join Date
    Jul 2018
    Location
    Italy
    Search Comp PM
    A quick and not optimized script for White Line Distortion.avi video.
    Try to tune the parameters and/or apply once more FixRipsp2 to reduce left scratches (do it only for the concerned segments).
    Some sharpening and/or addGrain() at the end may reduce a little bit the "feeling" of lost details and excessive smoothing.

    Jagabo may have better solutions

    Code:
    # interlaced fields TFF
    # problem: horizontal stripe
    # solution: repair with FixRipsp2
    
    video_org=AviSource("White Line Distortion.avi").convertToYV16(interlaced=true)
    
    # plugins directory
    plugins_dir="C:\Users\giuse\Documents\VideoSoft\MPEG\AviSynth\extFilters\"
    
    	# FixRipsp2
    Import(plugins_dir + "FixRipsp2.avs")
    	# RgTools
    loadPlugin(plugins_dir + "RgTools-v1.0\x86\RgTools.dll")
    	# DePanEstimate
    loadPlugin(plugins_dir + "depanestimate110\DePanEstimate.dll")
    	# FFTW
    loadPlugin(plugins_dir + "LoadDll\LoadDll.dll")
    loadDll(plugins_dir + "fftw3_20040130\fftw3win32mingw\fftw3.dll")
    	# DePan
    loadPlugin(plugins_dir + "depan1131\DePan.dll")
    	# MaskTools2
    loadPlugin(plugins_dir + "masktools2-v2.2.23\x86\masktools2.dll")
    	# MVTools
    loadPlugin(plugins_dir + "mvtools-2.7.41-with-depans20200430\x86\mvtools2.dll")
    
    ### separate fields
    video_org_sep=video_org.AssumeTFF().separateFields()
    
    ### select even fields
    video_org_sep_even=SelectEven(video_org_sep)
    
    ### select odd fields
    video_org_sep_odd=SelectOdd(video_org_sep)
    
    ### repair
    video_org_sep_even_rep=video_org_sep_even.FixRipsp2().FixRipsp2()
    video_org_sep_odd_rep=video_org_sep_odd.FixRipsp2().FixRipsp2()
    
    ### interleave
    video_interleaved=interleave(video_org_sep_even_rep,video_org_sep_odd_rep)
    
    ### weave
    video_restored=video_interleaved.Weave()
    
    #return(video_restored)
    
    stackhorizontal(\
    subtitle(video_org,"video_org",size=20,align=2),\
    subtitle(video_restored,"video_restored",size=20,align=2)\
    )
    Click image for larger version

Name:	2a.png
Views:	391
Size:	1.77 MB
ID:	61465

    Here the comparison video: 2a.avi

    Edit: if it is not a problem of bad tapes, check your VCR!
    Last edited by lollo; 26th Oct 2021 at 05:50.
    Quote Quote  
  5. Noob
    Join Date
    Sep 2021
    Location
    New Zealand
    Search Comp PM
    I have attached a video (for Lollo)
    Image Attached Files
    Quote Quote  
  6. Captures & Restoration lollo's Avatar
    Join Date
    Jul 2018
    Location
    Italy
    Search Comp PM
    It could be a bad or inappropriate deinterlacing (TFF instead of BFF, or whatever else), but, please, post a sample of the raw capture before filtering, so we can try to understand

    edit: post your script also
    Last edited by lollo; 31st Oct 2021 at 05:20.
    Quote Quote  
  7. Nice Does anyone have a script to do this in Vapoursynth?
    users currently on my ignore list: deadrats, Stears555
    Quote Quote  
  8. Captures & Restoration lollo's Avatar
    Join Date
    Jul 2018
    Location
    Italy
    Search Comp PM
    Don't know aobut the script itself, but all the dependencies (MaskTools, MVTools, RGTools, etc...) should be in VapourSynth.

    Here the link the script, if you wish to experiment: https://forum.videohelp.com/attachments/45745-1527397208/FixRipsP2.avs
    It is a quite destructive/last resort option.

    Some doc here:
    https://forum.videohelp.com/threads/388978-Help-with-very-old-VHS-tapecapture-differen...-possible-VCRs
    https://forum.videohelp.com/threads/343296-Transfer-of-real-bad-tape-to-pc-and-restore
    Quote Quote  
  9. Problem is as far as I can see, there is no DepanInterleave in Vapoursynth, which is where I give up for today, in case someone has the time and knowledge to get this working, here's what I got so far:
    Code:
    import vapoursynth as vs
    core = vs.core
    
    
    def FixRipsP2(c):
      c1 = core.rgvs.Clense(clip=c)
      c1 = core.std.Merge(clipa=c1, clipb=c)
      c1 = core.rgvs.Clense(clip=c1)
      mot = core.rgvs.RemoveGrain(clip=c1, mode=[11,0])
      mot = core.rgvs.RemoveGrain(clip=mot, mode=[20,0])
      mot = core.mv.DepanEstimate(clip=mot)
      
      take2 = core.mv.DepanInterleave(clip=mot, pred=2, next=2, subpixel=2)
    
      clean1 = TMedian2(take2).std.SelectEvery(5,2)
      #sup1 = minblur(clean1, 1).rgvs.removegrain(mode=[11,0)].rgvs.Removegrain(mode=[11,0])
      #supe 1 = 
     #\           .mt_lutxy(clean1,"x 1 + y < x 2 + x 1 - y > x 2 - y ? ?",U=2,V=2)
     #\           .msuper(pel=2,sharp=0)
    #sup2 = a.msuper(pel=2,levels=1,sharp=2)
    #
    #bv22=sup1.manalyse(isb=true, truemotion=false,global=true,delta=2,blksize=16,overlap=8,search=5,searchparam=4,DCT=5)
    #bv21=sup1.manalyse(isb=true, truemotion=false,global=true,delta=1,blksize=16,overlap=8,search=5,searchparam=4,DCT=5)
    #fv21=sup1.manalyse(isb=false,truemotion=false,global=true,delta=1,blksize=16,overlap=8,search=5,searchparam=4,DCT=5)
    #fv22=sup1.manalyse(isb=false,truemotion=false,global=true,delta=2,blksize=16,overlap=8,search=5,searchparam=4,DCT=5)
    #
    #interleave(a.mcompensate(sup2,fv22),a.mcompensate(sup2,fv21),a,a.mcompensate(sup2,bv21),a.mcompensate(sup2,bv22))
    #TMedian2().selectevery(5,2)
      
      
      return mot
    
    # from https://github.com/Selur/VapoursynthScriptsInHybrid/blob/3cd821559e1ead2d5ca7b9df97cdf736425666b8/havsfunc.py#L5749
    def sbr(c, r=1, planes=None):
      if not isinstance(c, vs.VideoNode):
          raise vs.Error('sbr: This is not a clip')
    
      neutral = 1 << (c.format.bits_per_sample - 1) if c.format.sample_type == vs.INTEGER else 0.0
    
      if planes is None:
          planes = list(range(c.format.num_planes))
      elif isinstance(planes, int):
          planes = [planes]
    
      matrix1 = [1, 2, 1, 2, 4, 2, 1, 2, 1]
      matrix2 = [1, 1, 1, 1, 1, 1, 1, 1, 1]
    
      if r <= 1:
          RG11 = c.std.Convolution(matrix=matrix1, planes=planes)
      elif r == 2:
          RG11 = c.std.Convolution(matrix=matrix1, planes=planes).std.Convolution(matrix=matrix2, planes=planes)
      else:
          RG11 = c.std.Convolution(matrix=matrix1, planes=planes).std.Convolution(matrix=matrix2, planes=planes).std.Convolution(matrix=matrix2, planes=planes)
    
      RG11D = core.std.MakeDiff(c, RG11, planes=planes)
    
      if r <= 1:
          RG11DS = RG11D.std.Convolution(matrix=matrix1, planes=planes)
      elif r == 2:
          RG11DS = RG11D.std.Convolution(matrix=matrix1, planes=planes).std.Convolution(matrix=matrix2, planes=planes)
      else:
          RG11DS = RG11D.std.Convolution(matrix=matrix1, planes=planes).std.Convolution(matrix=matrix2, planes=planes).std.Convolution(matrix=matrix2, planes=planes)
    
      expr = f'x y - x {neutral} - * 0 < {neutral} x y - abs x {neutral} - abs < x y - {neutral} + x ? ?'
      RG11DD = core.std.Expr([RG11D, RG11DS], expr=[expr if i in planes else '' for i in range(c.format.num_planes)])
      return core.std.MakeDiff(c, RG11DD, planes=planes)
    
    # from https://github.com/Selur/VapoursynthScriptsInHybrid/blob/3cd821559e1ead2d5ca7b9df97cdf736425666b8/havsfunc.py#L5714
    def MinBlur(clp, r=1, planes=None):
      if not isinstance(clp, vs.VideoNode):
          raise vs.Error('MinBlur: This is not a clip')
    
      if planes is None:
          planes = list(range(clp.format.num_planes))
      elif isinstance(planes, int):
          planes = [planes]
    
      matrix1 = [1, 2, 1, 2, 4, 2, 1, 2, 1]
      matrix2 = [1, 1, 1, 1, 1, 1, 1, 1, 1]
    
      if r <= 0:
          RG11 = sbr(clp, planes=planes)
          RG4 = clp.std.Median(planes=planes)
      elif r == 1:
          RG11 = clp.std.Convolution(matrix=matrix1, planes=planes)
          RG4 = clp.std.Median(planes=planes)
      elif r == 2:
          RG11 = clp.std.Convolution(matrix=matrix1, planes=planes).std.Convolution(matrix=matrix2, planes=planes)
          RG4 = clp.ctmf.CTMF(radius=2, planes=planes)
      else:
          RG11 = clp.std.Convolution(matrix=matrix1, planes=planes).std.Convolution(matrix=matrix2, planes=planes).std.Convolution(matrix=matrix2, planes=planes)
          if clp.format.bits_per_sample == 16:
              s16 = clp
              RG4 = clp.fmtc.bitdepth(bits=12, planes=planes, dmode=1).ctmf.CTMF(radius=3, planes=planes).fmtc.bitdepth(bits=16, planes=planes)
              RG4 = mvf.LimitFilter(s16, RG4, thr=0.0625, elast=2, planes=planes)
          else:
              RG4 = clp.ctmf.CTMF(radius=3, planes=planes)
    
      expr = 'x y - x z - * 0 < x x y - abs x z - abs < y z ? ?'
      return core.std.Expr([clp, RG11, RG4], expr=[expr if i in planes else '' for i in range(clp.format.num_planes)])
    
    # from https://gist.github.com/4re/bba3f65469acfe0ec08a#file-vshelpers-py-L42
    def mt_lutxy(c1, c2, expr, planes=[0]):
      max_ = 2 ** c1.format.bits_per_sample - 1
      lut_range = range(max_ + 1)
      lut = []
      for y in lut_range:
          for x in lut_range:
              lut.append(clamp(0, expr(x, y), max_))
      return core.std.Lut2(c1, c2, lut=lut, planes=planes)
    
    # based on https://github.com/darealshinji/vapoursynth-plugins/blob/614d367e826b5f6bb0af33e1f91453f3ff7999ec/scripts/dehalo_alpha.py#L40 
    def mt_logic(c1, c2, mode, th1=0, th2=0, planes=0):
      if mode == 'min':
        expr = lambda x, y: min(x + th1, y + th2)
      elif mode == 'max':
        expr = lambda x, y: max(x + th1, y + th2)
      else:
        raise InvalidArgument('%s is not a valid mode for mt_logic' % mode)
      return mt_lutxy(c1, c2, expr, planes)
    
    def Median2(c1, c2, c3, c4, c5):
      int135 = core.std.Interleave([c1, c3, c5])
      int135 = core.rgvs.Cleanse(int135)
      m1 = core.std.SelectEvery(inter135,3,1)
      m2 = mt_logic(c1, c3, "min")
      m2 = mt_logic(m2, c5, "min")
      m2 = mt_logic(m2, c2, "min")
      m3 = mt_logic(c1, c3, "min")
      m3 = mt_logic(m2, c5, "min")
      m3 = mt_logic(m2, c4, "min")
      int135 = core.std.Interleave([m1, m3, m3])
      int135 = core.rgvs.Cleanse(int135)
      return core.std.SelectEvery(inter135,3,1)
    
    def TMedian2(c):
      return Median2(core.std.SelectEvery(c,1,-2), core.std.SelectEvery(c,1,-1), c, core.std.SelectEvery(c,1,1), core.std.SelectEvery(c,1,2) )
    users currently on my ignore list: deadrats, Stears555
    Quote Quote  
  10. Captures & Restoration lollo's Avatar
    Join Date
    Jul 2018
    Location
    Italy
    Search Comp PM
    From http://avisynth.org.ru/depan/depan.html

    DePanInterleave
    It generates long interleaved clipwith series of group of previous frames motion compensated (within some range), original frame, and motion compensated next frames (within range), and same groups for every following frames. In fact, it combines DePan function and Interleave function (AviSynth internal) for easy following temporal denoising, with following SelectEvery(prev+next+1, prev) function for selecting only cleaned source frames.


    Maybe, is possible to emulate DepanInterleave with Depan (should exist in VS) + Interleave. Just my guess.
    Quote Quote  



Similar Threads

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