![]() |
|
Deinterlace only the frames flagged as interlaced - Printable Version +- Selur's Little Message Board (https://forum.selur.net) +-- Forum: Hybrid - Support (https://forum.selur.net/forum-1.html) +--- Forum: Problems & Questions (https://forum.selur.net/forum-3.html) +--- Thread: Deinterlace only the frames flagged as interlaced (/thread-4039.html) Pages:
1
2
|
Deinterlace only the frames flagged as interlaced - Ichirare - 16.03.2025 Hi, Firstly, thank you for your software. It allows to utilize the power of VapourSynth and AviSynth in a nice and convienient way. I'm trying to remove interlacing from a mixed (PsF with some sections being truly interlaced) content. I suppose Field Matching is the best to find progressive frames and interlaced frames and decode them as such. But the problem is with processing them. I obviously want to leave the progressive frames untouched by deinterlacer. Many deinterlacers, found in for example ffmpeg, allow the use of a flag to indicate that I want to deinterlace only those frames, which were flagged as being interlaced. Is that possible in Hybrid? I tried the TFMBob deinterlacer in VapourSynth, but I'm not sure it's doing it right? Is it possible with QTGMC? Thank you RE: Deinterlace only the frames flagged as interlaced - Selur - 16.03.2025 No, neither TFMBob nor QTGMC do this. Hybrid has no automated way for this. (since for me, it never worked reliably) Something along the line of def conditionalDeint(n, f, orig, deint):
if f.props['_Combed']:
return deint
else:
return orig
deint = core.tdm.TDeintMod(clip, order=1, edeint=core.nnedi3.nnedi3(clip, field=1))
combProps = core.tdm.IsCombed(clip)
clip = core.std.FrameEval(clip, functools.partial(conditionalDeint, orig=clip, deint=deint), combProps)clip2clip = clip
def postprocess(n, f, clip, deinterlaced):
if f.props['_Combed'] > 0:
return deinterlaced
else:
return clip
clip2clip = qtgmc.QTGMC(Input=clip2clip, Preset="fast", TFF=True, FPSDivisor=2)
clip = core.vivtc.VFM(clip=clip, order=1)
clip = core.std.FrameEval(clip=clip, eval=functools.partial(postprocess, clip=clip, deinterlaced=clip2clip), prop_src=clip)General idea: create two clips, one (same frame rate deinterlaced), the other ran through TFM or VFM. Then mix them. Cu Selur RE: Deinterlace only the frames flagged as interlaced - Ichirare - 24.03.2025 (16.03.2025, 19:54)Selur Wrote: No, neither TFMBob nor QTGMC do this. How can I do that using Custom section of Hybrid? I tried it, but to no avail.. RE: Deinterlace only the frames flagged as interlaced - Selur - 24.03.2025 If you try to do that in a custom section, you need to: a. make sure you load all the dependencies b. let Hybrid know that after your addition, the content is progressive So for example: import ctypes
import sys
import os
import functools
Dllref = ctypes.windll.LoadLibrary("F:/Hybrid/64bit/vsfilters/Support/libfftw3f-3.dll")
core.std.LoadPlugin(path="%FILTERPATH%/GrainFilter/RemoveGrain/RemoveGrainVS.dll")
core.std.LoadPlugin(path="%FILTERPATH%/GrainFilter/AddGrain/AddGrain.dll")
core.std.LoadPlugin(path="%FILTERPATH%/DenoiseFilter/NEO_FFT3DFilter/neo-fft3d.dll")
core.std.LoadPlugin(path="%FILTERPATH%/DenoiseFilter/DFTTest/DFTTest.dll")
core.std.LoadPlugin(path="%FILTERPATH%/Support/EEDI3m.dll")# vsQTGMC
core.std.LoadPlugin(path="%FILTERPATH%/ResizeFilter/nnedi3/vsznedi3.dll")
core.std.LoadPlugin(path="%FILTERPATH%/Support/libmvtools.dll")
core.std.LoadPlugin(path="%FILTERPATH%/Support/fmtconv.dll")
core.std.LoadPlugin(path="%FILTERPATH%/MiscFilter/MiscFilters/MiscFilters.dll")
core.std.LoadPlugin(path="%FILTERPATH%/DeinterlaceFilter/Bwdif/Bwdif.dll")
core.std.LoadPlugin(path="%FILTERPATH%/DeinterlaceFilter/VIVTC/VIVTC.dll")
import qtgmc
clip2clip = clip
def postprocess(n, f, clip, deinterlaced):
if f.props['_Combed'] > 0:
return deinterlaced
else:
return clip
clip2clip = qtgmc.QTGMC(Input=clip2clip, Preset="fast", TFF=True, FPSDivisor=2)
clip = core.vivtc.VFM(clip=clip, order=1)
clip = core.std.FrameEval(clip=clip, eval=functools.partial(postprocess, clip=clip, deinterlaced=clip2clip), prop_src=clip)
clip = core.std.SetFrameProps(clip=clip, _FieldBased=vs.FIELD_PROGRESSIVE) # progressive
# scantype progressive=> you will have to write your own script if you want to use this. Cu Selur RE: Deinterlace only the frames flagged as interlaced - Selur - 24.03.2025 Here's a more generic example for the custom section: import ctypes
import sys
import os
import functools
Dllref = ctypes.windll.LoadLibrary("%FILTERPATH%s/Support/libfftw3f-3.dll")
core.std.LoadPlugin(path="%FILTERPATH%/GrainFilter/RemoveGrain/RemoveGrainVS.dll")
core.std.LoadPlugin(path="%FILTERPATH%/GrainFilter/AddGrain/AddGrain.dll")
core.std.LoadPlugin(path="%FILTERPATH%/DenoiseFilter/NEO_FFT3DFilter/neo-fft3d.dll")
core.std.LoadPlugin(path="%FILTERPATH%/DenoiseFilter/DFTTest/DFTTest.dll")
core.std.LoadPlugin(path="%FILTERPATH%/Support/EEDI3m.dll")# vsQTGMC
core.std.LoadPlugin(path="%FILTERPATH%/ResizeFilter/nnedi3/vsznedi3.dll")
core.std.LoadPlugin(path="%FILTERPATH%/Support/libmvtools.dll")
core.std.LoadPlugin(path="%FILTERPATH%/Support/fmtconv.dll")
core.std.LoadPlugin(path="%FILTERPATH%/MiscFilter/MiscFilters/MiscFilters.dll")
core.std.LoadPlugin(path="%FILTERPATH%/DeinterlaceFilter/Bwdif/Bwdif.dll")
core.std.LoadPlugin(path="%FILTERPATH%/DeinterlaceFilter/VIVTC/VIVTC.dll")
import qtgmc
clip2clip = clip
def postprocess(n, f, clip, deinterlaced):
if f.props['_Combed'] > 0:
return deinterlaced
else:
return clip
if clip.get_frame(0).props.get('_FieldBased', '') == vs.FIELD_TOP:
tff = True
order = 1
else:
tff = False
order = 0
clip2clip = qtgmc.QTGMC(Input=clip2clip, Preset="fast", TFF=tff, FPSDivisor=2)
clip = core.vivtc.VFM(clip=clip, order=order)
clip = core.std.FrameEval(clip=clip, eval=functools.partial(postprocess, clip=clip, deinterlaced=clip2clip), prop_src=clip)
clip = core.std.SetFrameProps(clip=clip, _FieldBased=vs.FIELD_PROGRESSIVE) # progressive
# scantype progressiveDid a few tests and for me, at least with the default VFM settings clip = core.vivtc.VFM(clip=clip, order=order)I got better results using TFM instead of VFM. Here's also an example using TFM instead of VFM. import ctypes
import sys
import os
import functools
Dllref = ctypes.windll.LoadLibrary("%FILTERPATH%/Support/libfftw3f-3.dll")
core.std.LoadPlugin(path="%FILTERPATH%/GrainFilter/RemoveGrain/RemoveGrainVS.dll")
core.std.LoadPlugin(path="%FILTERPATH%/GrainFilter/AddGrain/AddGrain.dll")
core.std.LoadPlugin(path="%FILTERPATH%/DenoiseFilter/NEO_FFT3DFilter/neo-fft3d.dll")
core.std.LoadPlugin(path="%FILTERPATH%/DenoiseFilter/DFTTest/DFTTest.dll")
core.std.LoadPlugin(path="%FILTERPATH%/Support/EEDI3m.dll")# vsQTGMC
core.std.LoadPlugin(path="%FILTERPATH%/ResizeFilter/nnedi3/vsznedi3.dll")
core.std.LoadPlugin(path="%FILTERPATH%/Support/libmvtools.dll")
core.std.LoadPlugin(path="%FILTERPATH%/Support/fmtconv.dll")
core.std.LoadPlugin(path="%FILTERPATH%/MiscFilter/MiscFilters/MiscFilters.dll")
core.std.LoadPlugin(path="%FILTERPATH%/DeinterlaceFilter/Bwdif/Bwdif.dll")
core.std.LoadPlugin(path="%FILTERPATH%/DeinterlaceFilter/TIVTC/libtivtc.dll")
import qtgmc
clip2clip = clip
def postprocess(n, f, clip, deinterlaced):
if f.props['_Combed'] > 0:
return deinterlaced
else:
return clip
if clip.get_frame(0).props.get('_FieldBased', '') == vs.FIELD_TOP:
tff = True
order = 1
else:
tff = False
order = 0
clip2clip = qtgmc.QTGMC(Input=clip2clip, Preset="fast", TFF=tff, FPSDivisor=2)
clip = core.tivtc.TFM(clip=clip)
clip = core.std.FrameEval(clip=clip, eval=functools.partial(postprocess, clip=clip, deinterlaced=clip2clip), prop_src=clip)
clip = core.std.SetFrameProps(clip=clip, _FieldBased=vs.FIELD_PROGRESSIVE) # progressive
# scantype progressiveSo you might have to either: a. tweak the VFM settings, see: https://amusementclub.github.io/doc/plugins/vivtc.html or b. use TFM instead and potentially tweak its settings Cu Selur Ps.: Updated the dev version to support such code in the custom sections. RE: Deinterlace only the frames flagged as interlaced - Ichirare - 25.03.2025 --- totally unnecessary full quote removed by Selur --- Thank you ![]() If I change the scantype to Progressive in the Deinterlace tab to disable autodeinterlace, will that custom code still work? RE: Deinterlace only the frames flagged as interlaced - Selur - 25.03.2025 Quote: If I change the scantype to Progressive in the Deinterlace tab to disable autodeinterlace, will that custom code still work?Why would you do that? This will only potentially cause problems. If you load the custom code, in a custom that is inserted before the 'Deinterlace'-section the code already lets Hybrid know that the source is progressive at the end of the section. Since Hybrid knows that the source is progressive after the custom section ('# scantype progressive'), it will not try to add additional deinterlacing. So if you tell Hybrid the source is already progressive at the beginning of the script, it will only break the preview. Cu Selur RE: Deinterlace only the frames flagged as interlaced - Ichirare - 25.03.2025 That makes sense, thank you. I didn't know that the custom code will override that deinterlacing logic, so I wanted to make sure that Hybrid won't read the scantype from the file and that only TFM will mark the frames and that only these detections will be used for deinterlacing RE: Deinterlace only the frames flagged as interlaced - Selur - 25.03.2025 a. Please, do not quote the full previous post. It just bloats up everything,... b. Like I wrote before, keep in mind that TFM / VFM might not always find and flag the correct frames unless you adjust their settings. Cu Selur RE: Deinterlace only the frames flagged as interlaced - Ichirare - 25.03.2025 Thank you for your help, Selur 👍. TFM did the job well after fine tuning the parameters. Only interlaced frames were processed by QTGMC. Btw, saving configuration in custom section seems kinda finicky. Hybrid does not register saving the configuration at first. After restarting the program, the configuration shows up, but in my case, it's present in the list 5 times. Saving configuration for filters works fine. |