SHARE
TWEET

Untitled

a guest Dec 28th, 2012 112 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #TemporalSoften2 wrapper module
  2.  
  3. '''
  4. put this python script into Python3.x/Lib/site_package as temporalsoften2.py
  5.  
  6. usage:
  7.  
  8.  
  9. from temporalsoften2 import Temporalsoften
  10. core.std.LoadPlugin('/path/to/scenechange.dll')
  11. core.std.LoadPlugin('/path/to/temporalsoften2.dll')
  12. clip = something
  13. clip = TemporalSoften(core).soften(clip, luma_threshold=4, ...)
  14. '''
  15.  
  16. import vapoursynth as vs
  17.  
  18. class TemporalSoften(object):
  19.     def __init__(self, core):
  20.         self.modframe = core.std.ModifyFrame
  21.         self.resize = core.resize.Point
  22.         self.detect = core.scd.Detect
  23.         self.tsoften = core.focus2.TemporalSoften2
  24.  
  25.     def set_props(self, n, f):
  26.         fout = f[0].copy()
  27.         fout.props._SceneChangePrev = f[1].props._SceneChangePrev
  28.         fout.props._SceneChangeNext = f[1].props._SceneChangeNext
  29.         return fout
  30.  
  31.     def set_scenechange(self, clip, threshold=15, log=None):
  32.         sc = clip
  33.         cf = clip.format.color_family
  34.         if cf == vs.RGB:
  35.             sc = self.resize(format=vs.GRAY8)
  36.         sc = self.detect(sc, threshold)
  37.         if cf == vs.RGB:
  38.             sc = self.modframe([clip, sc], self.set_props)
  39.         return sc
  40.  
  41.     def soften(self, clip, radius=4, luma_threshold=4, chroma_threshold=8,
  42.                 scenechange=15, mode=None, log=None):
  43.         if scenechange:
  44.             clip = self.set_scenechange(clip, scenechange)
  45.  
  46.         return self.tsoften(clip, radius, luma_threshold, chroma_threshold,
  47.                              scenechange)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top