Guest User

Untitled

a guest
Aug 17th, 2025
4
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.99 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. # Limit frame cache to 48473MB
  9. core.max_cache_size = 48473
  10. # Import scripts folder
  11. scriptPath = 'F:/Hybrid/64bit/vsscripts'
  12. sys.path.insert(0, os.path.abspath(scriptPath))
  13. # Loading Support Files
  14. Dllref = ctypes.windll.LoadLibrary("F:/Hybrid/64bit/vsfilters/Support/libfftw3f-3.dll")
  15. # loading plugins
  16. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/ResizeFilter/nnedi3/NNEDI3CL.dll")
  17. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DenoiseFilter/CTMF/CTMF.dll")
  18. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DenoiseFilter/DFTTest/dfttest2_nvrtc.dll")
  19. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DerainbowFilter/SSIQ/libssiq.dll")
  20. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/libmvtools.dll")
  21. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/DCTFilter.dll")
  22. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DeblockFilter/Deblock/Deblock.dll")
  23. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/fmtconv.dll")
  24. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/akarin.dll")
  25. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/SharpenFilter/CAS/CAS.dll")
  26. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DenoiseFilter/ZSmooth/zsmooth.dll")
  27. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/SourceFilter/d2vSource/DGDecode.dll")
  28. # Import scripts
  29. import edi_rpow2
  30. import dfttest2
  31. import nnedi3_resample
  32. import smdegrain
  33. import artifacts
  34. import SpotLess
  35. import deblock
  36. import sharpen
  37. import validate
  38. # Source: 'C:\Users\Selur\Desktop\A_1.mpg'
  39. # Current color space: YUV420P8, bit depth: 8, resolution: 352x288, frame rate: 25fps, scanorder: progressive, yuv luminance scale: limited, matrix: 470bg, format: mpeg-1
  40. # Loading C:\Users\Selur\Desktop\A_1.mpg using DGDecode
  41. clip = core.dgdecode.MPEG2Source("J:/tmp/mpg_fc4111cf4fb0f3393b1111ac0d285cab_853323747.d2v",info=3)# 25 fps, scanorder: progressive
  42. frame = clip.get_frame(0)
  43. # setting color matrix to 470bg.
  44. clip = core.std.SetFrameProps(clip, _Matrix=vs.MATRIX_BT470_BG)
  45. # setting color transfer (vs.TRANSFER_BT601), if it is not set.
  46. if validate.transferIsInvalid(clip):
  47. clip = core.std.SetFrameProps(clip=clip, _Transfer=vs.TRANSFER_BT601)
  48. # setting color primaries info (to vs.PRIMARIES_BT470_BG), if it is not set.
  49. if validate.primariesIsInvalid(clip):
  50. clip = core.std.SetFrameProps(clip=clip, _Primaries=vs.PRIMARIES_BT470_BG)
  51. # setting color range to TV (limited) range.
  52. clip = core.std.SetFrameProps(clip=clip, _ColorRange=vs.RANGE_LIMITED)
  53. # making sure frame rate is set to 25fps
  54. clip = core.std.AssumeFPS(clip=clip, fpsnum=25, fpsden=1)
  55. # making sure the detected scan type is set (detected: progressive)
  56. clip = core.std.SetFrameProps(clip=clip, _FieldBased=vs.FIELD_PROGRESSIVE) # progressive
  57. # adjusting color space from YUV420P8 to RGB24 for vsLevels
  58. clip = core.resize.Bicubic(clip=clip, format=vs.RGB24, matrix_in_s="470bg", range_s="limited")
  59. # adjusting color using Levels on RGB24 (8 bit)
  60. clip = core.std.Levels(clip=clip, min_in=32, max_in=196, min_out=16, max_out=235)
  61. # sharpening using DetailSharpen
  62. clip = sharpen.DetailSharpen(clip=clip)
  63. # contrast sharpening using CAS
  64. clip = core.cas.CAS(clip=clip, sharpness=0.700)
  65. # adjusting color space from RGB24 to YUV444PS for vsDeblockQED
  66. clip = core.resize.Bicubic(clip=clip, format=vs.YUV444PS, matrix_s="470bg", range_s="limited")
  67. # applying deblocking using DeBlock QED
  68. clip = deblock.Deblock_QED(clip, quant1=60, quant2=60, aOff2=5, bOff2=5)
  69. # adjusting color space from YUV444PS to YUV444P16 for vsSpotLess
  70. clip = core.resize.Bicubic(clip=clip, format=vs.YUV444P16, range_s="limited", dither_type="error_diffusion")
  71. # Spot removal using SpotLess
  72. clip = SpotLess.SpotLess(clip=clip, radT=3, rec=True, pel=1, smoother="zsmooth")
  73. clip = artifacts.DeSpot(o=clip)
  74. clip = core.std.Crop(clip=clip, left=0, right=8, top=6, bottom=2)# cropping to 344x280
  75. # adjusting color space from YUV444P16 to YUV420P8 for vsSSIQ
  76. clip = core.resize.Bicubic(clip=clip, format=vs.YUV420P8, range_s="limited", dither_type="error_diffusion")
  77. # rainbow removal using SSIQ
  78. clip = core.ssiq.SSIQ(clip=clip, interlaced=0)
  79. # removing grain using SMDegrain
  80. clip = smdegrain.SMDegrain(input=clip, tr=3, thSAD=1300, thSADC=512, RefineMotion=True, interlaced=False, prefilter=3, dct=1, opencl=True, device=-1)
  81. # resizing using NNEDI3CL
  82. # current: 344x280 target: 1416x1080 -> pow: 8
  83. clip = edi_rpow2.nnedi3cl_rpow2(clip=clip, rfactor=8, nns=1) # 2752x2240
  84. # resizing 2752x2240 to 1416x1080
  85. clip = core.fmtc.resample(clip=clip, w=1416, h=1080, kernel="spline64", interlaced=False, interlacedd=False)# before YUV420P8 after YUV420P16
  86. # adjusting output color from: YUV420P16 to YUV420P10 for NVEncModel
  87. clip = core.resize.Bicubic(clip=clip, format=vs.YUV420P10, range_s="limited", dither_type="error_diffusion")
  88. # set output frame rate to 25fps (progressive)
  89. clip = core.std.AssumeFPS(clip=clip, fpsnum=25, fpsden=1)
  90. # output
  91. clip.set_output()
Tags: vcd
Advertisement
Add Comment
Please, Sign In to add comment