Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Imports
- import vapoursynth as vs
- # getting Vapoursynth core
- core = vs.core
- # Loading Plugins
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/fmtconv.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DeinterlaceFilter/TIVTC/libtivtc.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/SourceFilter/DGDecNV/DGDecodeNV.dll")
- # defining beforeTFM-function - START
- def beforeTFM(clip):
- p1=core.std.Trim(clip,0,45)
- b1=core.std.Trim(clip,46,59)
- p2=core.std.Trim(clip,60,107)
- b2=core.std.Trim(clip,108,114)
- p3=core.std.Trim(clip,115)
- b1 = core.fmtc.resample(clip=b1, w=720, h=96, kernel="lanczos", interlaced=False, interlacedd=False)
- b1 = core.fmtc.resample(clip=b1, kernel="bicubic", w=720, h=480, interlaced=False, interlacedd=False)
- b1 = core.resize.Bicubic(clip=b1, format=vs.YUV420P8, range_s="limited", dither_type="error_diffusion")
- b2 = core.fmtc.resample(clip=b2, w=720, h=96, kernel="lanczos", interlaced=False, interlacedd=False)
- b2 = core.fmtc.resample(clip=b2, kernel="bicubic", w=720, h=480, interlaced=False, interlacedd=False)
- b2 = core.resize.Bicubic(clip=b2, format=vs.YUV420P8, range_s="limited", dither_type="error_diffusion")
- clip = p1 + b1 + p2 + b2 + p3
- return clip
- # defining beforeTFM-function - END
- # source: 'C:\Users\Selur\Desktop\sample.mpeg'
- # current color space: YUV420P8, bit depth: 8, resolution: 720x480, fps: 29.97, color matrix: 470bg, yuv luminance scale: limited, scanorder: telecine
- # Loading C:\Users\Selur\Desktop\sample.mpeg using DGSource
- clip = core.dgdecodenv.DGSource("J:/tmp/mpeg_5010fc7d62e4d419c506787ec2746b10_853323747.dgi",fieldop=0)# 29.97 fps, scanorder: telecine
- # Setting detected color matrix (470bg).
- clip = core.std.SetFrameProps(clip, _Matrix=5)
- # Setting color transfer info (470bg), when it is not set
- clip = clip if not core.text.FrameProps(clip,'_Transfer') else core.std.SetFrameProps(clip, _Transfer=5)
- # Setting color primaries info (BT.601 NTSC), when it is not set
- clip = clip if not core.text.FrameProps(clip,'_Primaries') else core.std.SetFrameProps(clip, _Primaries=5)
- # Setting color range to TV (limited) range.
- clip = core.std.SetFrameProp(clip=clip, prop="_ColorRange", intval=1)
- # making sure frame rate is set to 29.97
- clip = core.std.AssumeFPS(clip=clip, fpsnum=30000, fpsden=1001)
- clip = core.std.SetFrameProp(clip=clip, prop="_FieldBased", intval=0) # progressive
- # Deinterlacing using TIVTC
- clip = core.tivtc.TFM(clip=clip)
- clip = core.tivtc.TDecimate(clip=clip)# new fps: 23.976
- # Making sure content is preceived as frame based
- clip = core.std.SetFrameProp(clip=clip, prop="_FieldBased", intval=0) # progressive
- # Making sure content is preceived as frame based
- clip = core.std.SetFrameProp(clip=clip, prop="_FieldBased", intval=0) # progressive
- clip = beforeTFM(clip)
- # adjusting color space from YUV420P8 to RGB24 for vsLevels
- clip = core.resize.Bicubic(clip=clip, format=vs.RGB24, matrix_in_s="470bg", range_s="limited")
- # Color Adjustment using Levels on RGB24 (8 bit)
- clip = core.std.Levels(clip=clip, min_in=16, max_in=235, min_out=16, max_out=235)
- # adjusting resolution before resizing
- clip = core.fmtc.resample(clip=clip, w=720, h=96, kernel="lanczos", interlaced=False, interlacedd=False)# before RGB24 after RGB48
- # Resizing using 2 - bicubic
- clip = core.fmtc.resample(clip=clip, kernel="bicubic", w=720, h=480, interlaced=False, interlacedd=False) # resolution 720x480 before RGB48 after RGB48
- # adjusting output color from: RGB48 to YUV420P8 for x264Model
- clip = core.resize.Bicubic(clip=clip, format=vs.YUV420P8, matrix_s="470bg", range_s="limited", dither_type="error_diffusion")
- # set output frame rate to 23.976fps (progressive)
- clip = core.std.AssumeFPS(clip=clip, fpsnum=24000, fpsden=1001)
- # Output
- clip.set_output()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement