Log in

View Full Version : Vapoursynth: Telecine with VIVIC


jay123210599
14th January 2025, 21:55
How do I accomplish these tasks in Vapoursynth, or just the last part, at least?

Automatic comparisons with telecine sources can be improved by utilizing VIVTC's frameprops.
The comparison tool can skip frames marked with the Combed property to avoid leftover interlaced frames being left in the comparison.
Additionally, decimation differences can be accounted for by utilizing VIVTC's scene change property and avoiding frames +-1 around scene changes.

Selur
23rd January 2025, 20:45
Sounds like normal VIVTC usage with a fallback deinterlacer as post-processor for combed frames:
clip2clip = clip
clip2clip = havsfunc.QTGMC(Input=clip2clip, Preset="fast", opencl=True, TFF=True, FPSDivisor=2)
clip = core.vivtc.VFM(clip=clip, order=0, field=2, mode=1, mchroma=True, cthresh=9, mi=80, chroma=True, blockx=32, blocky=32, y0=16, y1=16, scthresh=12, micmatch=1, micout=False)
# VDecimate helper function
def postprocess(n, f, clip, deinterlaced):
if f.props['_Combed'] > 0:
return deinterlaced
else:
return clip
clip = core.std.FrameEval(clip=clip, eval=functools.partial(postprocess, clip=clip, deinterlaced=clip2clip), prop_src=clip)
clip = core.vivtc.VDecimate(clip=clip, cycle=5, chroma=True, dupthresh=1.1, scthresh=15, blockx=64, blocky=64))
VFM add does field matching and add the '_Combed' flag, the FrameEval line should replace the marked frames with deinterlaced frames (using QTGMC) and the VDecimate line does the decimation, where you can use scthresh (scene threshold) and the other parameters to improve the decimation.
This will only work as you intended if:
a. VFM is tuned to the source to properly notice the residual combing after field matching
b. the chosen deinterlacer is tuned to properly removes the combing.
c. you tune the VDecimate setting to the source.

Remembering:
VIVTC is basically a reimplementation of TIVTC and only borrows two (I think) heavily refactored field matching metric calculation functions. The rest is implemented more or less based on common sense/TIVTC documentation description which means it doesn't match the actual TIVTC behavior at all. source: https://forum.doom9.org/showthread.php?p=1938149#post1938149
I still prefer using TIVTC. (but sometimes I get better results using VIVTC)

Cu Selur

yuygfgg
10th February 2025, 14:17
Sounds like normal VIVTC usage with a fallback deinterlacer as post-processor for combed frames:
clip2clip = clip
clip2clip = havsfunc.QTGMC(Input=clip2clip, Preset="fast", opencl=True, TFF=True, FPSDivisor=2)
clip = core.vivtc.VFM(clip=clip, order=0, field=2, mode=1, mchroma=True, cthresh=9, mi=80, chroma=True, blockx=32, blocky=32, y0=16, y1=16, scthresh=12, micmatch=1, micout=False)
# VDecimate helper function
def postprocess(n, f, clip, deinterlaced):
if f.props['_Combed'] > 0:
return deinterlaced
else:
return clip
clip = core.std.FrameEval(clip=clip, eval=functools.partial(postprocess, clip=clip, deinterlaced=clip2clip), prop_src=clip)
clip = core.vivtc.VDecimate(clip=clip, cycle=5, chroma=True, dupthresh=1.1, scthresh=15, blockx=64, blocky=64))
VFM add does field matching and add the '_Combed' flag, the FrameEval line should replace the marked frames with deinterlaced frames (using QTGMC) and the VDecimate line does the decimation, where you can use scthresh (scene threshold) and the other parameters to improve the decimation.
This will only work as you intended if:
a. VFM is tuned to the source to properly notice the residual combing after field matching
b. the chosen deinterlacer is tuned to properly removes the combing.
c. you tune the VDecimate setting to the source.

Remembering:
source: https://forum.doom9.org/showthread.php?p=1938149#post1938149
I still prefer using TIVTC. (but sometimes I get better results using VIVTC)

Cu Selur


I'm slightly confused: Take 29.97fps -> 23.976fps for example, theoretically 1 out of 5 frames should be dropped to get the "correct" output, but deinterlacing the combed frames may leave all 5 frames. Will it cause incorrect framerate and/or other problems because frames are now "unevenly distributed"?

Or I'm misunderstanding the cause of combed frames. I thought they were frames that automatic IVTCs can't deal with. What if they are truly interlaced frames?

Also, I heard of 2-pass ivtc, which seems to output a VFR clip. While it solves the frame rate problem, the implementation does not include a deint step for the residual before Vdecimate. I'm not sure if I should use a similar QTGMC+frameval after that?

PS. the implementation refers to https://github.com/DJATOM/VapourSynth-atomchtools/blob/34e16238291954206b3f7d5b704324dd6885b224/atomchtools.py#L370

Selur
10th February 2025, 16:38
About your confusion and telecine / 3:2 pull-down, look at https://en.wikipedia.org/wiki/Three-two_pull_down and the 'An illustration of the process' image,...
If your source if truely interlaced or mixed, this is the wrong approach.
2pass ivtc is mainly useful for mixed content, can't say much about it, since I never used it.
Just wanted to answer your initial question. :)