Advertisement
Guest User

Untitled

a guest
Sep 15th, 2023
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.74 KB | None | 0 0
  1. # Imports
  2. import vapoursynth as vs
  3. import os
  4. import sys
  5. # getting Vapoursynth core
  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/Support/libvs_placebo.dll")
  12. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/SharpenFilter/AWarpSharp2/libawarpsharp2.dll")
  13. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/fmtconv.dll")
  14. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/SourceFilter/DGDecNV/DGDecodeNV.dll")
  15. # Import scripts
  16. import chromashift
  17. import muvsfunc
  18. import mvsfunc
  19. # source: 'C:\Users\Selur\Desktop\Gym Snip.mp4'
  20. # current color space: YUV420P8, bit depth: 8, resolution: 642x480, fps: 29.97, color matrix: 470bg, yuv luminance scale: limited, scanorder: progressive
  21. # Loading C:\Users\Selur\Desktop\Gym Snip.mp4 using DGSource
  22. clip = core.dgdecodenv.DGSource("J:/tmp/mp4_076c6c66888029ce51821890f630a438_853323747.dgi")# 29.97 fps, scanorder: progressive
  23. # Setting detected color matrix (470bg).
  24. clip = core.std.SetFrameProps(clip, _Matrix=5)
  25. # Setting color transfer info (470bg), when it is not set
  26. clip = clip if not core.text.FrameProps(clip,'_Transfer') else core.std.SetFrameProps(clip, _Transfer=5)
  27. # Setting color primaries info (BT.601 NTSC), when it is not set
  28. clip = clip if not core.text.FrameProps(clip,'_Primaries') else core.std.SetFrameProps(clip, _Primaries=5)
  29. # Setting color range to TV (limited) range.
  30. clip = core.std.SetFrameProp(clip=clip, prop="_ColorRange", intval=1)
  31. # making sure frame rate is set to 29.97
  32. clip = core.std.AssumeFPS(clip=clip, fpsnum=30000, fpsden=1001)
  33. clip = core.std.SetFrameProp(clip=clip, prop="_FieldBased", intval=0) # progressive
  34. # Color Adjustment using SmoothGrad
  35. clip = muvsfunc.SmoothGrad(input=clip)
  36. # Chroma adjustment using ChromaShiftSP
  37. clip = chromashift.ChromaShiftSP(clip=clip, X=-5.50, shiftV=False)
  38. # adjusting resolution before resizing
  39. clip = core.fmtc.resample(clip=clip, w=642, h=240, kernel="lanczos", interlaced=False, interlacedd=False)# before YUV420P8 after YUV420P16
  40. # Resizing using 10 - bicubic spline
  41. clip = core.fmtc.resample(clip=clip, kernel="spline16", w=642, h=480, interlaced=False, interlacedd=False) # resolution 642x480 before YUV420P16 after YUV420P16
  42. # sharpening using AWarpSharp2
  43. clip = core.warp.AWarpSharp2(clip=clip, blur=2, depth=32, chroma=True, planes=[1,2])
  44. # adjusting color space from YUV420P16 to YUV444P16 for vsGLSLFilmGrain
  45. clip = core.resize.Bicubic(clip=clip, format=vs.YUV444P16, range_s="limited", dither_type="error_diffusion")
  46. with open("F:/Hybrid/64bit/vsfilters/GLSL/parameterized/filmgrain.glsl") as glslf:
  47. glsl = glslf.read()
  48. glsl = glsl.replace('#define INTENSITY 0.05', '#define INTENSITY 0.02')
  49. clip = core.placebo.Shader(clip=clip, shader_s=glsl, width=clip.width, height=clip.height)
  50. clip = core.std.AddBorders(clip=clip, left=4, right=4, top=0, bottom=0) # add borders to archive mod 8 (vsBasicVSRPPFilter) - 650x480
  51. # adjusting color space from YUV444P16 to RGBH for vsBasicVSRPPFilter
  52. clip = core.resize.Bicubic(clip=clip, format=vs.RGBH, matrix_in_s="470bg", range_s="limited")
  53. # Quality enhancement using BasicVSR++
  54. from vsbasicvsrpp import basicvsrpp as BasicVSRPP
  55. clip = BasicVSRPP(clip=clip, model=4, length=20)
  56. clip = core.std.CropRel(clip=clip, left=4, right=4, top=0, bottom=0) # removing borders (vsBasicVSRPPFilter) - 642x480
  57. # adjusting output color from: RGBH to YUV420P10 for QSVEncModel
  58. clip = core.resize.Bicubic(clip=clip, format=vs.YUV420P10, matrix_s="470bg", range_s="limited", dither_type="error_diffusion")
  59. # set output frame rate to 29.97fps (progressive)
  60. clip = core.std.AssumeFPS(clip=clip, fpsnum=30000, fpsden=1001)
  61. # Output
  62. clip.set_output()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement