Guest User

Untitled

a guest
Jan 4th, 2025
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.18 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/Support/libvs_placebo.dll")
  12. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/fmtconv.dll")
  13. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DenoiseFilter/ZSmooth/zsmooth.dll")
  14. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/libmvtools.dll")
  15. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DeinterlaceFilter/TIVTC/libtivtc.dll")
  16. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/SourceFilter/DGDecNV/DGDecodeNV.dll")
  17. # Import scripts
  18. import SpotLess
  19. import chromashift
  20. import validate
  21. # Source: 'C:\Users\Selur\Desktop\sample_trl.mkv'
  22. # Current color space: YUV420P8, bit depth: 8, resolution: 710x478, frame rate: 29.97fps, scanorder: telecine, yuv luminance scale: limited, matrix: 470bg, transfer: bt.709, primaries: bt.601 ntsc, format: AVC
  23. # Loading C:\Users\Selur\Desktop\sample_trl.mkv using DGSource
  24. clip = core.dgdecodenv.DGSource("J:/tmp/mkv_cd34fe4da5196d637036f10fbbe5a14b_853323747.dgi",fieldop=0)# 29.97 fps, scanorder: telecine
  25. frame = clip.get_frame(0)
  26. # setting color matrix to 470bg.
  27. clip = core.std.SetFrameProps(clip, _Matrix=vs.MATRIX_BT470_BG)
  28. # setting color transfer (vs.TRANSFER_BT709), if it is not set.
  29. if validate.transferIsInvalid(clip):
  30. clip = core.std.SetFrameProps(clip=clip, _Transfer=vs.TRANSFER_BT709)
  31. # setting color primaries info (to vs.PRIMARIES_BT470_BG), if it is not set.
  32. if validate.primariesIsInvalid(clip):
  33. clip = core.std.SetFrameProps(clip=clip, _Primaries=vs.PRIMARIES_BT470_BG)
  34. # setting color range to TV (limited) range.
  35. clip = core.std.SetFrameProps(clip=clip, _ColorRange=vs.RANGE_LIMITED)
  36. # making sure frame rate is set to 29.97fps
  37. clip = core.std.AssumeFPS(clip=clip, fpsnum=30000, fpsden=1001)
  38. # making sure the detected scan type is set (detected: telecine)
  39. clip = core.std.SetFrameProps(clip=clip, _FieldBased=vs.FIELD_TOP) # tff
  40. # Deinterlacing using TIVTC
  41. clip = core.tivtc.TFM(clip=clip)
  42. clip = core.tivtc.TDecimate(clip=clip)# new fps: 23.976
  43. # Making sure content is preceived as frame based
  44. clip = core.std.SetFrameProps(clip=clip, _FieldBased=vs.FIELD_PROGRESSIVE) # progressive
  45. # Chroma adjustment using ChromaShiftSP
  46. clip = chromashift.ChromaShiftSP(clip=clip, X=2.50, jeh=False)
  47. # Spot removal using SpotLess
  48. clip = SpotLess.SpotLess(clip=clip, radT=3, pel=1, smoother="zsmooth")
  49. clip = core.std.Crop(clip=clip, left=2, right=4, top=0, bottom=0)# cropping to 704x478
  50. clip = core.std.AddBorders(clip=clip, left=0, right=0, top=0, bottom=2) # add borders to archive mod 8 (vsBasicVSRPPFilter) - 704x480
  51. # adjusting color space from YUV420P8 to RGBH for vsBasicVSRPPFilter
  52. clip = core.resize.Bicubic(clip=clip, format=vs.RGBH, matrix_in_s="470bg", range_s="limited")
  53. # Quality enhancement using BasicVSR++
  54. from vsbasicvsrpp import basicvsrpp as BasicVSRPP
  55. clip = BasicVSRPP(clip=clip, model=4)
  56. clip = core.std.Crop(clip=clip, left=0, right=0, top=0, bottom=2) # removing borders (vsBasicVSRPPFilter) - 704x478
  57. # Resizing using 10 - bicubic spline
  58. clip = core.resize.Bicubic(clip=clip, format=vs.RGBS, range_s="limited")
  59. clip = core.fmtc.resample(clip=clip, kernel="spline16", w=720, h=550, interlaced=False, interlacedd=False) # resolution 720x550
  60. # adjusting color space from RGBS to YUV444P16 for vsGLSLFilmGrain
  61. clip = core.resize.Bicubic(clip=clip, format=vs.YUV444P16, matrix_s="470bg", range_s="limited", dither_type="error_diffusion")
  62. with open("F:/Hybrid/64bit/vsfilters/GLSL/parameterized/filmgrain.glsl") as glslf:
  63. glsl = glslf.read()
  64. glsl = glsl.replace('#define INTENSITY 0.05', '#define INTENSITY 0.01')
  65. clip = core.placebo.Shader(clip=clip, shader_s=glsl, width=clip.width, height=clip.height)
  66. # adjusting output color from: YUV444P16 to YUV420P10 for NVEncModel
  67. clip = core.resize.Bicubic(clip=clip, format=vs.YUV420P10, range_s="limited", dither_type="error_diffusion")
  68. # set output frame rate to 23.976fps (progressive)
  69. clip = core.std.AssumeFPS(clip=clip, fpsnum=24000, fpsden=1001)
  70. # output
  71. clip.set_output()
Advertisement
Add Comment
Please, Sign In to add comment