Log in

View Full Version : how to re-interlace TFF deinterlaced back into TFF


hydra3333
31st July 2016, 12:50
A newbie to python and vapoursynth seeks assistance on how to re-interlaced a deinterlaced 576p50 (50 fps) clip into 576i25 (25 fps).

Example script;
import vapoursynth as vs
import havsfunc as haf
import mvsfunc as mvs
core = vs.get_core(accept_lowercase=True)
core.std.LoadPlugin(r'c:\software\dgdecodenv\dgdecodenv.DLL')
# todo: figure out what else to "LoadPlugin" so that QTGMC just works (google how to do that in VS)
video = core.dgdecodenv.DGSource(r'D:\Temp\Video\test.dgi') # interlaced TFF input, PAL 576i 25fps, or PAL 1080i 25fps
# todo: put an interlaced-aware deblocker in here before QTGMC since the broadcasts are very usually blocky as all heck (google how to do that in VS)
video = haf.QTGMC(Preset="Very Slow", TFF=True,EdiThreads=4,SLMode=2,EZKeepGrain=1.2,NoiseProcess=2) # result is double framerate progressive, so re-interlate it later
# todo: do other stuff including sharpen (google how to do that in VS)
# todo: if required, resize to 576p (google how to do that in VS)

Now I need to reinterlace the "double framerate" deinterlaced (50p progressive) clip (don't ask, it's to do with "motion fluidity" for fast-moving sports videos panning across a very large grassed arena).

Avisynth is like this for TFF:
Blur(0,0.25).SeparateFields().SelectEvery(4,0,3).Weave() #reinterlace - ASSUMED TFF HERE # BLUR(0,1) per http://forum.doom9.org/showthread.php?p=1488308#post1488308

However I appear have mis-read 3 possible VS methods after googling it.

(1) (not sure the syntax is correct)

video = core.std.SeparateFields(video, tff=True)
video = core.std.SelectEvery(video, cycle=4, offsets=[0, 3]) # looks like avisynth ?
video = haf.Weave(video, tff=True)
video = mvs.AssumeTFF(video)
(2) (definitely not sure the syntax is correct)
video = core.std.DoubleWeave(clip=video, tff=True)[::2]
video = mvs.AssumeTFF(video)
(3)
video = core.std.SelectEvery(video, 4, [0, 3])
video = haf.Weave(video, tff=True)
video = mvs.AssumeTFF(video)


Advice sought.

hydra3333
3rd August 2016, 10:11
For posterity, reading the manual and trying it out, this seems to work re-interlacing 576p50 to 576i25 (25 frames/sec is 50 fields/sec).
Note Vapoursynth needs "tff" in calls as some things don't use a prior AssumeTFF.
import havsfunc as haf
video = core.std.SeparateFields(video, tff=True)
video = core.std.SelectEvery(video, cycle=4, offsets=[0, 3]) # looks like avisynth ?
video = haf.Weave(video, tff=True)
video = mvs.AssumeTFF(video)

and
http://avisynth.nl/index.php/DoubleWeave
Weave is actually just a shorthand for DoubleWeave followed by SelectEven.
with
http://forum.doom9.org/showthread.php?p=1756168#post1756168
Untested but based off the documentation the equivalent in VapourSynth would be:

v = (v.std.SeparateFields(tff=True)
.std.SelectEvery(cycle=4, offsets=[0, 3])
.std.DoubleWeave(tff=True)
.std.SelectEvery(cycle=2, offsets=0))

That's 50p->50i (aka 25i). 25p->50i is a no-op, it's already ready to go, unless you want to do fancy frame-interpolation. (The first post's VS code is a complicated no-op.) You just have to treat it as interlaced.