Advertisement
Guest User

sRestore+QTGMC+BasicVSR++

a guest
Feb 17th, 2025
26
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.62 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/fmtconv.dll")
  23. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/SourceFilter/DGDecNV/DGDecodeNV.dll")
  24. # Import scripts
  25. import havsfunc
  26. import muvsfunc
  27. import validate
  28. # Source: 'C:\Users\Selur\Desktop\test.mkv'
  29. # Current color space: YUV420P8, bit depth: 8, resolution: 1216x684, frame rate: 30fps, scanorder: progressive, yuv luminance scale: limited, matrix: 709, format: AVC
  30. # Loading C:\Users\Selur\Desktop\test.mkv using DGSource
  31. clip = core.dgdecodenv.DGSource("J:/tmp/mkv_aaf47d044f0319abfb06280a337316d9_853323747.dgi")# 30 fps, scanorder: progressive
  32. frame = clip.get_frame(0)
  33. # setting color matrix to 709.
  34. clip = core.std.SetFrameProps(clip, _Matrix=vs.MATRIX_BT709)
  35. # setting color transfer (vs.TRANSFER_BT709), if it is not set.
  36. if validate.transferIsInvalid(clip):
  37. clip = core.std.SetFrameProps(clip=clip, _Transfer=vs.TRANSFER_BT709)
  38. # setting color primaries info (to vs.PRIMARIES_BT709), if it is not set.
  39. if validate.primariesIsInvalid(clip):
  40. clip = core.std.SetFrameProps(clip=clip, _Primaries=vs.PRIMARIES_BT709)
  41. # setting color range to TV (limited) range.
  42. clip = core.std.SetFrameProps(clip=clip, _ColorRange=vs.RANGE_LIMITED)
  43. # making sure frame rate is set to 30fps
  44. clip = core.std.AssumeFPS(clip=clip, fpsnum=30, fpsden=1)
  45. # making sure the detected scan type is set (detected: progressive)
  46. clip = core.std.SetFrameProps(clip=clip, _FieldBased=vs.FIELD_PROGRESSIVE) # progressive
  47. # adjusting frame count and rate with sRestore
  48. clip = muvsfunc.srestore(source=clip, frate=23.9760)
  49. # Denoising using QTGMC
  50. clip = havsfunc.QTGMC(Input=clip, Preset="Fast", InputType=3, TR2=1, TFF=False, SourceMatch=0, Lossless=0, opencl=True)
  51. clip = core.std.AddBorders(clip=clip, left=0, right=0, top=2, bottom=2) # add borders to archive mod 8 (vsBasicVSRPPFilter) - 1216x688
  52. # adjusting color space from YUV420P8 to RGBH for vsBasicVSRPPFilter
  53. clip = core.resize.Bicubic(clip=clip, format=vs.RGBH, matrix_in_s="709", range_s="limited")
  54. # Quality enhancement using BasicVSR++
  55. from vsbasicvsrpp import basicvsrpp as BasicVSRPP
  56. clip = BasicVSRPP(clip=clip, model=4)
  57. clip = core.std.Crop(clip=clip, left=0, right=0, top=2, bottom=2) # removing borders (vsBasicVSRPPFilter) - 1216x684
  58. # adjusting output color from: RGBH to YUV420P10 for NVEncModel
  59. clip = core.resize.Bicubic(clip=clip, format=vs.YUV420P10, matrix_s="709", range_s="limited", dither_type="error_diffusion")
  60. # set output frame rate to 23.976fps (progressive)
  61. clip = core.std.AssumeFPS(clip=clip, fpsnum=24000, fpsden=1001)
  62. # output
  63. clip.set_output()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement