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
#21
I've been doing some digging and came across this thread on the topic from 10 years ago. It references a script from another thread from 20 years ago.
https://forum.doom9.net/showthread.php?t=172258

Regardless of age the users claim it works well enough.
Is there a filter that can effectively accomplish this bit of code at the beginning of the script? I would hope that there would be some advances in the last 10-20 years.

Function FieldMatch(Clip C) {   Global PP = C.DuplicateFrame(0)   Global CC = C   Global NN = C.DeleteFrame(0)   P2 = PP.SeparateFields()   C2 = CC.SeparateFields()   N2 = NN.SeparateFields()   Global PC = Interleave(P2.SelectEven(),C2.SelectOdd()).Weave()   Global CP = Interleave(C2.SelectEven(),P2.SelectOdd()).Weave()   Global CN = Interleave(C2.SelectEven(),N2.SelectOdd()).Weave()   Global NC = Interleave(N2.SelectEven(),C2.SelectOdd()).Weave()   Global Deint = QTGMC(CC).SelectEven()   Return ScriptClip(CC, \     "!CC.IsCombedTIVTC(CThresh=12,Chroma=True,BlockX=16,BlockY=32) ? CC : " + \     "!NN.IsCombedTIVTC(CThresh=12,Chroma=True,BlockX=16,BlockY=32) ? NN : " + \     "!CN.IsCombedTIVTC(CThresh=12,Chroma=True,BlockX=16,BlockY=32) ? CN : " + \     "!NC.IsCombedTIVTC(CThresh=12,Chroma=True,BlockX=16,BlockY=32) ? NC : " + \     "!PP.IsCombedTIVTC(CThresh=12,Chroma=True,BlockX=16,BlockY=32) ? PP : " + \     "!CP.IsCombedTIVTC(CThresh=12,Chroma=True,BlockX=16,BlockY=32) ? CP : " + \     "!PC.IsCombedTIVTC(CThresh=12,Chroma=True,BlockX=16,BlockY=32) ? PC : Deint") } TFM(Order=-1,Mode=5,PP=2,Clip2=FieldMatch(),Slow=2,MChroma=False,Ubsco=False,CThresh=12,Chroma=True) TDecimate(Mode=1)

Hey, you're in this one!
https://forum.videohelp.com/threads/3968...detelecine
Reply
#22
Haven't seen someone porting this to Vapoursynth. It's a custom solution for a specific clip so it's usually not worth the effort.
----
Dev versions are in the 'experimental'-folder of my GoogleDrive, which is linked on the download page.
Offline between (including) 29th of June and 5th of July => RochHarz Festival
Reply
#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.
Offline between (including) 29th of June and 5th of July => RochHarz Festival
Reply
#24
Wow, those are really broken.
I appreciate the effort and tests.
Reply
#25
Here's what I've landed on

clip2clip = clip clip2clip = qtgmc.QTGMC(Input=clip2clip, Preset="slow", TFF=True, FPSDivisor=2) # Deinterlacing using TIVTC clip = core.tivtc.TFM(clip=clip, mode=5, scthresh=12.00, mmsco=False, chroma=True, clip2=clip2clip) clip = core.tivtc.TDecimate(clip=clip, mode=7, rate=23.9760, dupThresh=0.04, vidThresh=3.50, sceneThresh=15.00)# new fps: 23.976 # Making sure content is preceived as frame based clip = core.std.SetFrameProps(clip=clip, _FieldBased=vs.FIELD_PROGRESSIVE) # progressive # removing grain using MCDegrain clip = degrain.mcdegrainsharp(clip=clip, bblur=0.25, csharp=0.25)

It's not perfect, but it does pretty well. 
There are a few chroma problems I noticed, but they are minor from what I've found, and MCDegrain reduces the bleeding.
It leaves interlaced frames where there are 3-4 interlaced frames in a row.

I'm going to process a few episodes and check the results.


Attached Files Thumbnail(s)
           
Reply
#26
Update: 23.976 fps was way too jerky so I changed it in TDecimate to 29.97 fps. Looks much better.
The pilot episode appears to be the only one so far with the chroma issues. Subsequent episodes have more progressive frames and more predictable interlacing.
Reply
#27
There were some frames in the output I thought the deinterlacer missed, but looking at the source the frames appear to be... the result of deinterlacing encoded into the source? See attached source screens.
I'm not an expert. There are no frames before or after the examples that would match interlacing.

Selur - only one file failed, see debug report


Attached Files Thumbnail(s)
           
Reply
#28
try:
a. vinverse
b. vinverse2
c. QTGMC (Filter)
to get rid of the residuals of the deinterlacing
If that does not work try some anti-aliasing filtering.

About the crash, seem like the Vapourynth Script failed => try the Vapoursynth Preview, it should show an error message.
The script does seem fine to me:
# Imports import vapoursynth as vs # getting Vapoursynth core import ctypes import sys import os core = vs.core # Import scripts folder scriptPath = 'C:/Program Files/Hybrid/64bit/vsscripts' sys.path.insert(0, os.path.abspath(scriptPath)) # Loading Support Files Dllref = ctypes.windll.LoadLibrary("C:/Program Files/Hybrid/64bit/vsfilters/Support/libfftw3f-3.dll") # loading plugins core.std.LoadPlugin(path="C:/Program Files/Hybrid/64bit/vsfilters/Support/TCanny.dll") core.std.LoadPlugin(path="C:/Program Files/Hybrid/64bit/vsfilters/DeinterlaceFilter/TIVTC/libtivtc.dll") core.std.LoadPlugin(path="C:/Program Files/Hybrid/64bit/vsfilters/MiscFilter/MiscFilters/MiscFilters.dll") core.std.LoadPlugin(path="C:/Program Files/Hybrid/64bit/vsfilters/GrainFilter/AddGrain/AddGrain.dll") core.std.LoadPlugin(path="C:/Program Files/Hybrid/64bit/vsfilters/DenoiseFilter/NEO_FFT3DFilter/neo-fft3d.dll") core.std.LoadPlugin(path="C:/Program Files/Hybrid/64bit/vsfilters/DenoiseFilter/DFTTest/DFTTest.dll") core.std.LoadPlugin(path="C:/Program Files/Hybrid/64bit/vsfilters/Support/EEDI3m.dll")# DeinterlaceFilter-Selector core.std.LoadPlugin(path="C:/Program Files/Hybrid/64bit/vsfilters/ResizeFilter/nnedi3/vsznedi3.dll") core.std.LoadPlugin(path="C:/Program Files/Hybrid/64bit/vsfilters/DenoiseFilter/ZSmooth/zsmooth.dll") core.std.LoadPlugin(path="C:/Program Files/Hybrid/64bit/vsfilters/Support/libmvtools.dll") core.std.LoadPlugin(path="C:/Program Files/Hybrid/64bit/vsfilters/Support/fmtconv.dll") core.std.LoadPlugin(path="C:/Program Files/Hybrid/64bit/vsfilters/Support/akarin.dll") core.std.LoadPlugin(path="C:/Program Files/Hybrid/64bit/vsfilters/SourceFilter/LSmashSource/LSMASHSource.dll") # Import scripts import degrain import qtgmc import validate # Source: 'E:\Futurama [remux]\Futurama S02E07 Put Your Head on My Shoulder.mkv' # Current color space: YUV420P8, bit depth: 8, resolution: 720x480, frame rate: 24.751fps, scanorder: telecine, yuv luminance scale: limited, matrix: 470bg, transfer: bt.601, primaries: bt.601 ntsc, format: mpeg-2 # Loading E:\Futurama [remux]\Futurama S02E07 Put Your Head on My Shoulder.mkv using LWLibavSource clip = core.lsmas.LWLibavSource(source="E:/Futurama [remux]/Futurama S02E07 Put Your Head on My Shoulder.mkv", format="YUV420P8", stream_index=0, cache=0, prefer_hw=0) 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 24.751fps clip = core.std.AssumeFPS(clip=clip, fpsnum=24751, fpsden=1000) # making sure the detected scan type is set (detected: telecine) clip = core.std.SetFrameProps(clip=clip, _FieldBased=vs.FIELD_TOP) # tff clip2clip = clip clip2clip = qtgmc.QTGMC(Input=clip2clip, Preset="slow", TFF=True, FPSDivisor=2) # Deinterlacing using TIVTC clip = core.tivtc.TFM(clip=clip, mode=5, scthresh=12.00, mmsco=False, chroma=True, clip2=clip2clip) clip = core.tivtc.TDecimate(clip=clip, mode=7, rate=29.9700, dupThresh=0.04, vidThresh=3.50, sceneThresh=15.00)# new fps: 29.97 # Making sure content is preceived as frame based clip = core.std.SetFrameProps(clip=clip, _FieldBased=vs.FIELD_PROGRESSIVE) # progressive # removing grain using MCDegrain clip = degrain.mcdegrainsharp(clip=clip, bblur=0.20, csharp=0.20) # adjusting output color from: YUV420P8 to YUV420P10 for x265Model clip = core.resize.Bicubic(clip=clip, format=vs.YUV420P10, range_s="limited") # set output frame rate to 29.97fps (progressive) clip = core.std.AssumeFPS(clip=clip, fpsnum=30000, fpsden=1001) # output clip.set_output()
But maybe, it's some incompatibility or bug in one of the filters.

Cu Selur
----
Dev versions are in the 'experimental'-folder of my GoogleDrive, which is linked on the download page.
Offline between (including) 29th of June and 5th of July => RochHarz Festival
Reply
#29
Wow, DAA worked surprisingly well, thanks.

[Image: temp-Preview-Vapoursynth-File22-39-37-272-vpy-22967.png]

The crashing episode S02E07 had a weird container frame rate of 24.751 which was causing an error with TDecimate mode 7. The rest of the episodes were 29.97.
I enabled 'Prefer Original: Frame rate' which was 29.97 and it worked fine.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)