Guest User

Untitled

a guest
Nov 12th, 2022
306
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.95 KB | None | 0 0
  1. # Imports
  2. import vapoursynth as vs
  3. import os
  4. import ctypes
  5. # Loading Support Files
  6. Dllref = ctypes.windll.LoadLibrary("i:/Hybrid/64bit/vsfilters/Support/libfftw3f-3.dll")
  7. import sys
  8. # getting Vapoursynth core
  9. core = vs.core
  10. # Import scripts folder
  11. scriptPath = 'i:/Hybrid/64bit/vsscripts'
  12. sys.path.insert(0, os.path.abspath(scriptPath))
  13. import site
  14. # Import libraries for onnxruntime
  15. path = site.getsitepackages()[0]+'/onnxruntime_dlls/'
  16. ctypes.windll.kernel32.SetDllDirectoryW(path)
  17. # Loading Plugins
  18. core.std.LoadPlugin(path="i:/Hybrid/64bit/vsfilters/GrainFilter/RemoveGrain/RemoveGrainVS.dll")
  19. core.std.LoadPlugin(path="i:/Hybrid/64bit/vsfilters/GrainFilter/AddGrain/AddGrain.dll")
  20. core.std.LoadPlugin(path="i:/Hybrid/64bit/vsfilters/DenoiseFilter/FFT3DFilter/fft3dfilter.dll")
  21. core.std.LoadPlugin(path="i:/Hybrid/64bit/vsfilters/DenoiseFilter/DFTTest/DFTTest.dll")
  22. core.std.LoadPlugin(path="i:/Hybrid/64bit/vsfilters/Support/EEDI3m.dll")
  23. core.std.LoadPlugin(path="i:/Hybrid/64bit/vsfilters/ResizeFilter/nnedi3/NNEDI3CL.dll")
  24. core.std.LoadPlugin(path="i:/Hybrid/64bit/vsfilters/Support/libmvtools.dll")
  25. core.std.LoadPlugin(path="i:/Hybrid/64bit/vsfilters/Support/scenechange.dll")
  26. core.std.LoadPlugin(path="i:/Hybrid/64bit/vsfilters/Support/fmtconv.dll")
  27. core.std.LoadPlugin(path="i:/Hybrid/64bit/vsfilters/MiscFilter/MiscFilters/MiscFilters.dll")
  28. core.std.LoadPlugin(path="i:/Hybrid/64bit/vsfilters/DeinterlaceFilter/Bwdif/Bwdif.dll")
  29. core.std.LoadPlugin(path="i:/Hybrid/64bit/vsfilters/SourceFilter/LSmashSource/vslsmashsource.dll")
  30. # Import scripts
  31. import havsfunc
  32. # source: 'C:\Users\Selur\Desktop\Donna-Summer-2-tff.mp4'
  33. # current color space: YUV422P10, bit depth: 10, resolution: 760x488, fps: 29.97, color matrix: 709, yuv luminance scale: limited, scanorder: top field first
  34. # Loading C:\Users\Selur\Desktop\Donna-Summer-2-tff.mp4 using LibavSMASHSource
  35. clip = core.lsmas.LibavSMASHSource(source="C:/Users/Selur/Desktop/Donna-Summer-2-tff.mp4")
  36. # Setting color matrix to 709.
  37. clip = core.std.SetFrameProps(clip, _Matrix=1)
  38. clip = clip if not core.text.FrameProps(clip,'_Transfer') else core.std.SetFrameProps(clip, _Transfer=1)
  39. clip = clip if not core.text.FrameProps(clip,'_Primaries') else core.std.SetFrameProps(clip, _Primaries=5)
  40. # Setting color range to TV (limited) range.
  41. clip = core.std.SetFrameProp(clip=clip, prop="_ColorRange", intval=1)
  42. # making sure frame rate is set to 29.970
  43. clip = core.std.AssumeFPS(clip=clip, fpsnum=30000, fpsden=1001)
  44. clip = core.std.SetFrameProp(clip=clip, prop="_FieldBased", intval=2)
  45. # setting field order to what QTGMC should assume (top field first)
  46. clip = core.std.SetFrameProp(clip=clip, prop="_FieldBased", intval=2)
  47. # Deinterlacing using QTGMC
  48. clip = havsfunc.QTGMC(Input=clip, Preset="Fast", TFF=True, opencl=True) # new fps: 59.94
  49. # make sure content is preceived as frame based
  50. clip = core.std.SetFieldBased(clip, 0)
  51. # cropping the video to 742x482
  52. clip = core.std.CropRel(clip=clip, left=10, right=8, top=4, bottom=2)
  53. from vsrealesrgan import RealESRGAN
  54. clip = core.std.AddBorders(clip=clip, left=0, right=2, top=0, bottom=2) # add borders to archive mod 4 (VsRealESRGAN) - 744x484
  55. # adjusting color space from YUV422P10 to RGBS for VsRealESRGAN
  56. clip = core.resize.Bicubic(clip=clip, format=vs.RGBS, matrix_in_s="709", range_s="limited")
  57. # resizing using RealESRGAN
  58. clip = RealESRGAN(clip=clip, model=0, provider=1, device_id=0) # 1488x968
  59. # resizing 1488x968 to 884x488
  60. clip = core.std.CropRel(clip=clip, left=0, right=4, top=0, bottom=4) # removing borders (VsRealESRGAN) - 1484x964
  61. # adjusting resizing
  62. clip = core.fmtc.resample(clip=clip, w=884, h=488, kernel="lanczos", interlaced=False, interlacedd=False)
  63. # adjusting output color from: RGBS to YUV422P10 for x265Model
  64. clip = core.resize.Bicubic(clip=clip, format=vs.YUV422P10, matrix_s="709", range_s="limited", dither_type="none")
  65. # set output frame rate to 59.94fps
  66. clip = core.std.AssumeFPS(clip=clip, fpsnum=60000, fpsden=1001)
  67. # Output
  68. clip.set_output()
Advertisement
Add Comment
Please, Sign In to add comment