# Imports
import vapoursynth as vs
# getting Vapoursynth core
import ctypes
import sys
import os
core = vs.core
# Import scripts folder
scriptPath = 'C:/Program Files/Hybrid/64bit/vsscripts'
sys.path.insert(0, os.path.abspath(scriptPath))
# Loading Support Files
Dllref = ctypes.windll.LoadLibrary("C:/Program Files/Hybrid/64bit/vsfilters/Support/libfftw3f-3.dll")
# loading plugins
core.std.LoadPlugin(path="C:/Program Files/Hybrid/64bit/vsfilters/GrainFilter/RemoveGrain/RemoveGrainVS.dll")
core.std.LoadPlugin(path="C:/Program Files/Hybrid/64bit/vsfilters/GrainFilter/AddGrain/AddGrain.dll")
core.std.LoadPlugin(path="C:/Program Files/Hybrid/64bit/vsfilters/DenoiseFilter/DFTTest/DFTTest.dll")
core.std.LoadPlugin(path="C:/Program Files/Hybrid/64bit/vsfilters/DenoiseFilter/NEO_FFT3DFilter/neo-fft3d.dll")
core.std.LoadPlugin(path="C:/Program Files/Hybrid/64bit/vsfilters/Support/EEDI3m.dll")# vsQTGMC
core.std.LoadPlugin(path="C:/Program Files/Hybrid/64bit/vsfilters/ResizeFilter/nnedi3/vsznedi3.dll")
core.std.LoadPlugin(path="C:/Program Files/Hybrid/64bit/vsfilters/Support/libmvtools.dll")
core.std.LoadPlugin(path="C:/Program Files/Hybrid/64bit/vsfilters/Support/scenechange.dll")
core.std.LoadPlugin(path="C:/Program Files/Hybrid/64bit/vsfilters/Support/fmtconv.dll")
core.std.LoadPlugin(path="C:/Program Files/Hybrid/64bit/vsfilters/MiscFilter/MiscFilters/MiscFilters.dll")
core.std.LoadPlugin(path="C:/Program Files/Hybrid/64bit/vsfilters/DeinterlaceFilter/Bwdif/Bwdif.dll")
core.std.LoadPlugin(path="C:/Program Files/Hybrid/64bit/vsfilters/SourceFilter/LSmashSource/LSMASHSource.dll")
# Import scripts
import RGBColor
import havsfunc
import validate
# Source: 'M:\TwemlowIN\GBH-Liverpool-Sony-DMR10.mov'
# Current color space: YUV420P8, bit depth: 8, resolution: 720x576, frame rate: 25fps, scanorder: bottom field first, yuv luminance scale: limited, matrix: 470bg, transfer: bt.709, primaries: bt.601 pal
# Loading M:\TwemlowIN\GBH-Liverpool-Sony-DMR10.mov using LWLibavSource
clip = core.lsmas.LWLibavSource(source="M:/TwemlowIN/GBH-Liverpool-Sony-DMR10.mov", format="YUV420P8", stream_index=0, cache=0, fpsnum=25, prefer_hw=0)
frame = clip.get_frame(0)
# Setting detected color matrix (470bg).
clip = core.std.SetFrameProps(clip=clip, _Matrix=5)
# setting color transfer (709), if it is not set.
if validate.transferIsInvalid(clip):
clip = core.std.SetFrameProps(clip=clip, _Transfer=1)
# setting color primaries info (to 470), if it is not set.
if validate.primariesIsInvalid(clip):
clip = core.std.SetFrameProps(clip=clip, _Primaries=5)
# setting color range to TV (limited) range.
clip = core.std.SetFrameProps(clip=clip, _ColorRange=1)
# making sure frame rate is set to 25fps
clip = core.std.AssumeFPS(clip=clip, fpsnum=25, fpsden=1)
# making sure the detected scan type is set (detected: bottom field first)
clip = core.std.SetFrameProps(clip=clip, _FieldBased=1) # bff
original = clip
# Deinterlacing using QTGMC
clip = havsfunc.QTGMC(Input=clip, Preset="Fast", TFF=False) # new fps: 50
# Making sure content is preceived as frame based
clip = core.std.SetFrameProps(clip=clip, _FieldBased=0) # progressive
# Deinterlacing using QTGMC
original = havsfunc.QTGMC(Input=original, Preset="Fast", TFF=False) # new fps: 50
# Making sure content is preceived as frame based
original = core.std.SetFrameProps(clip=original, _FieldBased=0) # progressive
clip = core.std.CropRel(clip=clip, left=12, right=12, top=2, bottom=6)# cropping to 696x568
# adding crop rectangle to 696x568
original = core.resize.Bicubic(clip=original, format=vs.YUV444P8, range_s="limited")
originalVline = core.std.BlankClip(clip=original, width=1, format=vs.RGB24, color=[50,205,5])
originalHline = core.std.BlankClip(clip=original, height=1,format=vs.RGB24, color=[50,205,5])
originalVline = core.resize.Bicubic(clip=originalVline, format=vs.YUV444P8, matrix_s="470bg", range_s="limited")
originalHline = core.resize.Bicubic(clip=originalHline, format=vs.YUV444P8, matrix_s="470bg", range_s="limited")
original = havsfunc.Overlay(base=original, overlay=originalVline, x=12)
original = havsfunc.Overlay(base=original, overlay=originalVline, x=original.width-12)
original = havsfunc.Overlay(base=original, overlay=originalHline, y=original.height-6)
original = core.resize.Bicubic(clip=original, format=vs.YUV420P8, range_s="limited")
# letterboxing 696x568 to 720x576
borderColor = RGBColor.RGBColor(clip,color="000000")
clip = core.std.AddBorders(clip=clip, left=12, right=12, top=2, bottom=6, color=borderColor)
original = core.text.Text(clip=original,text="Original",scale=1,alignment=7)
clip = core.text.Text(clip=clip,text="Filtered",scale=1,alignment=7)
stacked = core.std.StackHorizontal([original,clip])
stacked = core.resize.Bicubic(clip=stacked, format=vs.YUV422P10, range_s="limited", dither_type="error_diffusion")
# output
stacked.set_output()