Advertisement
Guest User

conventional filtering

a guest
Nov 30th, 2023
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.83 KB | None | 0 0
  1. # Imports
  2. import vapoursynth as vs
  3. # getting Vapoursynth core
  4. import ctypes
  5. import sys
  6. import os
  7. core = vs.core
  8. # Import scripts folder
  9. scriptPath = 'F:/Hybrid/64bit/vsscripts'
  10. sys.path.insert(0, os.path.abspath(scriptPath))
  11. # Loading Support Files
  12. Dllref = ctypes.windll.LoadLibrary("F:/Hybrid/64bit/vsfilters/Support/libfftw3f-3.dll")
  13. # Loading Plugins
  14. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DenoiseFilter/FFT3DFilter/fft3dfilter.dll")
  15. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/libmvtools_sf_em64t.dll")
  16. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/TCanny.dll")
  17. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/SharpenFilter/AWarpSharp2/libawarpsharp2.dll")
  18. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DenoiseFilter/CTMF/CTMF.dll")
  19. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/SharpenFilter/CAS/CAS.dll")
  20. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/GrainFilter/RemoveGrain/RemoveGrainVS.dll")
  21. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/GrainFilter/AddGrain/AddGrain.dll")
  22. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DenoiseFilter/DFTTest/DFTTest.dll")
  23. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DenoiseFilter/NEO_FFT3DFilter/neo-fft3d.dll")
  24. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/EEDI3m_opencl.dll")
  25. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/ResizeFilter/nnedi3/NNEDI3CL.dll")
  26. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/libmvtools.dll")
  27. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/scenechange.dll")
  28. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/fmtconv.dll")
  29. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/MiscFilter/MiscFilters/MiscFilters.dll")
  30. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DeinterlaceFilter/Bwdif/Bwdif.dll")
  31. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/SourceFilter/DGDecNV/DGDecodeNV.dll")
  32. # Import scripts
  33. import edi_rpow2
  34. import G41Fun
  35. import havsfunc
  36. # source: 'C:\Users\Selur\Desktop\Yanni - Tribute (1997 DVD-9 720 x480)__00012.mkv'
  37. # current color space: YUV420P8, bit depth: 8, resolution: 720x480, fps: 29.97, color matrix: 470bg, yuv luminance scale: limited, scanorder: top field first
  38. # Loading C:\Users\Selur\Desktop\Yanni - Tribute (1997 DVD-9 720 x480)__00012.mkv using DGSource
  39. clip = core.dgdecodenv.DGSource("J:/tmp/mkv_d603b0d1a8552802aa433b7391d38442_853323747.dgi",fieldop=0)# 29.97 fps, scanorder: top field first
  40. # Setting detected color matrix (470bg).
  41. clip = core.std.SetFrameProps(clip, _Matrix=5)
  42. # Setting color transfer info (470bg), when it is not set
  43. clip = clip if not core.text.FrameProps(clip,'_Transfer') else core.std.SetFrameProps(clip, _Transfer=5)
  44. # Setting color primaries info (), when it is not set
  45. clip = clip if not core.text.FrameProps(clip,'_Primaries') else core.std.SetFrameProps(clip, _Primaries=5)
  46. # Setting color range to TV (limited) range.
  47. clip = core.std.SetFrameProp(clip=clip, prop="_ColorRange", intval=1)
  48. # making sure frame rate is set to 29.97
  49. clip = core.std.AssumeFPS(clip=clip, fpsnum=30000, fpsden=1001)
  50. clip = core.std.SetFrameProp(clip=clip, prop="_FieldBased", intval=2) # tff
  51. # Deinterlacing using QTGMC
  52. clip = havsfunc.QTGMC(Input=clip, Preset="Faster", InputType=0, TFF=True, TR2=0, SourceMatch=0, Lossless=0, opencl=True, TR0=2, TR1=2, Rep0=1, Rep1=0, Rep2=4, DCT=5, ThSCD1=300, ThSCD2=110, Sbb=0, NoiseProcess=2, GrainRestore=0.0, NoiseRestore=0.4, NoisePreset="slow", StabilizeNoise=False, NoiseTR=0, NoiseDeint="bob") # new fps: 59.94
  53. # Making sure content is preceived as frame based
  54. clip = core.std.SetFrameProp(clip=clip, prop="_FieldBased", intval=0) # progressive
  55. # ColorMatrix: adjusting color matrix from fcc to 709
  56. # adjusting luma range to 'limited' due to post clipping
  57. clip = core.resize.Bicubic(clip=clip, matrix_in_s="fcc", matrix_s="709", range_in=0, range=0)
  58. clip = core.std.CropRel(clip=clip, left=8, right=8, top=0, bottom=0)# cropping to 704x480
  59. # contrast sharpening using CAS
  60. clip = core.cas.CAS(clip=clip, sharpness=0.600)
  61. # applying dehalo using YAHR
  62. clip = havsfunc.YAHR(clip)
  63. # removing grain using TemporalDegrain2
  64. clip = G41Fun.TemporalDegrain2(clip=clip, degrainTR=3, degrainPlane=4, meAlgPar=False, postFFT=1, fftThreads=1)
  65. # resizing using NNEDI3CL
  66. # current: 704x480 target: 1584x1080 -> pow: 4
  67. clip = edi_rpow2.nnedi3cl_rpow2(clip=clip, rfactor=4, nsize=6) # 2816x1920
  68. # adjusting resizing
  69. clip = core.fmtc.resample(clip=clip, w=1584, h=1080, kernel="spline64", interlaced=False, interlacedd=False)# before YUV420P8 after YUV420P16
  70. # adjusting output color from: YUV420P16 to YUV420P10 for NVEncModel
  71. clip = core.resize.Bicubic(clip=clip, format=vs.YUV420P10, range_s="limited", dither_type="error_diffusion")
  72. # set output frame rate to 59.94fps (progressive)
  73. clip = core.std.AssumeFPS(clip=clip, fpsnum=60000, fpsden=1001)
  74. # Output
  75. clip.set_output()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement