Advertisement
Guest User

Untitled

a guest
Feb 2nd, 2024
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.97 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/DenoiseFilter/CTMF/CTMF.dll")
  16. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/libmvtools_sf_em64t.dll")
  17. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/TCanny.dll")
  18. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/GrainFilter/RemoveGrain/RemoveGrainVS.dll")
  19. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/GrainFilter/AddGrain/AddGrain.dll")
  20. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DenoiseFilter/DFTTest/DFTTest.dll")
  21. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DenoiseFilter/NEO_FFT3DFilter/neo-fft3d.dll")
  22. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/EEDI3m_opencl.dll")
  23. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/ResizeFilter/nnedi3/NNEDI3CL.dll")
  24. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/libmvtools.dll")
  25. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/scenechange.dll")
  26. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/fmtconv.dll")
  27. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/MiscFilter/MiscFilters/MiscFilters.dll")
  28. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DeinterlaceFilter/Bwdif/Bwdif.dll")
  29. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/SourceFilter/LSmashSource/vslsmashsource.dll")
  30. # Import scripts
  31. import G41Fun
  32. import autowhite
  33. import havsfunc
  34. # source: 'C:\Users\Selur\Desktop\amarec(20230304-1521)_clip_no_audio 1.avi'
  35. # current color space: YUV422P8, bit depth: 8, resolution: 720x480, fps: 29.97, scanorder: top field first, yuv luminance scale: limited, matrix: 470bg
  36. # Loading C:\Users\Selur\Desktop\amarec(20230304-1521)_clip_no_audio 1.avi using LWLibavSource
  37. clip = core.lsmas.LWLibavSource(source="C:/Users/Selur/Desktop/amarec(20230304-1521)_clip_no_audio 1.avi", format="YUV422P8", stream_index=0, cache=0, prefer_hw=0)
  38. frame = clip.get_frame(0)
  39. # Setting detected color matrix (470bg).
  40. clip = core.std.SetFrameProps(clip, _Matrix=5)
  41. # Setting color transfer (170), if it is not set.
  42. if '_Transfer' not in frame.props or not frame.props['_Transfer']:
  43. clip = core.std.SetFrameProps(clip, _Transfer=6)
  44. # Setting color primaries info (to 470), if it is not set.
  45. if '_Primaries' not in frame.props or not frame.props['_Primaries']:
  46. clip = core.std.SetFrameProps(clip, _Primaries=5)
  47. # Setting color range to TV (limited) range.
  48. clip = core.std.SetFrameProp(clip=clip, prop="_ColorRange", intval=1)
  49. # making sure frame rate is set to 29.97
  50. clip = core.std.AssumeFPS(clip=clip, fpsnum=30000, fpsden=1001)
  51. clip = core.std.SetFrameProp(clip=clip, prop="_FieldBased", intval=2) # tff
  52. # Deinterlacing using QTGMC
  53. clip = havsfunc.QTGMC(Input=clip, Preset="Fast", TFF=True, opencl=True) # new fps: 59.94
  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 YUV422P8 to RGB24 for vsAutoWhite
  57. clip = core.resize.Bicubic(clip=clip, format=vs.RGB24, matrix_in_s="470bg", range_s="limited")
  58. # adjustint colors using AutoWhite
  59. clip = autowhite.AutoWhite(clip=clip)
  60. # adjusting color space from RGB24 to YUV444P16 for vsTemporalDegrain2
  61. clip = core.resize.Bicubic(clip=clip, format=vs.YUV444P16, matrix_s="470bg", range_s="limited")
  62. # removing grain using TemporalDegrain2
  63. clip = G41Fun.TemporalDegrain2(clip=clip, degrainPlane=4, meAlgPar=False, postFFT=0, fftThreads=1)
  64. from vsscunet import scunet as SCUNet
  65. # adjusting color space from YUV444P16 to RGBS for vsSCUNet
  66. clip = core.resize.Bicubic(clip=clip, format=vs.RGBS, matrix_in_s="470bg", range_s="limited")
  67. # denoising using SCUNet
  68. clip = SCUNet(clip=clip, model=4, cuda_graphs=True)
  69. # changing range from limited to full range
  70. clip = core.resize.Bicubic(clip, range_in_s="limited", range_s="full")
  71. # adjusting color space from RGBS to RGB24 for vsCodeFormer
  72. clip = core.resize.Bicubic(clip=clip, format=vs.RGB24, range_s="full", dither_type="error_diffusion")
  73. # Blind Face Restoration using CodeFormer
  74. from vscodeformer import codeformer as CodeFormer
  75. clip = CodeFormer(clip=clip, upscale=1, weight=1.000) # 720x480
  76. # changing range from full to limited range
  77. clip = core.resize.Bicubic(clip, range_in_s="full", range_s="limited")
  78.  
  79. # no resizing since resolution is already archived
  80. # adjusting output color from: RGB24 to YUV420P10 for NVEncModel
  81. clip = core.resize.Bicubic(clip=clip, format=vs.YUV420P10, matrix_s="470bg", range_s="limited")
  82. # set output frame rate to 59.94fps (progressive)
  83. clip = core.std.AssumeFPS(clip=clip, fpsnum=60000, fpsden=1001)
  84. # Output
  85. clip.set_output()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement