Advertisement
Guest User

Untitled

a guest
Jan 6th, 2024
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.79 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 thread count to 1, due to usage of sRestore
  9. core.num_threads = 1
  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/Support/libtemporalmedian.dll")
  17. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/SharpenFilter/CAS/CAS.dll")
  18. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/GrainFilter/RemoveGrain/RemoveGrainVS.dll")
  19. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/GrainFilter/AddGrain/AddGrain.dll")
  20. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DenoiseFilter/DFTTest/DFTTest.dll")
  21. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DenoiseFilter/NEO_FFT3DFilter/neo-fft3d.dll")
  22. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/EEDI3m_opencl.dll")
  23. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/ResizeFilter/nnedi3/NNEDI3CL.dll")
  24. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/libmvtools.dll")
  25. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/scenechange.dll")
  26. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/fmtconv.dll")
  27. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/MiscFilter/MiscFilters/MiscFilters.dll")
  28. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DeinterlaceFilter/Bwdif/Bwdif.dll")
  29. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/libdescale.dll")
  30. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/SourceFilter/DGDecNV/DGDecodeNV.dll")
  31. # Import scripts
  32. import SpotLess
  33. import havsfunc
  34. # source: 'C:\Users\Selur\Desktop\Copenhagen01-001-CLIP.mp4'
  35. # current color space: YUV420P8, bit depth: 8, resolution: 1258x720, fps: 29.97, color matrix: 709, yuv luminance scale: limited, scanorder: top field first
  36. # Loading C:\Users\Selur\Desktop\Copenhagen01-001-CLIP.mp4 using DGSource
  37. clip = core.dgdecodenv.DGSource("J:/tmp/mp4_e563cfd6e2734c84919598f607f26f0f_853323747.dgi",fieldop=0)# 29.97 fps, scanorder: top field first
  38. frame = clip.get_frame(0)
  39. # Setting detected color matrix (709).
  40. clip = core.std.SetFrameProps(clip, _Matrix=1)
  41. # Setting color transfer (to 709), if it is not set.
  42. if '_Transfer' not in frame.props or not frame.props['_Transfer']:
  43. clip = core.std.SetFrameProps(clip, _Transfer=1)
  44. # Setting color primaries info (to 1), if it is not set.
  45. if '_Primaries' not in frame.props or not frame.props['_Primaries']:
  46. clip = core.std.SetFrameProps(clip, _Primaries=1)
  47. # Setting color range to TV (limited) range.
  48. clip = core.std.SetFrameProp(clip=clip, prop="_ColorRange", intval=1)
  49. # making sure frame rate is set to 29.97
  50. clip = core.std.AssumeFPS(clip=clip, fpsnum=30000, fpsden=1001)
  51. clip = core.std.SetFrameProp(clip=clip, prop="_FieldBased", intval=2) # tff
  52. # converting interlaced to half-height progressive for filtering (vsVinverse) (separate fields)
  53. clip = core.resize.Bicubic(clip=clip, format=vs.YUV444P8, range_s="limited")
  54. clip = core.std.SeparateFields(clip, tff=True)
  55. clipEven = clip[::2] # resolution 1258x360
  56. clipEven = core.std.SetFrameProp(clip=clipEven, prop="_FieldBased", intval=0) # progressive
  57. clipOdd = clip[1::2] # resolution 1258x360
  58. clipOdd = core.std.SetFrameProp(clip=clipOdd, prop="_FieldBased", intval=0) # progressive
  59. clipEven = havsfunc.Vinverse(clp=clipEven)
  60. clipOdd = havsfunc.Vinverse(clp=clipOdd)
  61. # converting half-height progressive to interlacedbefore deinterlacing
  62. clip = core.std.Interleave([clipOdd, clipEven])
  63. clip = core.std.DoubleWeave(clip=clip, tff=True) # resolution 1258x720
  64. clip = core.std.SelectEvery(clip, 2, 0)
  65. clip = core.std.SetFrameProp(clip=clip, prop="_FieldBased", intval=2) # tff
  66. # adjusting resolution before deinterlacing
  67. clip = core.descale.Debicubic(src=clip, width=1258, height=282, b="0.00", c="0.50")
  68. clip = core.std.AddBorders(clip=clip, left=0, right=2, top=0, bottom=2) # add borders to archive mod 4 (vsQTGMC) - 1260x284
  69. # Deinterlacing using QTGMC
  70. clip = havsfunc.QTGMC(Input=clip, Preset="Faster", InputType=0, TFF=True, TR2=0, SourceMatch=0, Lossless=0, EZDenoise=5.00, NoisePreset="Fast", opencl=True) # new fps: 29.97
  71. # Making sure content is preceived as frame based
  72. clip = core.std.SetFrameProp(clip=clip, prop="_FieldBased", intval=0) # progressive
  73. clip = clip[::2] # selecting previously even frames
  74. clip = core.std.CropRel(clip=clip, left=0, right=2, top=0, bottom=2) # removing borders (vsQTGMC) - 1258x282
  75. clip = core.std.AddBorders(clip=clip, left=0, right=2, top=0, bottom=2) # add borders to archive mod 4 (vsQTGMCFilter) - 1260x284
  76. # Denoising using QTGMC
  77. clip = havsfunc.QTGMC(Input=clip, Preset="Fast", InputType=3, TR2=1, TFF=False, SourceMatch=0, Lossless=0, opencl=True)
  78. clip = core.std.CropRel(clip=clip, left=0, right=2, top=0, bottom=2) # removing borders (vsQTGMCFilter) - 1258x282
  79. clip = core.std.CropRel(clip=clip, left=0, right=0, top=0, bottom=2)# cropping to 1258x280
  80. # Resizing using 10 - bicubic spline
  81. clip = core.fmtc.resample(clip=clip, kernel="spline16", w=1258, h=790, interlaced=False, interlacedd=False) # resolution 1258x790 before YUV444P8 after YUV444P16
  82. # contrast sharpening using CAS
  83. clip = core.cas.CAS(clip=clip, sharpness=0.600)
  84. # adjusting frame count and rate with sRestore
  85. clip = havsfunc.srestore(source=clip, frate=23.9760)
  86. # Spot removal using SpotLess
  87. clip = SpotLess.SpotLess(clip=clip, radT=1, pel=2)
  88. # adjusting output color from: YUV444P16 to YUV420P10 for NVEncModel
  89. clip = core.resize.Bicubic(clip=clip, format=vs.YUV420P10, range_s="limited", dither_type="error_diffusion")
  90. # set output frame rate to 23.976fps (progressive)
  91. clip = core.std.AssumeFPS(clip=clip, fpsnum=24000, fpsden=1001)
  92. # Output
  93. clip.set_output()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement