Log in

View Full Version : Translating Avisynth Script to Vapoursynth


ENunn
3rd November 2025, 02:13
i'm just now learning how to use vs. i want to translate my vhs processing script that was made in avisynth to vapoursynth. i got most of it down, but there's some that's missing.

my avisynth script:
LoadVirtualDubPlugin("C:\Program Files (x86)\AviSynth+\plugins64+\ccd_64bit.vdf", "ccd", 0)
v = AVISource("J:\virtualdub\tape transfers\opening to two to tango 1989 vhs.avi")
a = lwlibavaudioSource("D:\recordings\opening to two to tango 1989 vhs.flac")
audiodub(v,a)
#delayaudio(1.026)
assumetff().converttoyuv422(matrix="rec601", interlaced=true).convertbits(10)
Levels(60, 1,895, 0, 1020, coring=false,dither=true).tweak(bright=0, cont=1.00, hue=-0, sat=0.850, coring=false, dither=true).convertbits(8)
#turnRight().Histogram().TurnLeft()
Trim(801, 6484)
Mergechroma(separatefields().vinverse().weave())
converttorgb32(matrix="rec601", interlaced=true,chromaresample="point")
e=separatefields().selecteven().CCD(5,0)
o=separatefields().selectodd().CCD(5,0)
interleave(e,o).weave()
converttoyv24(matrix="rec601", interlaced=true,chromaresample="point")
e2=separatefields().selecteven(). ChromaShiftSP(x=0.0,y=0.15)
o2=separatefields().selectodd(). ChromaShiftSP(x=0.0,y=0.15)
interleave(e2,o2).weave()
QTGMC(TR0=2, TR1=2, TR2=2, Rep0=1, Rep1=0, Rep2=4,
\ DCT=5, ThSCD1=300, ThSCD2=110,
\ SourceMatch=3, Lossless=2, Sharpness=0.0, SLMode=0, Sbb=0, MatchPreset="slow",
\ ezdenoise=0.0, ezkeepgrain=1.0, NoiseProcess=2, GrainRestore=0.3, NoiseRestore=0.1, NoisePreset="slow",
\ StabilizeNoise=false, NoiseTR=0, NoiseDeint="generate")
MergeChroma(aWarpSharp2(depth=20))MergeChroma(aWarpSharp2(depth=10))
santiag(strh=3, strv=3, nns=4, nsize=5)
neo_dfttest(sigma=5, tbsize=3, dither=2)
LSFplus(ss_x=1.5, ss_y=1.5, secure=true, Spwr=2, SdmpHi=0, soothe=false, preblur="on", keep=25)
FineDehalo(rx=2.5, ry=2.5)
resizeshader(width=652, kernel="ssim")
#selectodd()
Crop(11, 0, -11, -8)
SuperRes(matrixin="rec601", 2, .43, 0, """nnedi3_rpow2(4, nns=4, cshift="Spline16Resize")""", matrixout="rec709")
#SuperRes(2, .43, 0, """edi_rpow2(2, nns=4, cshift="Spline16Resize")""").SuperRes(2, .43, 0, """edi_rpow2(2, nns=4, cshift="Spline16Resize")""")
x = float(width) / float(height)
resizeshader(width=round(x * 2176),height=2176, kernel="ssim")
converttoyv12(matrix="rec709", interlaced=false,chromaresample="point")
prefetch(6)


my vapoursynth script so far:
import vapoursynth as vs
from functools import partial
from vsdenoise import DFTTest
from vsaa import BWDIF, EEDI3, EEDI2, NNEDI3
import havsfunc as havs

import ctypes
import sys
import os
import adjust

import edi_rpow2

core = vs.core


core.num_threads = 12

from vapoursynth import core
from vsdeinterlace import QTempGaussMC

clip = core.bs.VideoSource(source=rf"J:\virtualdub\tape transfers\opening to two to tango 1989 vhs.avi", fpsnum=30000, fpsden=1001)
audio = core.bs.AudioSource(source=rf"D:\recordings\opening to two to tango 1989 vhs.flac", )
clip = core.fmtc.bitdepth (clip,bits=10)
#clip = core.std.Levels(clip, min_in=64, max_in=940, min_out=0, max_out=1120, planes=0)
clip = core.std.Levels(clip, min_in=68, max_in=940, min_out=0, max_out=1105, planes=0)
clip = adjust.Tweak(clip, sat=0.85)
clip = core.resize.Point(clip, format=vs.YUV444P8)
#clip = core.hist.Classic(clip)
clip = core.std.Trim(clip, first=802, last=6481)
#audio = core.std.AudioTrim(audio, first=802, last=6481)
clip = havs.QTGMC(clip, TR0=2, TR1=2, Rep0=1, Rep1=0, Rep2=4, DCT=5, ThSCD1=300, ThSCD2=110, SourceMatch=3, Lossless=2, Sharpness=0.0, SLMode=0, Sbb=0, MatchPreset="Slow", EZDenoise=0.0, EZKeepGrain=1.0, NoiseProcess=2, GrainRestore=0.3, NoiseRestore=0.1, NoisePreset="Slow", StabilizeNoise=False, NoiseTR=0, NoiseDeint="Generate", TFF=True)
awarpsharp1 = core.warp.AWarpSharp2(clip, depth=20)
awarpsharp2 = core.warp.AWarpSharp2(clip, depth=10)
clip= core.std.ShufflePlanes(clips=[awarpsharp1,awarpsharp1], planes=[0, 1, 2], colorfamily=vs.YUV)
clip= core.std.ShufflePlanes(clips=[awarpsharp2,awarpsharp2], planes=[0, 1, 2], colorfamily=vs.YUV)
clip = havs.santiag(clip, strh=3, strv=3, nns=4, nsize=5)
clip = core.neo_dfttest.DFTTest(clip,sigma=5, tbsize=3, dither=2)
clip = havs.LSFmod(clip, ss_x=1.5, ss_y=1.5, secure=True, Spwr=2, SdmpHi=0, soothe=False, keep=5)
clip = fine_dehalo(clip)
#clip = core.resize.Bicubic(clip, width=652)
clip.set_output(0)
audio.set_output(1)

what i want to translate:
LoadVirtualDubPlugin("C:\Program Files (x86)\AviSynth+\plugins64+\ccd_64bit.vdf", "ccd", 0)
Levels(50, 1,860, 0, 1020, coring=false,dither=true).tweak(bright=0, cont=1.00, hue=-0, sat=0.850, coring=false, dither=true).convertbits(8)
e=separatefields().selecteven().CCD(5,0)
o=separatefields().selectodd().CCD(5,0)
interleave(e,o).weave()
SuperRes(matrixin="rec601", 2, .43, 0, """nnedi3_rpow2(4, nns=4, cshift="Spline16Resize")""", matrixout="rec709")
x = float(width) / float(height)
resizeshader(width=round(x * 2176),height=2176, kernel="ssim")

i do notice that it seems like nothing is really happening after qtgmc. warping, but that's it. not exactly like my avisynth script.

and i probably need some help learning how to trim both audio and video at the same time. is there an easy way to do all this translating and such? anything extra that i need?

Selur
7th November 2025, 15:01
LoadVirtualDubPlugin("C:\Program Files (x86)\AviSynth+\plugins64+\ccd_64bit.vdf", "ccd", 0)
e=separatefields().selecteven().CCD(5,0)
o=separatefields().selectodd().CCD(5,0)
interleave(e,o).weave()

should probably be something like:
# converting interlaced to half-height progressive for filtering (vsCCD) (separate fields)
clip = core.std.SeparateFields(clip, tff=True)
clipEven = clip[::2]
clipEven = core.std.SetFrameProps(clip=clipEven, _FieldBased=vs.FIELD_PROGRESSIVE) # progressive
clipOdd = clip[1::2]
clipOdd = core.std.SetFrameProps(clip=clipOdd, _FieldBased=vs.FIELD_PROGRESSIVE) # progressive

# adjusting color space from YUV420P8 to RGB24 for vsCCD
clipEven = core.resize.Bicubic(clip=clipEven, format=vs.RGB24, matrix_in_s="470bg", range_in_s="limited", range_s="full")
# chroma denoising using CCD
clipEven = core.zsmooth.CCD(clipEven, threshold=5.00, points=[True,True,False])
# adjusting color space from YUV420P8 to RGB24 for vsCCD
clipOdd = core.resize.Bicubic(clip=clipOdd, format=vs.RGB24, matrix_in_s="470bg", range_in_s="limited", range_s="full")
# chroma denoising using CCD
clipOdd = core.zsmooth.CCD(clipOdd, threshold=5.00, points=[True,True,False])

# converting half-height progressive to interlaced
clip = core.std.Interleave([clipOdd, clipEven])
clip = core.std.DoubleWeave(clip=clip, tff=True)
clip = core.std.SelectEvery(clip, 2, 0)
clip = core.std.SetFrameProps(clip=clip, _FieldBased=vs.FIELD_TOP) # tff
when using CCD from zsmooth instead of the VirtualDub plugin. (assuming the source is tff)


convertbits(10)
Levels(50, 1, 860, 0, 1020, coring=false,dither=true)
tweak(bright=0, cont=1.00, hue=-0, sat=0.850, coring=false, dither=true)
convertbits(8)


should be something like:

# adjusting color space from YUV to RGB30 for vsLevels
clip = core.resize.Bicubic(clip=clip, format=vs.RGB30, matrix_in_s="470bg", range_in_s="limited", range_s="full")
# adjusting color using Levels on RGB30 (10 bit)
clip = core.std.Levels(clip, min_in=50, max_in=860, min_out=0, max_out=1020)
# adjusting output color from: RGB30 to YUV444P8
clip = core.resize.Bicubic(clip=clip, format=vs.YUV444P8, matrix_s="470bg", range_in_s="full", range_s="limited")

assuming the input is limited YUV444P8 with 470bg.

Don't know Superres or resizeshader, so I suspect there is no 1:1 alternative for it in Vapoursynth.

Cu Selur