Advertisement
Guest User

Untitled

a guest
May 23rd, 2023
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.75 KB | None | 0 0
  1. # Imports
  2. import vapoursynth as vs
  3. # getting Vapoursynth core
  4. core = vs.core
  5. # Loading Plugins
  6. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/fmtconv.dll")
  7. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DeinterlaceFilter/TIVTC/libtivtc.dll")
  8. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/SourceFilter/DGDecNV/DGDecodeNV.dll")
  9. # defining beforeTFM-function - START
  10. def beforeTFM(clip):
  11. p1=core.std.Trim(clip,0,45)
  12. b1=core.std.Trim(clip,46,59)
  13. p2=core.std.Trim(clip,60,107)
  14. b2=core.std.Trim(clip,108,114)
  15. p3=core.std.Trim(clip,115)
  16.  
  17. b1 = core.fmtc.resample(clip=b1, w=720, h=96, kernel="lanczos", interlaced=False, interlacedd=False)
  18. b1 = core.fmtc.resample(clip=b1, kernel="bicubic", w=720, h=480, interlaced=False, interlacedd=False)
  19. b1 = core.resize.Bicubic(clip=b1, format=vs.YUV420P8, range_s="limited", dither_type="error_diffusion")
  20.  
  21. b2 = core.fmtc.resample(clip=b2, w=720, h=96, kernel="lanczos", interlaced=False, interlacedd=False)
  22. b2 = core.fmtc.resample(clip=b2, kernel="bicubic", w=720, h=480, interlaced=False, interlacedd=False)
  23. b2 = core.resize.Bicubic(clip=b2, format=vs.YUV420P8, range_s="limited", dither_type="error_diffusion")
  24. clip = p1 + b1 + p2 + b2 + p3
  25. return clip
  26. # defining beforeTFM-function - END
  27.  
  28. # source: 'C:\Users\Selur\Desktop\sample.mpeg'
  29. # current color space: YUV420P8, bit depth: 8, resolution: 720x480, fps: 29.97, color matrix: 470bg, yuv luminance scale: limited, scanorder: telecine
  30. # Loading C:\Users\Selur\Desktop\sample.mpeg using DGSource
  31. clip = core.dgdecodenv.DGSource("J:/tmp/mpeg_5010fc7d62e4d419c506787ec2746b10_853323747.dgi",fieldop=0)# 29.97 fps, scanorder: telecine
  32. # Setting detected color matrix (470bg).
  33. clip = core.std.SetFrameProps(clip, _Matrix=5)
  34. # Setting color transfer info (470bg), when it is not set
  35. clip = clip if not core.text.FrameProps(clip,'_Transfer') else core.std.SetFrameProps(clip, _Transfer=5)
  36. # Setting color primaries info (BT.601 NTSC), when it is not set
  37. clip = clip if not core.text.FrameProps(clip,'_Primaries') else core.std.SetFrameProps(clip, _Primaries=5)
  38. # Setting color range to TV (limited) range.
  39. clip = core.std.SetFrameProp(clip=clip, prop="_ColorRange", intval=1)
  40. # making sure frame rate is set to 29.97
  41. clip = core.std.AssumeFPS(clip=clip, fpsnum=30000, fpsden=1001)
  42. clip = core.std.SetFrameProp(clip=clip, prop="_FieldBased", intval=0) # progressive
  43. # Deinterlacing using TIVTC
  44. clip = core.tivtc.TFM(clip=clip)
  45. clip = core.tivtc.TDecimate(clip=clip)# new fps: 23.976
  46. # Making sure content is preceived as frame based
  47. clip = core.std.SetFrameProp(clip=clip, prop="_FieldBased", intval=0) # progressive
  48. # Making sure content is preceived as frame based
  49. clip = core.std.SetFrameProp(clip=clip, prop="_FieldBased", intval=0) # progressive
  50. clip = beforeTFM(clip)
  51. # adjusting color space from YUV420P8 to RGB24 for vsLevels
  52. clip = core.resize.Bicubic(clip=clip, format=vs.RGB24, matrix_in_s="470bg", range_s="limited")
  53. # Color Adjustment using Levels on RGB24 (8 bit)
  54. clip = core.std.Levels(clip=clip, min_in=16, max_in=235, min_out=16, max_out=235)
  55. # adjusting resolution before resizing
  56. clip = core.fmtc.resample(clip=clip, w=720, h=96, kernel="lanczos", interlaced=False, interlacedd=False)# before RGB24 after RGB48
  57. # Resizing using 2 - bicubic
  58. clip = core.fmtc.resample(clip=clip, kernel="bicubic", w=720, h=480, interlaced=False, interlacedd=False) # resolution 720x480 before RGB48 after RGB48
  59. # adjusting output color from: RGB48 to YUV420P8 for x264Model
  60. clip = core.resize.Bicubic(clip=clip, format=vs.YUV420P8, matrix_s="470bg", range_s="limited", dither_type="error_diffusion")
  61. # set output frame rate to 23.976fps (progressive)
  62. clip = core.std.AssumeFPS(clip=clip, fpsnum=24000, fpsden=1001)
  63. # Output
  64. clip.set_output()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement