This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

Help with Futurama Telecine
#23
I tried porting the FieldMatch-function:
import vapoursynth as vs
core = vs.core
import qtgmc

def FieldMatch(c: vs.VideoNode) -> vs.VideoNode:
    pp = core.std.DuplicateFrames(c, frames=[0])
    cc = c
    nn = core.std.DeleteFrames(c, frames=[0])

    # Separate fields
    p2 = core.std.SeparateFields(pp)
    c2 = core.std.SeparateFields(cc)
    n2 = core.std.SeparateFields(nn)

    # Create field match candidates
    pc = core.std.DoubleWeave(core.std.Interleave([p2[::2], c2[1::2]])).std.SelectEvery(2, 0)
    cp = core.std.DoubleWeave(core.std.Interleave([c2[::2], p2[1::2]])).std.SelectEvery(2, 0)
    cn = core.std.DoubleWeave(core.std.Interleave([c2[::2], n2[1::2]])).std.SelectEvery(2, 0)
    nc = core.std.DoubleWeave(core.std.Interleave([n2[::2], c2[1::2]])).std.SelectEvery(2, 0)

    deint = qtgmc.QTGMC(cc, Preset="Fast").std.SelectEvery(2, 0)

    # List of all candidates in priority order
    candidates = [cc, nn, cn, nc, pp, cp, pc, deint]

    # Precompute IsCombed for each clip
    combed_flags = [core.tdm.IsCombed(clip, cthresh=12, chroma=True, blockx=16, blocky=32) for clip in candidates]

    def select_frame(n, f):
        for i in range(len(combed_flags) - 1):  # skip deint until end
            if not f[i].props._Combed:
                return candidates[i]
        return candidates[-1]  # fallback to deint if all are combed

    return core.std.FrameEval(cc, eval=lambda n: select_frame(n, [cf.get_frame(n) for cf in combed_flags]))
and used:
# Imports
import vapoursynth as vs
# getting Vapoursynth core
import ctypes
import sys
import os
core = vs.core
# Import scripts folder
scriptPath = 'F:/Hybrid/64bit/vsscripts'
sys.path.insert(0, os.path.abspath(scriptPath))
# Loading Support Files
Dllref = ctypes.windll.LoadLibrary("F:/Hybrid/64bit/vsfilters/Support/libfftw3f-3.dll")
# loading plugins
core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DeinterlaceFilter/TIVTC/libtivtc.dll")
core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/MiscFilter/MiscFilters/MiscFilters.dll")
core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/GrainFilter/AddGrain/AddGrain.dll")
core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DenoiseFilter/NEO_FFT3DFilter/neo-fft3d.dll")
core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DenoiseFilter/DFTTest/DFTTest.dll")
core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/EEDI3m.dll")# DeinterlaceFilter-Selector
core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/ResizeFilter/nnedi3/vsznedi3.dll")
core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DeinterlaceFilter/TDeintMod/TDeintMod.dll")
core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/libmvtools.dll")
core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/fmtconv.dll")
core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/akarin.dll")
core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/TCanny.dll")
core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/SourceFilter/BestSource/BestSource.dll")

core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DenoiseFilter/ZSmooth/zsmooth.dll")
core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DenoiseFilter/CTMF/CTMF.dll")

# Import scripts
import qtgmc
import smdegrain
import validate
# Source: 'G:\Usenet\Incoming\Futurama S01E01 Space Pilot 3000 DVD.mkv'
# Current color space: YUV420P8, bit depth: 8, resolution: 720x480, frame rate: 29.97fps, scanorder: telecine (soft), yuv luminance scale: limited, matrix: 470bg, transfer: bt.601, primaries: bt.601 ntsc, format: mpeg-2
# Loading G:\Usenet\Incoming\Futurama S01E01 Space Pilot 3000 DVD.mkv using BestSource)
clip = core.bs.VideoSource(source="G:/Usenet/Incoming/Futurama S01E01 Space Pilot 3000 DVD.mkv", cachepath="J:/tmp/Futurama S01E01 Space Pilot 3000 DVD_bestSource", track=0, hwdevice="opencl")
frame = clip.get_frame(0)
# setting color matrix to 470bg.
clip = core.std.SetFrameProps(clip, _Matrix=vs.MATRIX_BT470_BG)
# setting color transfer (vs.TRANSFER_BT601), if it is not set.
if validate.transferIsInvalid(clip):
  clip = core.std.SetFrameProps(clip=clip, _Transfer=vs.TRANSFER_BT601)
# setting color primaries info (to vs.PRIMARIES_BT470_BG), if it is not set.
if validate.primariesIsInvalid(clip):
  clip = core.std.SetFrameProps(clip=clip, _Primaries=vs.PRIMARIES_BT470_BG)
# setting color range to TV (limited) range.
clip = core.std.SetFrameProps(clip=clip, _ColorRange=vs.RANGE_LIMITED)
# making sure frame rate is set to 29.97fps
clip = core.std.AssumeFPS(clip=clip, fpsnum=30000, fpsden=1001)
# making sure the detected scan type is set (detected: telecine (soft))
clip = core.std.SetFrameProps(clip=clip, _FieldBased=vs.FIELD_TOP) # tff
# removing grain using SMDegrain
clip = smdegrain.SMDegrain(input=clip, tr=3, thSAD=1300, thSADC=2400, interlaced=True, tff=True, opencl=True, device=-1)
# Deinterlacing using TIVTC
import fieldmatch
clip = core.tivtc.TFM(clip=clip, mode=5, clip2=fieldmatch.FieldMatch(clip),slow=2,mChroma=False,ubsco=False,scthresh=12,chroma=True)
clip = core.tivtc.TDecimate(clip=clip, mode=1)# new fps: 23.976

# Making sure content is preceived as frame based
clip = core.std.SetFrameProps(clip=clip, _FieldBased=vs.FIELD_PROGRESSIVE) # progressive
# adjusting output color from: YUV420P8 to YUV420P10 for NVEncModel
clip = core.resize.Bicubic(clip=clip, format=vs.YUV420P10, range_s="limited")
# set output frame rate to 23.976fps (progressive)
clip = core.std.AssumeFPS(clip=clip, fpsnum=24000, fpsden=1001)
# output
clip.set_output()
but one still ends up with broken frames:
[Image: grafik.png]
[Image: grafik.png]
[Image: grafik.png]
my previous try:
# removing grain using SMDegrain
clip = smdegrain.SMDegrain(input=clip, tr=3, thSADC=2400, interlaced=True, opencl=True, device=-1, tff=False)
clip2clip = clip
clip2clip = qtgmc.QTGMC(Input=clip2clip, Preset="fast", opencl=True, TFF=False, FPSDivisor=2)
# Deinterlacing using TIVTC
clip = core.tivtc.TFM(clip=clip, mode=5, blockx=64, blocky=64, MI=64, clip2=clip2clip)
clip = core.tivtc.TDecimate(clip=clip, mode=7, rate=23.9760, dupThresh=0.04, vidThresh=3.50, sceneThresh=15.00, blockx=16, blocky=16)# new fps: 23.976
# Making sure content is preceived as frame based
clip = core.std.SetFrameProps(clip=clip, _FieldBased=vs.FIELD_PROGRESSIVE) # progressive
# denoising using mClean
clip = denoise.mClean(clip=clip)
seems to perform better here (and can be directly set in Hybrid)

Cu Selur
----
Dev versions are in the 'experimental'-folder of my GoogleDrive, which is linked on the download page.
Reply


Messages In This Thread
Help with Futurama Telecine - by protectron - 07.07.2025, 05:50
RE: Help with Futurama Telecine - by Selur - 07.07.2025, 05:52
RE: Help with Futurama Telecine - by Selur - 07.07.2025, 12:25
RE: Help with Futurama Telecine - by Selur - 07.07.2025, 15:45
RE: Help with Futurama Telecine - by Selur - 07.07.2025, 16:09
RE: Help with Futurama Telecine - by Selur - 07.07.2025, 16:39
RE: Help with Futurama Telecine - by Selur - 07.07.2025, 18:43
RE: Help with Futurama Telecine - by Selur - 07.07.2025, 19:34
RE: Help with Futurama Telecine - by Selur - 07.07.2025, 21:53
RE: Help with Futurama Telecine - by Selur - 08.07.2025, 04:45
RE: Help with Futurama Telecine - by Selur - 08.07.2025, 11:11
RE: Help with Futurama Telecine - by Selur - 08.07.2025, 17:54
RE: Help with Futurama Telecine - by Selur - 08.07.2025, 18:17
RE: Help with Futurama Telecine - by Selur - 09.07.2025, 05:25
RE: Help with Futurama Telecine - by Selur - 09.07.2025, 17:02
RE: Help with Futurama Telecine - by Selur - 11.07.2025, 04:34

Forum Jump:


Users browsing this thread: 1 Guest(s)