Advertisement
Guest User

Untitled

a guest
Apr 6th, 2024
33
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.61 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. # Import scripts folder
  9. scriptPath = 'F:/Hybrid/64bit/vsscripts'
  10. sys.path.insert(0, os.path.abspath(scriptPath))
  11. # Loading Support Files
  12. Dllref = ctypes.windll.LoadLibrary("F:/Hybrid/64bit/vsfilters/Support/libfftw3f-3.dll")
  13. # Loading Plugins
  14. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/SharpenFilter/AWarpSharp2/libawarpsharp2.dll")
  15. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DenoiseFilter/CTMF/CTMF.dll")
  16. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/TCanny.dll")
  17. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/libtemporalmedian.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/SourceFilter/LSmashSource/LSMASHSource.dll")
  30. # Import scripts
  31. import edi_rpow2
  32. import mcdegrainsharp
  33. import SpotLess
  34. import havsfunc
  35. # source: 'C:\Users\Selur\Desktop\sample.mov'
  36. # current color space: YUV420P8, bit depth: 8, resolution: 720x576, fps: 25, scanorder: bottom field first, yuv luminance scale: limited, matrix: 470bg, transfer: bt.709, primaries: bt.601 pal
  37. # Loading C:\Users\Selur\Desktop\sample.mov using LWLibavSource
  38. clip = core.lsmas.LWLibavSource(source="C:/Users/Selur/Desktop/sample.mov", format="YUV420P8", stream_index=0, cache=0, prefer_hw=0)
  39. frame = clip.get_frame(0)
  40. # Setting detected color matrix (470bg).
  41. clip = core.std.SetFrameProps(clip, _Matrix=5)
  42. # Setting color transfer (709), if it is not set.
  43. if '_Transfer' not in frame.props or not frame.props['_Transfer']:
  44. clip = core.std.SetFrameProps(clip, _Transfer=1)
  45. # Setting color primaries info (to 470), if it is not set.
  46. if '_Primaries' not in frame.props or not frame.props['_Primaries']:
  47. clip = core.std.SetFrameProps(clip, _Primaries=5)
  48. # Setting color range to TV (limited) range.
  49. clip = core.std.SetFrameProp(clip=clip, prop="_ColorRange", intval=1)
  50. # making sure frame rate is set to 25
  51. clip = core.std.AssumeFPS(clip=clip, fpsnum=25, fpsden=1)
  52. clip = core.std.SetFrameProp(clip=clip, prop="_FieldBased", intval=1) # bff
  53. # Deinterlacing using QTGMC
  54. clip = havsfunc.QTGMC(Input=clip, Preset="Fast", TFF=True, opencl=True) # new fps: 25
  55. # Making sure content is preceived as frame based
  56. clip = core.std.SetFrameProp(clip=clip, prop="_FieldBased", intval=0) # progressive
  57. clip = clip[::2] # selecting previously even frames
  58. # Spot removal using SpotLess
  59. clip = SpotLess.SpotLess(clip=clip, radT=2, pel=1)
  60. clip = core.std.CropRel(clip=clip, left=10, right=20, top=4, bottom=10)# cropping to 690x562
  61. # Fix bright and dark line artifacts near the border of an image using BalanceBorders
  62. clip = havsfunc.bbmod(c=clip,cLeft=16,cTop=0,cRight=0,cBottom=0)
  63. # removing grain using MCDegrain
  64. clip = mcdegrainsharp.mcdegrainsharp(clip=clip)
  65. # applying dehalo using YAHR
  66. clip = havsfunc.YAHR(clip, depth=16)
  67. clip = core.std.AddBorders(clip=clip, left=0, right=2, top=0, bottom=2) # add borders to archive mod 4 (NNEDI3(CL)) - 692x564
  68. # resizing using NNEDI3CL
  69. # current: 692x564 target: 1280x978 -> pow: 2
  70. clip = edi_rpow2.nnedi3cl_rpow2(clip=clip, rfactor=2, nsize=3) # 1384x1128
  71. clip = core.std.CropRel(clip=clip, left=0, right=4, top=0, bottom=4) # removing borders (NNEDI3(CL)) - 1380x1124
  72. # adjusting resizing
  73. clip = core.fmtc.resample(clip=clip, w=1280, h=978, kernel="spline64", interlaced=False, interlacedd=False)# before YUV420P8 after YUV420P16
  74. # adjusting output color from: YUV420P16 to YUV420P10 for NVEncModel
  75. clip = core.resize.Bicubic(clip=clip, format=vs.YUV420P10, range_s="limited", dither_type="error_diffusion")
  76. # set output frame rate to 25fps (progressive)
  77. clip = core.std.AssumeFPS(clip=clip, fpsnum=25, fpsden=1)
  78. # Output
  79. clip.set_output()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement