Advertisement
Guest User

Untitled

a guest
Apr 8th, 2024
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.79 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/SharpenFilter/CAS/CAS.dll")
  12. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/fmtconv.dll")
  13. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/FrameFilter/Interframe/svpflow2_vs64.dll")
  14. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/FrameFilter/Interframe/svpflow1_vs64.dll")
  15. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/GrainFilter/RemoveGrain/RemoveGrainVS.dll")
  16. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DenoiseFilter/RemoveDirt/RemoveDirtVS.dll")
  17. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/MiscFilter/EdgeFixer/EdgeFixer.dll")
  18. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/libtemporalmedian.dll")
  19. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/libmvtools.dll")
  20. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/SourceFilter/LSmashSource/LSMASHSource.dll")
  21. # Import scripts
  22. import removeDirt
  23. import SpotLess
  24. import havsfunc
  25. # source: 'C:\Users\Selur\Desktop\PAL SD_sample.mkv'
  26. # current color space: YUV422P10, bit depth: 10, resolution: 720x576, fps: 25, scanorder: progressive, yuv luminance scale: limited, matrix: 470bg
  27. # Loading C:\Users\Selur\Desktop\PAL SD_sample.mkv using LWLibavSource
  28. clip = core.lsmas.LWLibavSource(source="C:/Users/Selur/Desktop/PAL SD_sample.mkv", format="YUV422P10", stream_index=0, cache=0, prefer_hw=0)
  29. frame = clip.get_frame(0)
  30. # Setting detected color matrix (470bg).
  31. clip = core.std.SetFrameProps(clip, _Matrix=5)
  32. # Setting color transfer (170), if it is not set.
  33. if '_Transfer' not in frame.props or not frame.props['_Transfer']:
  34. clip = core.std.SetFrameProps(clip, _Transfer=6)
  35. # Setting color primaries info (to 470), if it is not set.
  36. if '_Primaries' not in frame.props or not frame.props['_Primaries']:
  37. clip = core.std.SetFrameProps(clip, _Primaries=5)
  38. # Setting color range to TV (limited) range.
  39. clip = core.std.SetFrameProp(clip=clip, prop="_ColorRange", intval=1)
  40. # making sure frame rate is set to 25
  41. clip = core.std.AssumeFPS(clip=clip, fpsnum=25, fpsden=1)
  42. clip = core.std.SetFrameProp(clip=clip, prop="_FieldBased", intval=0) # progressive
  43. clip = havsfunc.Vinverse(clp=clip)
  44. # Spot removal using SpotLess
  45. clip = SpotLess.SpotLess(clip=clip, radT=2, pel=1)
  46. clip = core.std.CropRel(clip=clip, left=18, right=16, top=2, bottom=6)# cropping to 686x568
  47. # Fix bright and dark line artifacts near the border of an image using EdgeFixer
  48. clip = core.edgefixer.Continuity(clip=clip,bottom=4,radius=3)
  49. # Fix bright and dark line artifacts near the border of an image using BalanceBorders
  50. clip = havsfunc.bbmod(c=clip,cLeft=12,cTop=8,cRight=12,cBottom=0)
  51. clip = core.std.AddBorders(clip=clip, left=8, right=10, top=0, bottom=0) # add borders to archive mod 8 (vsRemoveDirtMC) - 704x568
  52. # adjusting color space from YUV422P10 to YUV420P8 for vsRemoveDirtMC
  53. clip = core.resize.Bicubic(clip=clip, format=vs.YUV420P8, range_s="limited", dither_type="error_diffusion")
  54. # denoising using VsRemoveDirtMC
  55. clip = removeDirt.RemoveDirtMC(input=clip, remgrainmode=12, limit=10, gpu=True)
  56. clip = core.std.CropRel(clip=clip, left=8, right=10, top=0, bottom=0) # removing borders (vsRemoveDirtMC) - 686x568
  57. clip = core.fmtc.resample(clip=clip, w=960, h=794, kernel="spline64", interlaced=False, interlacedd=False)# adjusting for 'wanted width' (vsBasicVSRPPFilter)
  58. clip = core.std.AddBorders(clip=clip, left=0, right=0, top=2, bottom=4) # add borders to archive mod 8 (vsBasicVSRPPFilter) - 960x800
  59. # adjusting color space from YUV420P16 to RGBH for vsBasicVSRPPFilter
  60. clip = core.resize.Bicubic(clip=clip, format=vs.RGBH, matrix_in_s="470bg", range_s="limited")
  61. # Quality enhancement using BasicVSR++
  62. from vsbasicvsrpp import basicvsrpp as BasicVSRPP
  63. clip = BasicVSRPP(clip=clip, model=4, length=100)
  64. clip = core.std.CropRel(clip=clip, left=0, right=0, top=2, bottom=4) # removing borders (vsBasicVSRPPFilter) - 960x794
  65. # adjusting color space from RGBH to RGB48 for vsCAS
  66. clip = core.resize.Bicubic(clip=clip, format=vs.RGB48, range_s="limited")
  67. # contrast sharpening using CAS
  68. clip = core.cas.CAS(clip=clip, sharpness=0.600)
  69. # Resizing using 10 - bicubic spline
  70. clip = core.fmtc.resample(clip=clip, kernel="spline16", w=1280, h=1060, interlaced=False, interlacedd=False) # resolution 1280x1060 before RGB48 after RGB48
  71. # adjusting output color from: RGB48 to YUV420P10 for NVEncModel
  72. clip = core.resize.Bicubic(clip=clip, format=vs.YUV420P10, matrix_s="470bg", range_s="limited", dither_type="error_diffusion")
  73. # set output frame rate to 25fps (progressive)
  74. clip = core.std.AssumeFPS(clip=clip, fpsnum=25, fpsden=1)
  75. # Output
  76. clip.set_output()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement