Guest User

Untitled

a guest
May 16th, 2024
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.58 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/Support/EEDI3m_opencl.dll")
  15. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/ResizeFilter/nnedi3/NNEDI3CL.dll")
  16. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/MiscFilter/MiscFilters/MiscFilters.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/NEO_FFT3DFilter/neo-fft3d.dll")
  20. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DenoiseFilter/DFTTest/DFTTest.dll")
  21. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/libmvtools.dll")
  22. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/scenechange.dll")
  23. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/fmtconv.dll")
  24. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/ColorFilter/TimeCube/vscube.dll")
  25. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DenoiseFilter/ChromaNR/chromanrcuda.dll")
  26. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/ColorFilter/Softlight/CUDA 12.4/SoftLight.dll")
  27. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/SourceFilter/LSmashSource/LSMASHSource.dll")
  28. # Import scripts
  29. import havsfunc
  30. import autowhite
  31. import validate
  32. # Source: 'C:\Users\Selur\Desktop\Sample2.avi'
  33. # Current color space: YUV422P8, bit depth: 8, resolution: 720x576, frame rate: 50fps, scanorder: progressive, yuv luminance scale: limited, matrix: 470bg
  34. # Loading C:\Users\Selur\Desktop\Sample2.avi using LWLibavSource
  35. clip = core.lsmas.LWLibavSource(source="C:/Users/Selur/Desktop/Sample2.avi", format="YUV422P8", stream_index=0, cache=0, prefer_hw=0)
  36. frame = clip.get_frame(0)
  37. # Setting detected color matrix (470bg).
  38. clip = core.std.SetFrameProps(clip=clip, _Matrix=5)
  39. # setting color transfer (170), if it is not set.
  40. if validate.transferIsInvalid(clip):
  41. clip = core.std.SetFrameProps(clip=clip, _Transfer=6)
  42. # setting color primaries info (to 470), if it is not set.
  43. if validate.primariesIsInvalid(clip):
  44. clip = core.std.SetFrameProps(clip=clip, _Primaries=5)
  45. # setting color range to TV (limited) range.
  46. clip = core.std.SetFrameProps(clip=clip, _ColorRange=1)
  47. # making sure frame rate is set to 50fps
  48. clip = core.std.AssumeFPS(clip=clip, fpsnum=50, fpsden=1)
  49. # making sure the detected scan type is set (detected: progressive)
  50. clip = core.std.SetFrameProps(clip=clip, _FieldBased=0)# progressive
  51. # adjusting color space from YUV422P8 to RGB24 for vsAutoWhite
  52. clip = core.resize.Bicubic(clip=clip, format=vs.RGB24, matrix_in_s="470bg", range_s="limited")
  53. # adjustint colors using AutoWhite
  54. clip = autowhite.AutoWhite(clip=clip)
  55. # color adjustment using SoftLight
  56. clip = core.Argaricolm.Softlight(clip, mode=6, formula=2)
  57. clip = core.std.CropRel(clip=clip, left=14, right=10, top=2, bottom=12)# cropping to 696x562
  58. # adjusting color space from RGB24 to YUV444PS for vsChromaNR
  59. clip = core.resize.Bicubic(clip=clip, format=vs.YUV444PS, matrix_s="470bg", range_s="limited")
  60. # chroma denoising using ChromaNR
  61. clip = core.chromanrcuda.CNR(clip=clip, thres=50, threy=20, threu=20, threv=20, sizew=15, sizeh=15)
  62. clipMerge = clip
  63. clipMerge = core.std.AddBorders(clip=clipMerge, left=0, right=0, top=2, bottom=4)# add borders to archive mod 8 (vsBasicVSRPPFilter) - 696x568
  64. # adjusting color space from YUV444PS to RGBH for vsBasicVSRPPFilter
  65. clipMerge = core.resize.Bicubic(clip=clipMerge, format=vs.RGBH, matrix_in_s="470bg", range_s="limited", dither_type="error_diffusion")
  66. # Quality enhancement using BasicVSR++
  67. from vsbasicvsrpp import basicvsrpp as BasicVSRPP
  68. clipMerge = BasicVSRPP(clip=clipMerge, model=4, length=50)
  69. clipMerge = core.std.CropRel(clip=clipMerge, left=0, right=0, top=2, bottom=4)# removing borders (vsBasicVSRPPFilter) - 696x562
  70. clipMerge = core.resize.Bicubic(clip=clipMerge, format=vs.YUV444P16, matrix_s="470bg", range_s="limited")
  71. clip = core.resize.Bicubic(clip=clip, format=vs.YUV444P16, range_s="limited", dither_type="error_diffusion")
  72. clip = core.std.Merge(clip,clipMerge,[0, 1, 1])# merge filtered and unfiltered by plane
  73. # adjusting color space from YUV444P16 to RGB48 for vsTimeCube
  74. clip = core.resize.Bicubic(clip=clip, format=vs.RGB48, matrix_in_s="470bg", range_s="limited")
  75. # color adjustment using TimeCube
  76. clip = core.timecube.Cube(clip=clip, cube="F:/Hybrid/64bit/vsfilters/ColorFilter/TimeCube/BT2020_HLG_BT601_PAL.cube")
  77. clip = core.std.AddBorders(clip=clip, left=0, right=0, top=0, bottom=2)# add borders to archive mod 4 (vsQTGMCFilter) - 696x564
  78. # adjusting color space from RGB48 to YUV444P16 for vsQTGMCFilter
  79. clip = core.resize.Bicubic(clip=clip, format=vs.YUV444P16, matrix_s="470bg", range_s="limited")
  80. # Denoising using QTGMC
  81. clip = havsfunc.QTGMC(Input=clip, Preset="Fast", InputType=3, TR2=1, TFF=False, SourceMatch=3, Lossless=2, opencl=True)
  82. clip = core.std.CropRel(clip=clip, left=0, right=0, top=0, bottom=2)# removing borders (vsQTGMCFilter) - 696x562
  83. # adjusting output color from: YUV444P16 to YUV420P10 for NVEncModel
  84. clip = core.resize.Bicubic(clip=clip, format=vs.YUV420P10, range_s="limited", dither_type="error_diffusion")
  85. # set output frame rate to 50fps (progressive)
  86. clip = core.std.AssumeFPS(clip=clip, fpsnum=50, fpsden=1)
  87. # output
  88. clip.set_output()
Advertisement
Add Comment
Please, Sign In to add comment