Advertisement
Guest User

Vapoursynth smooth resize

a guest
Jul 28th, 2021
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.22 KB | None | 0 0
  1. # Imports
  2. import os
  3. import sys
  4. import vapoursynth as vs
  5. # getting Vapoursynth core
  6. core = vs.core
  7. # Import scripts folder
  8. scriptPath = 'I:/Hybrid/64bit/vsscripts'
  9. sys.path.append(os.path.abspath(scriptPath))
  10. # Loading Plugins
  11. core.std.LoadPlugin(path="I:/Hybrid/64bit/vsfilters/ResizeFilter/nnedi3/NNEDI3CL.dll")
  12. core.std.LoadPlugin(path="I:/Hybrid/64bit/vsfilters/Support/fmtconv.dll")
  13. core.std.LoadPlugin(path="I:/Hybrid/64bit/vsfilters/SharpenFilter/CAS/CAS.dll")
  14. core.std.LoadPlugin(path="I:/Hybrid/64bit/vsfilters/DeinterlaceFilter/TIVTC/libtivtc.dll")
  15. core.std.LoadPlugin(path="I:/Hybrid/64bit/vsfilters/SourceFilter/DGDecNV/DGDecodeNV.dll")
  16. # Import scripts
  17. import edi_rpow2
  18. # source: 'C:\Users\Selur\Desktop\SFE-Complete.demuxed.m2v'
  19. # current color space: YUV420P8, bit depth: 8, resolution: 720x480, fps: 29.97, color matrix: 470bg, yuv luminance scale: limited, scanorder: telecine (soft)
  20. # Loading C:\Users\Selur\Desktop\SFE-Complete.demuxed.m2v using DGSource
  21. clip = core.dgdecodenv.DGSource("E:/Temp/m2v_640d95887baddb54af12f6963f913c88_853323747.dgi",fieldop=2)
  22. # making sure input color matrix is set as 470bg
  23. clip = core.resize.Point(clip, matrix_in_s="470bg",range_s="limited")
  24. # making sure frame rate is set to 29.97
  25. clip = core.std.AssumeFPS(clip=clip, fpsnum=30000, fpsden=1001)
  26. # Setting color range to TV (limited) range.
  27. clip = core.std.SetFrameProp(clip=clip, prop="_ColorRange", intval=1)
  28. clip2clip = clip
  29. # Deinterlacing using TIVTC
  30. clip = core.tivtc.TFM(clip=clip, slow=2, clip2=clip2clip)
  31.  
  32. org = clip
  33.  
  34. # adjusting color space from YUV420P8 to RGBS for DPIR
  35. clip = core.resize.Bicubic(clip=clip, format=vs.RGBS, matrix_in_s="470bg", range_s="limited")
  36. from vsdpir import DPIR
  37. # def DPIR(clip: vs.VideoNode, strength: float=None, task: str='denoise', device_type: str='cuda', device_index: int=0) -> vs.VideoNode:
  38. # DPIR: Deep Plug-and-Play Image Restoration
  39. # Parameters:
  40. # clip: Clip to process. Only planar format with float sample type of 32 bit depth is supported.
  41. # strength: Strength for deblocking or denoising. Must be greater than 0. Defaults to 50.0 for 'deblock' task, 5.0 for 'denoise' task.
  42. # task: Task to perform. Must be 'deblock' or 'denoise'.
  43. # device_type: Device type on which the tensor is allocated. Must be 'cuda' or 'cpu'.
  44. # device_index: Device ordinal for the device type.
  45. clip = DPIR(clip=clip,task='denoise',strength=2)
  46. clip = DPIR(clip=clip,task='deblock',strength=25)
  47.  
  48. # contrast sharpening using CAS
  49. clip = core.cas.CAS(clip=clip, sharpness=0.8)
  50.  
  51. # resizing using NNEDI3CL
  52. clip = edi_rpow2.nnedi3cl_rpow2(clip=clip, rfactor=4, nns=4, qual=1)
  53. clip = core.fmtc.resample(clip=clip, w=1440, h=1080, kernel="lanczos", interlaced=False, interlacedd=False)
  54.  
  55. org = core.fmtc.resample(clip=org, w=1440, h=1080, kernel="lanczos", interlaced=False, interlacedd=False)
  56.  
  57. # adjusting output color from: RGBS to YUV420P10 for x265Model (i420@10)
  58. clip = core.resize.Bicubic(clip=clip, format=vs.YUV420P10, matrix_s="470bg", range_s="limited")
  59. org = core.resize.Bicubic(clip=org, format=vs.YUV420P10)
  60.  
  61. clip = core.sub.Subtitle(clip=clip, text='filtered')
  62. org = core.sub.Subtitle(clip=org, text='original')
  63.  
  64. clip = core.std.StackHorizontal([org,clip])
  65. # Output
  66. clip.set_output()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement