Guest User

Untitled

a guest
Apr 22nd, 2025
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.68 KB | None | 0 0
  1. # Imports
  2. import vapoursynth as vs
  3. # getting Vapoursynth core
  4. import sys
  5. import os
  6. core = vs.core
  7. # Import scripts folder
  8. scriptPath = 'F:/Hybrid/64bit/vsscripts'
  9. sys.path.insert(0, os.path.abspath(scriptPath))
  10. # loading plugins
  11. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DenoiseFilter/Cnr2/libcnr2.dll")
  12. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/SharpenFilter/MSmooth/libmsmoosh.dll")
  13. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/temporalsoften.dll")
  14. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/MiscFilter/MiscFilters/MiscFilters.dll")
  15. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DenoiseFilter/ZSmooth/zsmooth.dll")
  16. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/libmvtools.dll")
  17. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/SourceFilter/DGDecNV/DGDecodeNV.dll")
  18. # Import scripts
  19. import vsdeoldify as havc
  20. import fromDoom9
  21. import SpotLess
  22. import validate
  23. # Source: 'C:\Users\Selur\Desktop\videoplayback.mp4'
  24. # Current color space: YUV420P8, bit depth: 8, resolution: 320x240, frame rate: 30fps, scanorder: progressive, yuv luminance scale: limited, matrix: 709, transfer: bt.709, primaries: bt.709, format: AVC
  25. # Loading C:\Users\Selur\Desktop\videoplayback.mp4 using DGSource
  26. clip = core.dgdecodenv.DGSource("J:/tmp/mp4_f86918b1894211a32e040f0a408a05a1_853323747.dgi")# 30 fps, scanorder: progressive
  27. frame = clip.get_frame(0)
  28. # setting color matrix to 709.
  29. clip = core.std.SetFrameProps(clip, _Matrix=vs.MATRIX_BT709)
  30. # setting color transfer (vs.TRANSFER_BT709), if it is not set.
  31. if validate.transferIsInvalid(clip):
  32. clip = core.std.SetFrameProps(clip=clip, _Transfer=vs.TRANSFER_BT709)
  33. # setting color primaries info (to vs.PRIMARIES_BT470_BG), if it is not set.
  34. if validate.primariesIsInvalid(clip):
  35. clip = core.std.SetFrameProps(clip=clip, _Primaries=vs.PRIMARIES_BT470_BG)
  36. # setting color range to TV (limited) range.
  37. clip = core.std.SetFrameProps(clip=clip, _ColorRange=vs.RANGE_LIMITED)
  38. # making sure frame rate is set to 30fps
  39. clip = core.std.AssumeFPS(clip=clip, fpsnum=30, fpsden=1)
  40. # making sure the detected scan type is set (detected: progressive)
  41. clip = core.std.SetFrameProps(clip=clip, _FieldBased=vs.FIELD_PROGRESSIVE) # progressive
  42. # cutting from frame 5700 to 6599 - WARNING: This might cause synch issues
  43. clip = core.std.Trim(clip=clip, first=5700, last=6599)
  44. # adjusting color space from YUV420P8 to RGB24 for vsLevels
  45. clip = core.resize.Bicubic(clip=clip, format=vs.RGB24, matrix_in_s="709", range_s="limited")
  46. # adjusting color using Levels on RGB24 (8 bit)
  47. clip = core.std.Levels(clip=clip, min_in=16, max_in=255, min_out=16, max_out=235, gamma=0.80)
  48. # adjusting color space from RGB24 to YUV444P16 for vsSpotLess
  49. clip = core.resize.Bicubic(clip=clip, format=vs.YUV444P16, matrix_s="709", range_s="limited")
  50. # Spot removal using SpotLess
  51. clip = SpotLess.SpotLess(clip=clip, radT=3, rec=True, pel=1, smoother="zsmooth")
  52. # adjusting color space from YUV444P16 to YUV444P8 for vsSDeflicker
  53. clip = core.resize.Bicubic(clip=clip, format=vs.YUV444P8, range_s="limited", dither_type="error_diffusion")
  54. # removing flickering using Small Deflicker
  55. clip = fromDoom9.Small_Deflicker(clip=clip, preset=3, cnr=True)
  56. clip = core.std.Crop(clip=clip, left=6, right=0, top=12, bottom=12)# cropping to 314x216
  57. clip = core.std.AddBorders(clip=clip, left=3, right=3, top=0, bottom=0) # add borders to archive mod 8 (vsBasicVSRPPFilter) - 320x216
  58. # adjusting color space from YUV444P8 to RGBH for vsBasicVSRPPFilter
  59. clip = core.resize.Bicubic(clip=clip, format=vs.RGBH, matrix_in_s="709", range_s="limited")
  60. # Quality enhancement using BasicVSR++
  61. from vsbasicvsrpp import basicvsrpp as BasicVSRPP
  62. clip = BasicVSRPP(clip=clip, model=4)
  63. clip = core.std.Crop(clip=clip, left=3, right=3, top=0, bottom=0) # removing borders (vsBasicVSRPPFilter) - 314x216
  64. # changing range from limited to full range for vsHAVC
  65. clip = core.resize.Bicubic(clip, range_in_s="limited", range_s="full")
  66. # adjusting color space from RGBH to RGB24 for vsHAVC
  67. clip = core.resize.Bicubic(clip=clip, format=vs.RGB24, range_s="full", dither_type="error_diffusion")
  68. # adding colors using HAVC
  69. clip = havc.HAVC_main(clip=clip, ColorTune="strong", EnableDeepEx=True, DeepExMethod=0, DeepExRefMerge=0, ScFrameDir=None, DeepExModel=1, DeepExEncMode=0)
  70. # changing range from full to limited range for vsHAVC
  71. clip = core.resize.Bicubic(clip, range_in_s="full", range_s="limited")
  72. # adjusting output color from: RGB24 to YUV420P10 for NVEncModel
  73. clip = core.resize.Bicubic(clip=clip, format=vs.YUV420P10, matrix_s="709", range_s="limited")
  74. # set output frame rate to 30fps (progressive)
  75. clip = core.std.AssumeFPS(clip=clip, fpsnum=30, fpsden=1)
  76. # output
  77. clip.set_output()
Advertisement
Add Comment
Please, Sign In to add comment