Guest User

Untitled

a guest
Dec 29th, 2025
9
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.65 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. # Limit frame cache to 48449MB
  8. core.max_cache_size = 48449
  9. # Import scripts folder
  10. scriptPath = 'F:/Hybrid/64bit/vsscripts'
  11. sys.path.insert(0, os.path.abspath(scriptPath))
  12. # loading plugins
  13. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/libvs_placebo.dll")
  14. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/ResizeFilter/nnedi3/NNEDI3CL.dll")
  15. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/SharpenFilter/AWarpSharp2/libawarpsharp2.dll")
  16. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DenoiseFilter/CTMF/CTMF.dll")
  17. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/fmtconv.dll")
  18. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/akarin.dll")
  19. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DenoiseFilter/ZSmooth/zsmooth.dll")
  20. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DeinterlaceFilter/TIVTC/libtivtc.dll")
  21. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/SourceFilter/DGDecNV/DGDecodeNV_AVX2.dll")
  22. # Import scripts
  23. import edi_rpow2
  24. import dehalo
  25. import validate
  26. # Source: 'C:\Users\Selur\Desktop\05.mp4'
  27. # Current color space: YUV420P8, bit depth: 8, resolution: 720x480, frame rate: 29.97fps, scanorder: progressive, yuv luminance scale: limited, matrix: 470bg, format: mpeg-2
  28. # Loading 'C:\Users\Selur\Desktop\05.mp4' using DGSource
  29. clip = core.dgdecodenv.DGSource("J:/tmp/mp4_293d961aef361edabdd092b5aebdf51e_853323747.dgi") # 29.97 fps, scanorder: progressive
  30. frame = clip.get_frame(0)
  31. # setting color matrix to 470bg.
  32. clip = core.std.SetFrameProps(clip, _Matrix=vs.MATRIX_BT470_BG)
  33. # setting color transfer (vs.TRANSFER_BT601), if it is not set.
  34. if validate.transferIsInvalid(clip):
  35. clip = core.std.SetFrameProps(clip=clip, _Transfer=vs.TRANSFER_BT601)
  36. # setting color primaries info (to vs.PRIMARIES_BT470_BG), if it is not set.
  37. if validate.primariesIsInvalid(clip):
  38. clip = core.std.SetFrameProps(clip=clip, _Primaries=vs.PRIMARIES_BT470_BG)
  39. # setting color range to TV (limited) range.
  40. clip = core.std.SetFrameProps(clip=clip, _ColorRange=vs.RANGE_LIMITED)
  41. # making sure frame rate is set to 29.97fps
  42. clip = core.std.AssumeFPS(clip=clip, fpsnum=30000, fpsden=1001)
  43. # making sure the detected scan type is set (detected: progressive)
  44. clip = core.std.SetFrameProps(clip=clip, _FieldBased=vs.FIELD_PROGRESSIVE) # scan type: progressive
  45. # Decimate using TDecimate
  46. clip = core.tivtc.TDecimate(clip) # new fps: 23.976
  47. clip = core.std.Crop(clip, left=14, right=12, top=72, bottom=72) # cropping to 694x336
  48. # applying dehalo using YAHR
  49. clip = dehalo.YAHR(clip, depth=16) # call: 0
  50. clip = core.std.AddBorders(clip=clip, left=0, right=2, top=0, bottom=0) # add borders to archive mod 4 (NNEDI3(CL)) - 696x336
  51. # resizing using NNEDI3CL
  52. # current: 696x336 target: 1280x698 -> pow: 4
  53. clip = edi_rpow2.nnedi3cl_rpow2(clip, rfactor=4, nsize=3, nns=4) # 2784x1344
  54. clip = core.std.Crop(clip=clip, left=0, right=8, top=0, bottom=0) # removing added borders from mod requirement (NNEDI3(CL)) - 2776x1344
  55. # resizing 2776x1344 to 1280x698
  56. clip = core.fmtc.resample(clip, w=1280, h=698, kernel="spline64", interlaced=False, interlacedd=False) # before YUV420P8 after YUV420P16
  57. clip = core.std.AddBorders(clip=clip, left=0, right=0, top=2, bottom=4) # add borders to archive mod 8 (vsBasicVSRPPFilter) - 1280x704
  58. # adjusting color space from YUV420P16 to RGBH for vsBasicVSRPPFilter
  59. clip = core.resize.Bicubic(clip=clip, format=vs.RGBH, matrix_in_s="470bg", range_in_s="limited", range_s="full")
  60. # Quality enhancement using BasicVSR++
  61. from vsbasicvsrpp import basicvsrpp as BasicVSRPP
  62. clip = BasicVSRPP(clip, model=4)
  63. clip = core.std.Crop(clip=clip, left=0, right=0, top=2, bottom=4) # removing added borders from mod requirement (vsBasicVSRPPFilter) - 1280x698
  64. # adjusting color space from RGBH to YUV444P16 for vsGLSLFilmGrain
  65. clip = core.resize.Bicubic(clip=clip, format=vs.YUV444P16, matrix_s="470bg", range_in_s="full", range_s="limited") # additional resize to match target color sampling
  66. # Adding grain using GLSL AddGrain
  67. with open("F:/Hybrid/64bit/vsfilters/GLSL/parameterized/filmgrain.glsl") as glslf:
  68. glsl = glslf.read()
  69. glsl = glsl.replace('#define INTENSITY 0.05', '#define INTENSITY 0.02')
  70. clip = core.placebo.Shader(clip, shader_s=glsl, width=clip.width, height=clip.height)
  71. # adjusting output color from YUV444P16 to YUV420P10 for NVEncModel
  72. clip = core.resize.Bicubic(clip=clip, format=vs.YUV420P10, dither_type="error_diffusion")
  73. # set output frame rate to 23.976fps (progressive)
  74. clip = core.std.AssumeFPS(clip=clip, fpsnum=24000, fpsden=1001)
  75. # output
  76. clip.set_output()
  77. # script was created by Hybrid 2025.12.29.1
Advertisement
Add Comment
Please, Sign In to add comment