Guest User

machine learning deinterlaced

a guest
Jul 9th, 2026
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.23 KB | None | 0 0
  1. # Imports
  2. import ctypes
  3. import sys
  4. import os
  5. import vapoursynth as vs
  6. # getting Vapoursynth core
  7. core = vs.core
  8. # Limit frame cache to 48449MB
  9. core.max_cache_size = 48449
  10. # Import scripts folder
  11. scriptPath = 'F:/Hybrid/64bit/vsscripts'
  12. sys.path.insert(0, os.path.abspath(scriptPath))
  13. # Loading Support Files
  14. Dllref = ctypes.windll.LoadLibrary("F:/Hybrid/64bit/vsfilters/Support/libfftw3f-3.dll")
  15. # loading plugins
  16. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/FrameFilter/ReduceFlicker/ReduceFlicker.dll")
  17. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DenoiseFilter/VInverse/vinverse_vs.dll")
  18. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DenoiseFilter/NEO_FFT3DFilter/neo-fft3d.dll")
  19. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DenoiseFilter/DFTTest/DFTTest.dll")
  20. core.std.LoadPlugin(path="F:/Hybrid/64bit/Vapoursynth/Lib/site-packages/vapoursynth/plugins2/bwdif.dll")
  21. core.std.LoadPlugin(path="F:/Hybrid/64bit/Vapoursynth/Lib/site-packages/vapoursynth/plugins2/fmtconv.dll")
  22. core.std.LoadPlugin(path="F:/Hybrid/64bit/Vapoursynth/Lib/site-packages/vapoursynth/plugins2/sneedif/libsneedif.dll")
  23. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/libeedi3vk.dll")
  24. core.std.LoadPlugin(path="F:/Hybrid/64bit/Vapoursynth/Lib/site-packages/vapoursynth/plugins2/addnoise.dll")
  25. core.std.LoadPlugin(path="F:/Hybrid/64bit/Vapoursynth/Lib/site-packages/vapoursynth/plugins2/mvtools.dll")
  26. core.std.LoadPlugin(path="F:/Hybrid/64bit/Vapoursynth/Lib/site-packages/vapoursynth/plugins2/akarin/libakarin.dll")
  27. core.std.LoadPlugin(path="F:/Hybrid/64bit/Vapoursynth/Lib/site-packages/vapoursynth/plugins2/zsmooth/zsmooth.dll")
  28. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/SourceFilter/DGDecNV/DGDecodeNV_AVX2.dll")
  29. # Import scripts
  30. import edi_rpow2
  31. import vs_deepdeinterlace
  32. import qtgmc
  33. import validate
  34. # Source: 'C:\Users\Selur\Desktop\outro.mkv'
  35. # clip current meta; color space: YUV420P8, bit depth: 8, resolution: 720x480, fps: 29.97, color matrix: 470bg, color primaries: Unspecific, color transfer: Unspecified, yuv luminance scale: limited, scanorder: top field first, full height: true (Source)
  36. # Loading 'C:\Users\Selur\Desktop\outro.mkv' using DGSource
  37. clip = core.dgdecodenv.DGSource("J:/tmp/mkv_2a601c9176f4fc6ae8cf25e52bec66c0_853323747.dgi",fieldop=0) # 29.97 fps, scanorder: top field first
  38. frame = clip.get_frame(0)
  39. # setting color matrix to 470bg.
  40. clip = core.std.SetFrameProps(clip, _Matrix=vs.MATRIX_BT470_BG)
  41. # setting color transfer (vs.TRANSFER_BT601), if it is not set.
  42. if validate.transferIsInvalid(clip):
  43. clip = core.std.SetFrameProps(clip=clip, _Transfer=vs.TRANSFER_BT601)
  44. # setting color primaries info (to vs.PRIMARIES_BT470_BG), if it is not set.
  45. if validate.primariesIsInvalid(clip):
  46. clip = core.std.SetFrameProps(clip=clip, _Primaries=vs.PRIMARIES_BT470_BG)
  47. # setting color range to TV (limited) range.
  48. prop_name = '_Range' if core.core_version.release_major >= 74 else '_ColorRange'
  49. clip = core.std.SetFrameProps(clip=clip, **{prop_name: vs.RANGE_LIMITED})
  50. # making sure frame rate is set to 29.97fps
  51. clip = core.std.AssumeFPS(clip=clip, fpsnum=30000, fpsden=1001)
  52. # making sure the detected scan type is set (detected: top field first)
  53. clip = core.std.SetFrameProps(clip=clip, _FieldBased=vs.FIELD_TOP) # scan type: top field first
  54. # Deinterlacing using QTGMC
  55. clipEdiExt = clip
  56. # adjusting color space from YUV420P8 to RGBS for vsDDD
  57. clipEdiExt = core.resize.Bicubic(clip=clipEdiExt, format=vs.RGBS, matrix_in_s="470bg", range_in_s="limited", range_s="full")
  58. clipEdiExt = vs_deepdeinterlace.DDD(clipEdiExt, tff=True, fp16=True, device="cuda")
  59. # Making sure content is preceived as frame based
  60. clipEdiExt = core.std.SetFrameProps(clip=clipEdiExt, _FieldBased=vs.FIELD_PROGRESSIVE) # scan type: progressive
  61. clipEdiExt = core.resize.Bicubic(clip=clipEdiExt, format=vs.YUV420P8, matrix_s="470bg", range_in_s="full", range_s="limited", dither_type="error_diffusion")
  62. clip = qtgmc.QTGMC(Input=clip, Preset="Slower", InputType=0, TFF=True, TR2=1, SourceMatch=0, Lossless=0, opencl=True, EdiExt=clipEdiExt) # new fps: 59.94
  63. # Making sure content is preceived as frame based
  64. clip = core.std.SetFrameProps(clip=clip, _FieldBased=vs.FIELD_PROGRESSIVE) # scan type: progressive
  65. clip = core.vinverse.vinverse(clip)
  66. # removing flickering using ReduceFlicker
  67. clip = core.rdfl.ReduceFlicker(clip, strength=3, aggressive=1)
  68. # resizing using NNEDI3CL
  69. # current: 720x480 target: 1280x960
  70. clip = edi_rpow2.nnedi3cl_rpow2(clip, rfactor=2, nsize=3, nns=4) # 1440x960
  71. # resizing 1440x960 to 1280x960
  72. clip = core.fmtc.resample(clip, w=1280, h=960, kernel="spline64", interlaced=False, interlacedd=False) # before YUV420P8 after YUV420P16
  73. # adjusting output color from YUV420P16 to YUV420P10 for NVEncModel
  74. clip = core.resize.Bicubic(clip=clip, format=vs.YUV420P10, dither_type="error_diffusion")
  75. # set output frame rate to 59.94fps (progressive)
  76. clip = core.std.AssumeFPS(clip=clip, fpsnum=60000, fpsden=1001)
  77. # output
  78. clip.set_output()
  79. # clip current meta; color space: YUV420P10, bit depth: 10, resolution: 1280x960, fps: 59.94, color matrix: 470bg, color primaries: Unspecific, color transfer: Unspecified, yuv luminance scale: limited, scanorder: progressive, full height: true (Meta)
  80. # script was created by Hybrid 2026.07.08.1
Advertisement
Add Comment
Please, Sign In to add comment