Advertisement
Guest User

DDColor

a guest
Jan 17th, 2024
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.46 KB | None | 0 0
  1. # Imports
  2. import vapoursynth as vs
  3. # getting Vapoursynth core
  4. import ctypes
  5. import site
  6. import sys
  7. import os
  8. core = vs.core
  9. # Import scripts folder
  10. scriptPath = 'F:/Hybrid/64bit/vsscripts'
  11. sys.path.insert(0, os.path.abspath(scriptPath))
  12. # Adding torch dependencies to PATH
  13. path = site.getsitepackages()[0]+'/torch_dependencies/bin/'
  14. ctypes.windll.kernel32.SetDllDirectoryW(path)
  15. path = path.replace('\\', '/')
  16. os.environ["PATH"] = path + os.pathsep + os.environ["PATH"]
  17. # Loading Plugins
  18. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/GrainFilter/RemoveGrain/RemoveGrainVS.dll")
  19. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DenoiseFilter/CTMF/CTMF.dll")
  20. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/libmvtools.dll")
  21. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/SourceFilter/DGDecNV/DGDecodeNV.dll")
  22. # Import scripts
  23. import nnedi3_resample
  24. import mvsfunc
  25. import smdegrain
  26. import havsfunc
  27. import autowhite
  28. import adjust
  29. # source: 'C:\Users\Selur\Desktop\Video.720p.BW.h264.Test_30s.mp4'
  30. # current color space: YUV420P8, bit depth: 8, resolution: 1280x692, fps: 23.976, color matrix: 709, yuv luminance scale: limited, scanorder: progressive
  31. # Loading C:\Users\Selur\Desktop\Video.720p.BW.h264.Test_30s.mp4 using DGSource
  32. clip = core.dgdecodenv.DGSource("J:/tmp/mp4_80d9bd52db8ea63586977a0845f435f4_853323747.dgi")# 23.976 fps, scanorder: progressive
  33. frame = clip.get_frame(0)
  34. # Setting detected color matrix (709).
  35. clip = core.std.SetFrameProps(clip, _Matrix=1)
  36. # Setting color transfer (to 709), if it is not set.
  37. if '_Transfer' not in frame.props or not frame.props['_Transfer']:
  38. clip = core.std.SetFrameProps(clip, _Transfer=1)
  39. # Setting color primaries info (to 1), if it is not set.
  40. if '_Primaries' not in frame.props or not frame.props['_Primaries']:
  41. clip = core.std.SetFrameProps(clip, _Primaries=1)
  42. # Setting color range to TV (limited) range.
  43. clip = core.std.SetFrameProp(clip=clip, prop="_ColorRange", intval=1)
  44. # making sure frame rate is set to 23.976
  45. clip = core.std.AssumeFPS(clip=clip, fpsnum=24000, fpsden=1001)
  46. clip = core.std.SetFrameProp(clip=clip, prop="_FieldBased", intval=0) # progressive
  47. # Color Adjustment
  48. clip = adjust.Tweak(clip=clip, hue=0.00, sat=0.00, cont=1.00, coring=True)
  49. # adjusting color space from YUV420P8 to RGB24 for vsAutoWhite
  50. clip = core.resize.Bicubic(clip=clip, format=vs.RGB24, matrix_in_s="709", range_s="limited")
  51. # adjustint colors using AutoWhite
  52. clip = autowhite.AutoWhite(clip=clip)
  53. # adjusting color space from RGB24 to YUV444P8 for vsSMDegrain
  54. clip = core.resize.Bicubic(clip=clip, format=vs.YUV444P8, matrix_s="709", range_s="limited")
  55. # removing grain using SMDegrain
  56. clip = smdegrain.SMDegrain(input=clip, interlaced=False, dct=1)
  57. from vsscunet import scunet as SCUNet
  58. # adjusting color space from YUV444P8 to RGBS for vsSCUNet
  59. clip = core.resize.Bicubic(clip=clip, format=vs.RGBS, matrix_in_s="709", range_s="limited")
  60. # denoising using SCUNet
  61. clip = SCUNet(clip=clip, model=4, cuda_graphs=True)
  62. # adjusting color space from RGBS to RGBH for vsDDColor
  63. clip = core.resize.Bicubic(clip=clip, format=vs.RGBH, range_s="limited", dither_type="error_diffusion")
  64. # adding colors using DDColor
  65. from vsddcolor import ddcolor
  66. clip = ddcolor(clip=clip, model=1, input_size=256)
  67. # adjusting output color from: RGBH to YUV420P10 for NVEncModel
  68. clip = core.resize.Bicubic(clip=clip, format=vs.YUV420P10, matrix_s="709", range_s="limited", dither_type="error_diffusion")
  69. # Output
  70. clip.set_output()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement