Guest User

Color Adjustement Vapoursynth

a guest
Jul 30th, 2026
9
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.26 KB | None | 0 0
  1. # Imports
  2. import sys
  3. import os
  4. import vapoursynth as vs
  5. # using Vapoursynth R78
  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 plugins
  14. core.std.LoadPlugin(path="F:/Hybrid/64bit/Vapoursynth/Lib/site-packages/vapoursynth/plugins2/fmtconv.dll")
  15. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/SharpenFilter/AWarpSharp2/libawarpsharp2.dll")
  16. core.std.LoadPlugin(path="F:/Hybrid/64bit/Vapoursynth/Lib/site-packages/vapoursynth/plugins2/zsmooth/zsmooth.dll")
  17. core.std.LoadPlugin(path="F:/Hybrid/64bit/Vapoursynth/Lib/site-packages/vapoursynth/plugins2/mvutensils/mvutensils.dll")
  18. core.std.LoadPlugin(path="F:/Hybrid/64bit/Vapoursynth/Lib/site-packages/vapoursynth/plugins2/akarin/libakarin.dll")
  19. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/SourceFilter/DGDecNV/DGDecodeNV_AVX2.dll")
  20. # Import scripts
  21. import sharpen
  22. import edge
  23. import SpotLess
  24. import color
  25. import chromashift
  26. import validate
  27. # Source: 'C:\Users\Selur\Desktop\U-MATIC.mp4'
  28. # clip current meta; color space: YUV420P8, bit depth: 8, resolution: 960x720, fps: 59.94, color matrix: 709, color primaries: Unspecific, color transfer: BT.709, yuv luminance scale: limited, scanorder: progressive, full height: true (Source)
  29. # Loading 'C:\Users\Selur\Desktop\U-MATIC.mp4' using DGSource
  30. clip = core.dgdecodenv.DGSource("J:/tmp/mp4_e1f516cc55688f3f8b976a560aca7ee4_853323747.dgi") # 59.94 fps, scanorder: progressive
  31. frame = clip.get_frame(0)
  32. # setting color matrix to 709.
  33. clip = core.std.SetFrameProps(clip, _Matrix=vs.MATRIX_BT709)
  34. # setting color transfer (vs.TRANSFER_BT709), if it is not set.
  35. if validate.transferIsInvalid(clip):
  36. clip = core.std.SetFrameProps(clip=clip, _Transfer=vs.TRANSFER_BT709)
  37. # setting color primaries info (to vs.PRIMARIES_BT709), if it is not set.
  38. if validate.primariesIsInvalid(clip):
  39. clip = core.std.SetFrameProps(clip=clip, _Primaries=vs.PRIMARIES_BT709)
  40. # setting color range to TV (limited) range.
  41. prop_name = '_Range' if core.core_version.release_major >= 74 else '_ColorRange'
  42. clip = core.std.SetFrameProps(clip=clip, **{prop_name: vs.RANGE_LIMITED})
  43. # making sure frame rate is set to 59.94fps
  44. clip = core.std.AssumeFPS(clip=clip, fpsnum=60000, fpsden=1001)
  45. # making sure the detected scan type is set (detected: progressive)
  46. clip = core.std.SetFrameProps(clip=clip, _FieldBased=vs.FIELD_PROGRESSIVE) # scan type: progressive
  47. # Chroma adjustment using ChromaShiftSP
  48. clip = chromashift.ChromaShiftSP(clip, X=10.00)
  49. # adjusting color space from YUV420P8 to RGB24 for vsRGBAdjust
  50. clip = core.resize.Bicubic(clip=clip, format=vs.RGB24, matrix_in_s="709", range_in_s="limited", range_s="full")
  51. # color adjustment using RGBAdjust
  52. clip = color.RGBAdjust(clip, rb=-30.000, gb=-10.000, bb=-15.000, rg=1.100, gg=1.200, bg=1.100)
  53. # adjusting color space from RGB24 to YUV444P8 for vsSpotLess
  54. clip = core.resize.Bicubic(clip=clip, format=vs.YUV444P8, matrix_s="709", range_in_s="full", range_s="limited")
  55. # Spot removal using SpotLess
  56. clip = SpotLess.SpotLess(clip, radT=3, rec=True, pel=1)
  57. clip = core.std.Crop(clip, left=20, right=20, top=0, bottom=0) # cropping to 920x720
  58. # Fix bright and dark line artifacts near the border of an image using BalanceBorders
  59. clip = edge.bbmod(clip, cLeft=0, cTop=0, cRight=12, cBottom=0)
  60. # sharpening using AWarpSharp2
  61. clip = sharpen.AWarpSharp2(clip, blur=2, depth=32, chroma=True, planes=[1,2])
  62. # Resizing using 10 - bicubic spline
  63. clip = core.fmtc.resample(clip, kernel="spline16", w=1920, h=1504, interlaced=False, interlacedd=False) # resolution 1920x1504 before YUV444P8 after YUV444P16
  64. # adjusting output color from YUV444P16 to YUV420P10 for NVEncModel
  65. clip = core.resize.Bicubic(clip=clip, format=vs.YUV420P10, dither_type="error_diffusion")
  66. # set output frame rate to 59.94fps (progressive)
  67. clip = core.std.AssumeFPS(clip=clip, fpsnum=60000, fpsden=1001)
  68. # output
  69. clip.set_output()
  70. # clip current meta; color space: YUV420P10, bit depth: 10, resolution: 1920x1504, fps: 59.94, color matrix: 709, color primaries: Unspecific, color transfer: BT.709, yuv luminance scale: limited, scanorder: progressive, full height: true (Meta)
  71. # script was created by Hybrid 2026.07.30.1
Advertisement
Add Comment
Please, Sign In to add comment