Advertisement
Guest User

deblock dark

a guest
May 29th, 2023
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.81 KB | None | 0 0
  1. # Imports
  2. import vapoursynth as vs
  3. import os
  4. import sys
  5. os.environ["CUDA_MODULE_LOADING"] = "LAZY"
  6. # getting Vapoursynth core
  7. core = vs.core
  8. # Import scripts folder
  9. scriptPath = 'F:/Hybrid/64bit/vsscripts'
  10. sys.path.insert(0, os.path.abspath(scriptPath))
  11. # Loading Plugins
  12. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/ColorFilter/Retinex/Retinex.dll")
  13. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DebandFilter/Flash3kDeband/flash3kyuu_deband.dll")
  14. core.std.LoadPlugin(path="F:/Hybrid/64bit/vs-mlrt/vstrt.dll")
  15. import site
  16. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/SourceFilter/LSmashSource/vslsmashsource.dll")
  17. # Import scripts
  18. from importlib.machinery import SourceFileLoader
  19. vsmlrt = SourceFileLoader('vsmlrt', 'F:/Hybrid/64bit/vs-mlrt/vsmlrt.py').load_module()
  20. import masked
  21. # source: 'C:\Users\Selur\Desktop\wind noise.mkv'
  22. # current color space: YUV420P8, bit depth: 8, resolution: 1024x576, fps: 59.94, color matrix: 709, yuv luminance scale: limited, scanorder: progressive
  23. # Loading C:\Users\Selur\Desktop\wind noise.mkv using LWLibavSource
  24. clip = core.lsmas.LWLibavSource(source="C:/Users/Selur/Desktop/wind noise.mkv", format="YUV420P8", stream_index=0, cache=0, prefer_hw=0)
  25. # Setting detected color matrix (709).
  26. clip = core.std.SetFrameProps(clip, _Matrix=1)
  27. # Setting color transfer info (709), when it is not set
  28. clip = clip if not core.text.FrameProps(clip,'_Transfer') else core.std.SetFrameProps(clip, _Transfer=1)
  29. # Setting color primaries info (), when it is not set
  30. clip = clip if not core.text.FrameProps(clip,'_Primaries') else core.std.SetFrameProps(clip, _Primaries=5)
  31. # Setting color range to TV (limited) range.
  32. clip = core.std.SetFrameProp(clip=clip, prop="_ColorRange", intval=1)
  33. # making sure frame rate is set to 59.94
  34. clip = core.std.AssumeFPS(clip=clip, fpsnum=60000, fpsden=1001)
  35. clip = core.std.SetFrameProp(clip=clip, prop="_FieldBased", intval=0) # progressive
  36. from vsmlrt import Backend
  37. ## Starting applying 'limit' masked filtering for vsDPIRmlrtDeblock
  38. clipMask = clip
  39. clipMask = core.resize.Bicubic(clip=clipMask, format=vs.RGBS, matrix_in_s="709", range_s="limited")
  40. clipMask = core.resize.Bicubic(clip=clipMask, format=vs.GRAYS, matrix_s="709", range_s="limited")
  41. clipMask = core.std.BinarizeMask(clipMask, 0.117647)
  42. clipMask = core.std.InvertMask(clipMask)
  43. clipFiltered = clip
  44. # adjusting color space from YUV420P8 to RGBS for vsDPIRmlrtDeblock
  45. clipFiltered = core.resize.Bicubic(clip=clipFiltered, format=vs.RGBS, matrix_in_s="709", range_s="limited")
  46. # adjusting deblocking using DPIR (mlrt)
  47. clipFiltered = vsmlrt.DPIR(clipFiltered, strength=50.000, overlap=16, model=3, backend=Backend.TRT(fp16=False, device_id=0,verbose=True,use_cuda_graph=False, num_streams=1, workspace=1 << 30))
  48. clip = core.resize.Bicubic(clip=clip, format=vs.RGBS, matrix_in_s="709", range_s="limited")
  49. clip = core.std.MaskedMerge(clip, clipFiltered, clipMask) # LimitMask
  50. ## Finished applying 'LimitMask' masked filtering for vsDPIRmlrtDeblock
  51. # adjusting color space from RGBS to YUV444P16 for vsFlash3kDB
  52. clip = core.resize.Bicubic(clip=clip, format=vs.YUV444P16, matrix_s="709", range_s="limited", dither_type="error_diffusion")
  53. # debanding using f3kdb
  54. clip = core.f3kdb.Deband(clip, keep_tv_range=True, output_depth=-1)
  55. # adjusting color space from YUV444P16 to YUV444P10 for vsRetinex
  56. clip = core.resize.Bicubic(clip=clip, format=vs.YUV444P10, range_s="limited")
  57. # color adjustment using Retinex
  58. clip = core.retinex.MSRCP(input=clip, sigma=[25,80,250], fulls=False, fulld=False)
  59. # adjusting output color from: YUV444P10 to YUV420P8 for x264Model
  60. clip = core.resize.Bicubic(clip=clip, dither_type="error_diffusion", format=vs.YUV420P8, range_s="limited")
  61. # set output frame rate to 59.94fps (progressive)
  62. clip = core.std.AssumeFPS(clip=clip, fpsnum=60000, fpsden=1001)
  63. # Output
  64. clip.set_output()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement