This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

Automatically remove "black frames"
#8
Okay, here's what you can do.
  • Start Hybrid
  • load clip
  • set 'Filtering->(De-)Interlace/Telecine->Overwrite input scan type to' to 'top field first'
  • optional: enable 'Filtering->(De-)Interlace/Telecine->QTGMC Vapoursynth->Bob'.
  • go to 'Filtering->Vapoursynth->Custom->Insert Before' set it to 'FillDrops', enable the text box below it.
  • in this custom section you now enter:
    # replace a black frames with last frame that was not black
    def ReplaceBlackFrames(clip, thresh=0.1, debug=False):
      core = vs.core
      if not isinstance(clip, vs.VideoNode):
          raise ValueError('This is not a clip')
          
      def selectFunc(n, f):
        if f.props['PlaneStatsAverage'] > thresh or n == 0:
          if debug:
            return core.text.Text(clip=clip,text="Org, avg: "+str(f.props['PlaneStatsAverage']),alignment=8)
          return clip
        toReplace = n
        for i in range(n)[::-1]:
          if clip.get_frame(i).props['PlaneStatsAverage'] <= thresh:
            continue
          
          # remove current replace with frame before    
          start = core.std.Trim(clip, first=0, last=n-1)
          r = core.std.Trim(clip, first=i, last=i)
          end = core.std.Trim(clip, first=n+1)
          replaced = start + r + end
          break
        
        if debug:
           return core.text.Text(clip=replaced,text="Replaced, avg: "+str(f.props['PlaneStatsAverage']),alignment=8)
        return replaced
              
      clip = core.std.PlaneStats(clip)
      fixed = core.std.FrameEval(clip, selectFunc, prop_src=clip)
      return fixed

    clip = ReplaceBlackFrames(clip, thresh=0.1, debug=False)
    If you now look at the Vapoursynth Preview all black frames should be replaced with the last non-black frame.
  • optional: if there were no multiple black frames in a row, enable 'Filtering->Vapoursynth->Misc->FillDrops', this will then replace the duplicate with an interpolated version.

Cu Selur
Reply


Messages In This Thread
RE: Automatically remove "black frames" - by Selur - 28.05.2023, 13:59

Forum Jump:


Users browsing this thread: 3 Guest(s)