Guest User

Untitled

a guest
Oct 22nd, 2024
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.55 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/Support/fmtconv.dll")
  12. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/libmvtools.dll")
  13. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/TCanny.dll")
  14. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DeinterlaceFilter/TIVTC/libtivtc.dll")
  15. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/SourceFilter/DGDecNV/DGDecodeNV.dll")
  16. # Import scripts
  17. import mcdegrainsharp
  18. import validate
  19. # Source: 'C:\Users\Selur\Desktop\fragment.mkv'
  20. # Current color space: YUV420P8, bit depth: 8, resolution: 720x480, frame rate: 29.97fps, scanorder: telecine, yuv luminance scale: limited, matrix: 470bg, transfer: bt.601, primaries: bt.601 ntsc, format: mpeg-2
  21. # Loading C:\Users\Selur\Desktop\fragment.mkv using DGSource
  22. clip = core.dgdecodenv.DGSource("J:/tmp/mkv_01387fde008f41946f510fe24f295f63_853323747.dgi",fieldop=0)# 29.97 fps, scanorder: telecine
  23. frame = clip.get_frame(0)
  24. # setting color matrix to 470bg.
  25. clip = core.std.SetFrameProps(clip, _Matrix=vs.MATRIX_BT470_BG)
  26. # setting color transfer (vs.TRANSFER_BT601), if it is not set.
  27. if validate.transferIsInvalid(clip):
  28. clip = core.std.SetFrameProps(clip=clip, _Transfer=vs.TRANSFER_BT601)
  29. # setting color primaries info (to vs.PRIMARIES_BT470_BG), if it is not set.
  30. if validate.primariesIsInvalid(clip):
  31. clip = core.std.SetFrameProps(clip=clip, _Primaries=vs.PRIMARIES_BT470_BG)
  32. # setting color range to TV (limited) range.
  33. clip = core.std.SetFrameProps(clip=clip, _ColorRange=vs.RANGE_LIMITED)
  34. # making sure frame rate is set to 29.97fps
  35. clip = core.std.AssumeFPS(clip=clip, fpsnum=30000, fpsden=1001)
  36. # making sure the detected scan type is set (detected: telecine)
  37. clip = core.std.SetFrameProps(clip=clip, _FieldBased=vs.FIELD_TOP) # tff
  38. # Deinterlacing using TIVTC
  39. clip = core.tivtc.TFM(clip=clip)
  40. clip = core.tivtc.TDecimate(clip=clip, mode=7, rate=25.0000, dupThresh=0.04, vidThresh=3.50, sceneThresh=15.00, nt=3, denoise=True)# new fps: 25
  41. # Making sure content is preceived as frame based
  42. clip = core.std.SetFrameProps(clip=clip, _FieldBased=vs.FIELD_PROGRESSIVE) # progressive
  43. clip = core.std.Crop(clip=clip, left=10, right=12, top=66, bottom=72)# cropping to 698x342
  44. # removing grain using MCDegrain
  45. clip = mcdegrainsharp.mcdegrainsharp(clip=clip, csharp=0.70)
  46. from vsrealesrgan import realesrgan as RealESRGAN
  47. clip = core.std.AddBorders(clip=clip, left=0, right=2, top=0, bottom=2) # add borders to archive mod 4 (vsRealESRGAN) - 700x344
  48. # adjusting color space from YUV420P8 to RGBS for vsRealESRGAN
  49. clip = core.resize.Bicubic(clip=clip, format=vs.RGBS, matrix_in_s="470bg", range_s="limited")
  50. # resizing using RealESRGAN
  51. clip = RealESRGAN(clip=clip, model=5, device_index=0, denoise_strength=0.30) # 2800x1376
  52. # resizing 2800x1376 to 1280x706
  53. clip = core.std.Crop(clip=clip, left=0, right=8, top=0, bottom=8) # removing borders (vsRealESRGAN) - 2792x1368
  54. # adjusting resizing
  55. clip = core.fmtc.resample(clip=clip, w=1280, h=706, kernel="spline64", interlaced=False, interlacedd=False)
  56. # adjusting output color from: RGBS to YUV420P10 for NVEncModel
  57. clip = core.resize.Bicubic(clip=clip, format=vs.YUV420P10, matrix_s="470bg", range_s="limited", dither_type="error_diffusion")
  58. # set output frame rate to 25fps (progressive)
  59. clip = core.std.AssumeFPS(clip=clip, fpsnum=25, fpsden=1)
  60. # output
  61. clip.set_output()
Advertisement
Add Comment
Please, Sign In to add comment