Advertisement
Guest User

Untitled

a guest
Aug 12th, 2022
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.70 KB | None | 0 0
  1. # Imports
  2. import vapoursynth as vs
  3. # getting Vapoursynth core
  4. core = vs.core
  5. import site
  6. # Import libraries for onnxruntime
  7. import ctypes
  8. path = site.getsitepackages()[0]+'/onnxruntime_dlls/'
  9. ctypes.windll.kernel32.SetDllDirectoryW(path)
  10. # Loading Plugins
  11. core.std.LoadPlugin(path="i:/Hybrid/64bit/vsfilters/Support/fmtconv.dll")
  12. core.std.LoadPlugin(path="i:/Hybrid/64bit/vsfilters/Support/libvs_placebo.dll")
  13. core.std.LoadPlugin(path="i:/Hybrid/64bit/vsfilters/DebandFilter/Flash3kDeband/flash3kyuu_deband.dll")
  14. core.std.LoadPlugin(path="i:/Hybrid/64bit/vsfilters/DeinterlaceFilter/TIVTC/libtivtc.dll")
  15. core.std.LoadPlugin(path="i:/Hybrid/64bit/vsfilters/SourceFilter/LSmashSource/vslsmashsource.dll")
  16. # source: 'C:\Users\Selur\Desktop\Taylor Swift - You Belong With Me_USCJY0903499-Source Prores 480i.mkv'
  17. # current color space: YUV422P10, bit depth: 10, resolution: 720x480, fps: 29.97, color matrix: 170m, yuv luminance scale: limited, scanorder: telecine
  18. # Loading C:\Users\Selur\Desktop\Taylor Swift - You Belong With Me_USCJY0903499-Source Prores 480i.mkv using LWLibavSource
  19. clip = core.lsmas.LWLibavSource(source="C:/Users/Selur/Desktop/Taylor Swift - You Belong With Me_USCJY0903499-Source Prores 480i.mkv", format="YUV422P10", stream_index=0, cache=0, prefer_hw=0)
  20. # Setting color matrix to 170m.
  21. clip = core.std.SetFrameProps(clip, _Matrix=6)
  22. clip = clip if not core.text.FrameProps(clip,'_Transfer') else core.std.SetFrameProps(clip, _Transfer=6)
  23. clip = clip if not core.text.FrameProps(clip,'_Primaries') else core.std.SetFrameProps(clip, _Primaries=5)
  24. # Setting color range to TV (limited) range.
  25. clip = core.std.SetFrameProp(clip=clip, prop="_ColorRange", intval=1)
  26. # making sure frame rate is set to 29.970
  27. clip = core.std.AssumeFPS(clip=clip, fpsnum=30000, fpsden=1001)
  28. # Deinterlacing using TIVTC
  29. clip = core.tivtc.TFM(clip=clip)
  30. clip = core.tivtc.TDecimate(clip=clip)# new fps: 23.976
  31. # make sure content is preceived as frame based
  32. clip = core.std.SetFieldBased(clip, 0)
  33. # cropping the video to 720x364
  34. clip = core.std.CropRel(clip=clip, left=0, right=0, top=58, bottom=58)
  35. from vsdpir import DPIR
  36. # adjusting color space from YUV422P10 to RGBS for vsDPIRDenoise
  37. clip = core.resize.Bicubic(clip=clip, format=vs.RGBS, matrix_in_s="170m", range_s="limited")
  38. # denoising using DPIRDenoise
  39. clip = DPIR(clip=clip, strength=5.000, task="denoise", provider=1, device_id=0)
  40. # adjusting color space from RGBS to YUV444P16 for vsFlash3kDB
  41. clip = core.resize.Bicubic(clip=clip, format=vs.YUV444P16, matrix_s="170m", range_s="limited", dither_type="error_diffusion")
  42. # debanding using f3kdb
  43. clip = core.f3kdb.Deband(clip, keep_tv_range=True, output_depth=16)
  44. with open("i:/Hybrid/64bit/vsfilters/GLSL/parameterized/Anime4K_Darken_HQ.glsl") as glslf:
  45. glsl = glslf.read()
  46. glsl = glsl.replace('#define STRENGTH 1.5', '#define STRENGTH 2.5')
  47. clip = core.placebo.Shader(clip=clip, shader_s=glsl, width=clip.width, height=clip.height)
  48. from vsswinir import SwinIR
  49. # adjusting color space from YUV444P16 to RGBS for VsSwinIR
  50. clip = core.resize.Bicubic(clip=clip, format=vs.RGBS, matrix_in_s="170m", range_s="limited")
  51. # resizing using SwinIR
  52. clip = SwinIR(clip=clip, task="lightweight_sr", scale=4, device_type="cuda", device_index=0) # 2880x1456
  53. # resizing 2880x1456 to 3840x2160
  54. # adjusting resizing
  55. clip = core.fmtc.resample(clip=clip, w=3840, h=2160, kernel="lanczos", interlaced=False, interlacedd=False)
  56. # adjusting output color from: RGBS to YUV420P10 for x265Model
  57. clip = core.resize.Bicubic(clip=clip, format=vs.YUV420P10, matrix_s="170m", range_s="limited", dither_type="error_diffusion")
  58. # set output frame rate to 23.976fps
  59. clip = core.std.AssumeFPS(clip=clip, fpsnum=24000, fpsden=1001)
  60. # Output
  61. clip.set_output()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement