Guest User

Untitled

a guest
Apr 26th, 2024
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.04 KB | None | 0 0
  1. # Imports
  2. import vapoursynth as vs
  3. # getting Vapoursynth core
  4. import site
  5. import ctypes
  6. import sys
  7. import os
  8. core = vs.core
  9. # Import scripts folder
  10. scriptPath = 'F:/Hybrid/64bit/vsscripts'
  11. sys.path.insert(0, os.path.abspath(scriptPath))
  12. # Loading Support Files
  13. Dllref = ctypes.windll.LoadLibrary("F:/Hybrid/64bit/vsfilters/Support/libfftw3f-3.dll")
  14. os.environ["CUDA_MODULE_LOADING"] = "LAZY"
  15. # loading plugins
  16. core.std.LoadPlugin(path="F:/Hybrid/64bit/vs-mlrt/vstrt.dll")
  17. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/GrainFilter/RemoveGrain/RemoveGrainVS.dll")
  18. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/GrainFilter/AddGrain/AddGrain.dll")
  19. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DenoiseFilter/DFTTest/DFTTest.dll")
  20. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DenoiseFilter/NEO_FFT3DFilter/neo-fft3d.dll")
  21. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/EEDI3m_opencl.dll")
  22. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/ResizeFilter/nnedi3/NNEDI3CL.dll")
  23. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/libmvtools.dll")
  24. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/scenechange.dll")
  25. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/fmtconv.dll")
  26. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/MiscFilter/MiscFilters/MiscFilters.dll")
  27. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DeinterlaceFilter/Bwdif/Bwdif.dll")
  28. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/SourceFilter/DGDecNV/DGDecodeNV.dll")
  29. # Import scripts
  30. from importlib.machinery import SourceFileLoader
  31. vsmlrt = SourceFileLoader('vsmlrt', 'F:/Hybrid/64bit/vs-mlrt/vsmlrt.py').load_module()
  32. import havsfunc
  33. # Source: 'C:\Users\Selur\Desktop\Gambala cut2.mpg'
  34. # Current color space: YUV420P8, bit depth: 8, resolution: 720x576, frame rate: 25fps, scanorder: bottom field first, yuv luminance scale: limited, matrix: 470bg, transfer: bt.470 system b/g, primaries: bt.601 pal
  35. # Loading C:\Users\Selur\Desktop\Gambala cut2.mpg using DGSource
  36. clip = core.dgdecodenv.DGSource("J:/tmp/mpg_1132d3cb06bc3c5d1a40f66ad9af7b60_853323747.dgi",fieldop=0)# 25 fps, scanorder: bottom field first
  37. frame = clip.get_frame(0)
  38. # Setting detected color matrix (470bg).
  39. clip = core.std.SetFrameProps(clip, _Matrix=5)
  40. # setting color transfer (601), if it is not set.
  41. if '_Transfer' not in frame.props or not frame.props['_Transfer']:
  42. clip = core.std.SetFrameProps(clip, _Transfer=5)
  43. # setting color primaries info (to 470), if it is not set.
  44. if '_Primaries' not in frame.props or not frame.props['_Primaries']:
  45. clip = 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 25fps
  49. clip = core.std.AssumeFPS(clip=clip, fpsnum=25, fpsden=1)
  50. # making sure the detected scan type is set
  51. clip = core.std.SetFrameProp(clip=clip, prop="_FieldBased", intval=1) # bff
  52. # Deinterlacing using QTGMC
  53. clip = havsfunc.QTGMC(Input=clip, Preset="Fast", TFF=False, opencl=True) # new fps: 50
  54. # Making sure content is preceived as frame based
  55. clip = core.std.SetFrameProp(clip=clip, prop="_FieldBased", intval=0) # progressive
  56. # adjusting color space from YUV420P8 to RGBH for vsBasicVSRPPFilter
  57. clip = core.resize.Bicubic(clip=clip, format=vs.RGBH, matrix_in_s="470bg", range_s="limited")
  58. # Quality enhancement using BasicVSR++
  59. from vsbasicvsrpp import basicvsrpp as BasicVSRPP
  60. clip = BasicVSRPP(clip=clip, model=5)
  61. from vsmlrt import Backend
  62. # denosing using DPIR (mlrt)
  63. clip = vsmlrt.DPIR(clip, strength=5.000, overlap=16, model=1, backend=Backend.TRT(fp16=True,device_id=0,verbose=True,use_cuda_graph=False, num_streams=3,builder_optimization_level=3,engine_folder="J:/tmp"))
  64. # adjusting output color from: RGBH to YUV420P10 for NVEncModel
  65. clip = core.resize.Bicubic(clip=clip, format=vs.YUV420P10, matrix_s="470bg", range_s="limited", dither_type="error_diffusion")
  66. # set output frame rate to 50fps (progressive)
  67. clip = core.std.AssumeFPS(clip=clip, fpsnum=50, fpsden=1)
  68. # output
  69. clip.set_output()
Advertisement
Add Comment
Please, Sign In to add comment