Advertisement
Guest User

Untitled

a guest
Jul 11th, 2024
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.13 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/DeinterlaceFilter/TIVTC/libtivtc.dll")
  15. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/MiscFilter/MiscFilters/MiscFilters.dll")
  16. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/GrainFilter/AddGrain/AddGrain.dll")
  17. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DenoiseFilter/NEO_FFT3DFilter/neo-fft3d.dll")
  18. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DenoiseFilter/DFTTest/DFTTest.dll")
  19. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/EEDI3m_opencl.dll")# DeinterlaceFilter-Selector
  20. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/ResizeFilter/nnedi3/NNEDI3CL.dll")
  21. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/GrainFilter/RemoveGrain/RemoveGrainVS.dll")
  22. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/libmvtools.dll")
  23. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/scenechange.dll")
  24. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/fmtconv.dll")
  25. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/SourceFilter/DGDecNV/DGDecodeNV.dll")
  26. # Import scripts
  27. import edi_rpow2
  28. import havsfunc
  29. import validate
  30. # Source: 'C:\Users\Selur\Desktop\S01E02.m2v'
  31. # Current color space: YUV420P8, bit depth: 8, resolution: 720x480, frame rate: 29.97fps, scanorder: telecine, yuv luminance scale: limited, matrix: 470bg
  32. # Loading C:\Users\Selur\Desktop\S01E02.m2v using DGSource
  33. clip = core.dgdecodenv.DGSource("J:/tmp/m2v_99a799e941bc5bc853296548b02b2beb_853323747.dgi",fieldop=0)# 29.97 fps, scanorder: telecine
  34. frame = clip.get_frame(0)
  35. # Setting detected color matrix (470bg).
  36. clip = core.std.SetFrameProps(clip=clip, _Matrix=5)
  37. # setting color transfer (170), if it is not set.
  38. if validate.transferIsInvalid(clip):
  39. clip = core.std.SetFrameProps(clip=clip, _Transfer=6)
  40. # setting color primaries info (to 470), if it is not set.
  41. if validate.primariesIsInvalid(clip):
  42. clip = core.std.SetFrameProps(clip=clip, _Primaries=5)
  43. # setting color range to TV (limited) range.
  44. clip = core.std.SetFrameProps(clip=clip, _ColorRange=1)
  45. # making sure frame rate is set to 29.97fps
  46. clip = core.std.AssumeFPS(clip=clip, fpsnum=30000, fpsden=1001)
  47. # making sure the detected scan type is set (detected: telecine)
  48. clip = core.std.SetFrameProps(clip=clip, _FieldBased=2) # tff
  49. clip2clip = clip
  50. clip2clip = havsfunc.QTGMC(Input=clip2clip, Preset="fast", opencl=True, TFF=False, FPSDivisor=2)
  51. # Deinterlacing using TIVTC
  52. clip = core.tivtc.TFM(clip=clip, clip2=clip2clip)
  53. clip = core.tivtc.TDecimate(clip=clip)# new fps: 23.976
  54. # Making sure content is preceived as frame based
  55. clip = core.std.SetFrameProps(clip=clip, _FieldBased=0) # progressive
  56. clip = core.std.CropRel(clip=clip, left=8, right=8, top=0, bottom=0)# cropping to 704x480
  57. # adjusting color space from YUV420P8 to RGBH for vsBasicVSRPPFilter
  58. clip = core.resize.Bicubic(clip=clip, format=vs.RGBH, matrix_in_s="470bg", range_s="limited")
  59. # Quality enhancement using BasicVSR++
  60. from vsbasicvsrpp import basicvsrpp as BasicVSRPP
  61. clip = BasicVSRPP(clip=clip, model=4)
  62. # adjusting color space from RGBH to RGB48 for NNEDI3(CL)
  63. clip = core.resize.Bicubic(clip=clip, format=vs.RGB48, range_s="limited")
  64. # resizing using NNEDI3CL
  65. # current: 704x480 target: 1408x1080 -> pow: 4
  66. clip = edi_rpow2.nnedi3cl_rpow2(clip=clip, rfactor=4, nsize=3, nns=4) # 2816x1920
  67. # adjusting resizing
  68. clip = core.fmtc.resample(clip=clip, w=1408, h=1080, kernel="spline64", interlaced=False, interlacedd=False)# before RGB48 after RGB48
  69. # adjusting output color from: RGB48 to YUV420P10 for NVEncModel
  70. clip = core.resize.Bicubic(clip=clip, format=vs.YUV420P10, matrix_s="470bg", range_s="limited", dither_type="error_diffusion")
  71. # set output frame rate to 23.976fps (progressive)
  72. clip = core.std.AssumeFPS(clip=clip, fpsnum=24000, fpsden=1001)
  73. # output
  74. clip.set_output()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement