Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Capturing and Editing Video > VapourSynth

Reply
 
Thread Tools Search this Thread Display Modes
Old 23rd April 2023, 15:41   #1  |  Link
Selur
Registered User
 
Selur's Avatar
 
Join Date: Oct 2001
Location: Germany
Posts: 7,259
sRestore Vapoursynth vs Avisynth

Using the following VapourSynth script:
Code:
# Imports
import vapoursynth as vs
import os
import ctypes
# Loading Support Files
Dllref = ctypes.windll.LoadLibrary("i:/Hybrid/64bit/vsfilters/Support/libfftw3f-3.dll")
import sys
# getting Vapoursynth core
core = vs.core
# Import scripts folder
scriptPath = 'i:/Hybrid/64bit/vsscripts'
sys.path.insert(0, os.path.abspath(scriptPath))
# Loading Plugins
core.std.LoadPlugin(path="i:/Hybrid/64bit/vsfilters/GrainFilter/RemoveGrain/RemoveGrainVS.dll")
core.std.LoadPlugin(path="i:/Hybrid/64bit/vsfilters/GrainFilter/AddGrain/AddGrain.dll")
core.std.LoadPlugin(path="i:/Hybrid/64bit/vsfilters/DenoiseFilter/DFTTest/DFTTest.dll")
core.std.LoadPlugin(path="i:/Hybrid/64bit/vsfilters/DenoiseFilter/FFT3DFilter/fft3dfilter.dll")
core.std.LoadPlugin(path="i:/Hybrid/64bit/vsfilters/Support/EEDI3m.dll")
core.std.LoadPlugin(path="i:/Hybrid/64bit/vsfilters/ResizeFilter/nnedi3/vsznedi3.dll")
core.std.LoadPlugin(path="i:/Hybrid/64bit/vsfilters/Support/libmvtools.dll")
core.std.LoadPlugin(path="i:/Hybrid/64bit/vsfilters/Support/scenechange.dll")
core.std.LoadPlugin(path="i:/Hybrid/64bit/vsfilters/Support/fmtconv.dll")
core.std.LoadPlugin(path="i:/Hybrid/64bit/vsfilters/MiscFilter/MiscFilters/MiscFilters.dll")
core.std.LoadPlugin(path="i:/Hybrid/64bit/vsfilters/DeinterlaceFilter/Bwdif/Bwdif.dll")
core.std.LoadPlugin(path="i:/Hybrid/64bit/vsfilters/SourceFilter/d2vSource/DGDecode.dll")
# Import scripts
import havsfunc
# source: 'G:\Output\Naruto DVD Folge 4_3 min.m2v'
# current color space: YUV420P8, bit depth: 8, resolution: 720x576, fps: 25, color matrix: 470bg, yuv luminance scale: limited, scanorder: top field first
# Loading G:\Output\Naruto DVD Folge 4_3 min.m2v using DGDecode
clip = core.dgdecode.MPEG2Source("J:/tmp/m2v_b7151a7e116c7001abddb45453f1386c_853323747.d2v",info=3)# 25 fps, scanorder: top field first
# Setting detected color matrix (470bg).
clip = core.std.SetFrameProps(clip, _Matrix=5)
# Setting color transfer info (470bg), when it is not set
clip = clip if not core.text.FrameProps(clip,'_Transfer') else core.std.SetFrameProps(clip, _Transfer=5)
# Setting color primaries info (BT.601 PAL), when it is not set
clip = clip if not core.text.FrameProps(clip,'_Primaries') else core.std.SetFrameProps(clip, _Primaries=5)
# Setting color range to TV (limited) range.
clip = core.std.SetFrameProp(clip=clip, prop="_ColorRange", intval=1)
# making sure frame rate is set to 25
clip = core.std.AssumeFPS(clip=clip, fpsnum=25, fpsden=1)
clip = core.std.SetFrameProp(clip=clip, prop="_FieldBased", intval=2) # tff
# Deinterlacing using QTGMC
clip = havsfunc.QTGMC(Input=clip, Preset="Fast", TFF=True) # new fps: 50
# Making sure content is preceived as frame based
clip = core.std.SetFrameProp(clip=clip, prop="_FieldBased", intval=0) # progressive
# adjusting frame count and rate with sRestore
clip = havsfunc.srestore(source=clip, frate=23.9760, omode=6)
# set output frame rate to 23.976fps (progressive)
clip = core.std.AssumeFPS(clip=clip, fpsnum=24000, fpsden=1001)
# Output
clip.set_output()
and comparing it with the following AviSynth script:
Code:
ClearAutoloadDirs()
SetFilterMTMode("DEFAULT_MT_MODE", MT_MULTI_INSTANCE)
LoadPlugin("I:\Hybrid\64bit\Avisynth\avisynthPlugins\DGDecode.dll")
LoadPlugin("I:\Hybrid\64bit\Avisynth\avisynthPlugins\RgTools.dll")
LoadPlugin("I:\Hybrid\64bit\Avisynth\avisynthPlugins\masktools2.dll")
LoadPlugin("I:\Hybrid\64bit\Avisynth\avisynthPlugins\mvtools2.dll")
LoadPlugin("I:\Hybrid\64bit\Avisynth\avisynthPlugins\nnedi3.dll")
LoadPlugin("I:\Hybrid\64bit\Avisynth\avisynthPlugins\TIVTC.dll")
LoadPlugin("I:\Hybrid\64bit\Avisynth\avisynthPlugins\Average.dll")
LoadPlugin("I:\Hybrid\64bit\Avisynth\avisynthPlugins\grunt-x64.dll")
LoadPlugin("I:\Hybrid\64bit\Avisynth\avisynthPlugins\MedianBlur2.dll")
Import("I:\Hybrid\64bit\Avisynth\avisynthPlugins\mtmodes.avsi")
Import("I:\Hybrid\64bit\Avisynth\avisynthPlugins\QTGMC.avsi")
Import("I:\Hybrid\64bit\Avisynth\avisynthPlugins\Zs_RF_Shared.avsi")
Import("I:\Hybrid\64bit\Avisynth\avisynthPlugins\Srestore.avsi")
# loading source: G:\Output\Naruto DVD Folge 4_3 min.m2v
# color sampling YV12@8, matrix: bt470, scantyp: top field first, luminance scale: limited
MPEG2Source(d2v="J:\tmp\m2v_b7151a7e116c7001abddb45453f1386c_853323747.d2v",fieldop=0)
# current resolution: 720x576
# deinterlacing
AssumeTFF()
QTGMC(Preset="Fast", ediThreads=2)
# removing ghosting
srestore(frate=23.976,omode=6)
Preroll(Int(last.FrameRate()))
# filtering
# setting output fps to 23.976fps
AssumeFPS(24000,1001)
#  output: color sampling YV12@8, matrix: bt470, scantyp: progressive, luminance scale: limited
return last
The AviSynth output has less blending:

https://imgsli.com/MTcyOTU2 (see left side of the image)

Any idea how to improve the blend removal in VapourSynth?
Is there a newer sRestore port for VapourSynth out there? (can someone make one?)

Cu Selur

Ps.: Used the clip from https://forum.videohelp.com/threads/...e)-from-animes as source.
(uploaded the source an the reencodes to GoogleDrive.
__________________
Hybrid here in the forum, homepage

Last edited by Selur; 23rd April 2023 at 16:08.
Selur is offline   Reply With Quote
Old 24th April 2023, 14:56   #2  |  Link
poisondeathray
Registered User
 
Join Date: Sep 2007
Posts: 5,346
Similar poor results for vpy srestore here. The results are quite a bit worse on many frames compared to avs version

You reported the issue before - but on that sample it's very easy to see the problems, consider adding it as another example
https://github.com/HomeOfVapourSynth...func/issues/78

On the avs version, a few of the slightly blended frames are from QTGMC . If you replace with something like bwdif ,they are clean
poisondeathray is offline   Reply With Quote
Old 24th April 2023, 15:11   #3  |  Link
Selur
Registered User
 
Selur's Avatar
 
Join Date: Oct 2001
Location: Germany
Posts: 7,259
You are right -> I added a link to this thread in the issue tracker.
Main question is: what is causing the differences and can it be fixed?
__________________
Hybrid here in the forum, homepage
Selur is offline   Reply With Quote
Old 24th April 2023, 15:56   #4  |  Link
poisondeathray
Registered User
 
Join Date: Sep 2007
Posts: 5,346
The avs and vpy versions look quite different . Another difference is there is no masktools in vapoursynth. srestore is quite a complex script, way beyond my ability to "fix" it
poisondeathray is offline   Reply With Quote
Old 24th April 2023, 16:13   #5  |  Link
poisondeathray
Registered User
 
Join Date: Sep 2007
Posts: 5,346
If I import an avs script using AVIsource with only bwdif, the vpy srestore works better too - about the same as the avs version. That sequence where girl is walking up is clean. But if I use vpy bwdif into srestore, it's blended.

In both cases, the output node of bwdif is about the same . Props isn't screwing it up - you can set them the same

In all cases, I go back a few seconds and test linearly , because you can get inconsistent results.

Could it be some threading issue ? AVISource is 1 frame in/out, and slower, so it "forces" linear processing in a way - so when I use MPEG2Source in the avs script only (just source filter) , and import using AVISource into the vpy script. Use vpy bwdif and srestore - it works now . So that's my working theory - some threading issue and mixing up frames

Is there a way to force linear/slow/threads=1 processing for source filter ? I used core.d2v.Source for vpy source loading
poisondeathray is offline   Reply With Quote
Old 24th April 2023, 16:16   #6  |  Link
Selur
Registered User
 
Selur's Avatar
 
Join Date: Oct 2001
Location: Germany
Posts: 7,259
Yeah, so the whole GScriptClip-stuff in the AviSynth version makes it really difficult to read.
Additionally, the Vapoursynth version is based on sRestore 2.7e from 2009 and the current version probably changed quite a bit since then,..
__________________
Hybrid here in the forum, homepage
Selur is offline   Reply With Quote
Old 24th April 2023, 16:19   #7  |  Link
poisondeathray
Registered User
 
Join Date: Sep 2007
Posts: 5,346
It cannot be a vpy srestore issue if it works with AVISource (mpeg2source in the avs script only)

core.num_threads = 1 , doesn't seem to help when everything is done in vapoursynth
poisondeathray is offline   Reply With Quote
Old 24th April 2023, 16:22   #8  |  Link
poisondeathray
Registered User
 
Join Date: Sep 2007
Posts: 5,346
It works ok with DGSource. So it is a source filter issue

Code:
clip = core.dgdecodenv.DGSource(r'Naruto DVD Folge 4_3 min.dgi')
clip = core.bwdif.Bwdif(clip, field=3)
clip = haf.srestore(clip)
clip.set_output()
poisondeathray is offline   Reply With Quote
Old 24th April 2023, 17:14   #9  |  Link
Selur
Registered User
 
Selur's Avatar
 
Join Date: Oct 2001
Location: Germany
Posts: 7,259
Doesn't work here,...
Code:
# Imports
import vapoursynth as vs
import os
import sys
# getting Vapoursynth core
core = vs.core
# Import scripts folder
scriptPath = 'i:/Hybrid/64bit/vsscripts'
sys.path.insert(0, os.path.abspath(scriptPath))
# Loading Plugins
core.std.LoadPlugin(path="i:/Hybrid/64bit/vsfilters/DeinterlaceFilter/Bwdif/Bwdif.dll")
core.std.LoadPlugin(path="i:/Hybrid/64bit/vsfilters/SourceFilter/DGDecNV/DGDecodeNV.dll")
# Import scripts
import havsfunc
# source: 'C:\Users\Selur\Desktop\Naruto DVD Folge 4_3 min.mkv'
# current color space: YUV420P8, bit depth: 8, resolution: 720x576, fps: 25, color matrix: 470bg, yuv luminance scale: limited, scanorder: top field first
# Loading C:\Users\Selur\Desktop\Naruto DVD Folge 4_3 min.mkv using DGSource
clip = core.dgdecodenv.DGSource("J:/tmp/mkv_2d1ce5e0c17bb199c7f9dc6f4331d407_853323747.dgi",fieldop=0)# 25 fps, scanorder: top field first
# Setting detected color matrix (470bg).
clip = core.std.SetFrameProps(clip, _Matrix=5)
# Setting color transfer info (470bg), when it is not set
clip = clip if not core.text.FrameProps(clip,'_Transfer') else core.std.SetFrameProps(clip, _Transfer=5)
# Setting color primaries info (BT.601 PAL), when it is not set
clip = clip if not core.text.FrameProps(clip,'_Primaries') else core.std.SetFrameProps(clip, _Primaries=5)
# Setting color range to TV (limited) range.
clip = core.std.SetFrameProp(clip=clip, prop="_ColorRange", intval=1)
# making sure frame rate is set to 25
clip = core.std.AssumeFPS(clip=clip, fpsnum=25, fpsden=1)
clip = core.std.SetFrameProp(clip=clip, prop="_FieldBased", intval=2) # tff
# Deinterlace using Bwdif
clip = core.bwdif.Bwdif(clip=clip, field=3) # new fps: 50
# adjusting frame count and rate with sRestore
clip = havsfunc.srestore(source=clip, frate=23.9760, omode=6, speed=9, thresh=16, mode=2)
# set output frame rate to 23.976fps (progressive)
clip = core.std.AssumeFPS(clip=clip, fpsnum=24000, fpsden=1001)
# Output
clip.set_output()

same when I simplify it to:
Code:
# Imports
import vapoursynth as vs
import os
import sys
# getting Vapoursynth core
core = vs.core
# Import scripts folder
scriptPath = 'i:/Hybrid/64bit/vsscripts'
sys.path.insert(0, os.path.abspath(scriptPath))
# Loading Plugins
core.std.LoadPlugin(path="i:/Hybrid/64bit/vsfilters/DeinterlaceFilter/Bwdif/Bwdif.dll")
core.std.LoadPlugin(path="i:/Hybrid/64bit/vsfilters/SourceFilter/DGDecNV/DGDecodeNV.dll")
# Import scripts
import havsfunc
# source: 'C:\Users\Selur\Desktop\Naruto DVD Folge 4_3 min.mkv'
# current color space: YUV420P8, bit depth: 8, resolution: 720x576, fps: 25, color matrix: 470bg, yuv luminance scale: limited, scanorder: top field first
# Loading C:\Users\Selur\Desktop\Naruto DVD Folge 4_3 min.mkv using DGSource
clip = core.dgdecodenv.DGSource("J:/tmp/mkv_2d1ce5e0c17bb199c7f9dc6f4331d407_853323747.dgi")# 25 fps, scanorder: top field first
# Deinterlace using Bwdif
clip = core.bwdif.Bwdif(clip=clip, field=3) # new fps: 50
# adjusting frame count and rate with sRestore
clip = havsfunc.srestore(source=clip)
# set output frame rate to 23.976fps (progressive)
clip = core.std.AssumeFPS(clip=clip, fpsnum=24000, fpsden=1001)
# Output
clip.set_output()
__________________
Hybrid here in the forum, homepage
Selur is offline   Reply With Quote
Old 24th April 2023, 17:38   #10  |  Link
Selur
Registered User
 
Selur's Avatar
 
Join Date: Oct 2001
Location: Germany
Posts: 7,259
Using:
Code:
# Imports
import vapoursynth as vs
import os
import sys
# getting Vapoursynth core
core = vs.core
# Import scripts folder
scriptPath = 'i:/Hybrid/64bit/vsscripts'
sys.path.insert(0, os.path.abspath(scriptPath))
# Loading Plugins
core.std.LoadPlugin(path="i:/Hybrid/64bit/vsfilters/ResizeFilter/nnedi3/NNEDI3CL.dll")
core.std.LoadPlugin(path="i:/Hybrid/64bit/vsfilters/DeinterlaceFilter/TIVTC/libtivtc.dll")
core.std.LoadPlugin(path="i:/Hybrid/64bit/vsfilters/SourceFilter/DGDecNV/DGDecodeNV.dll")
# Import scripts
import havsfunc
import TFMBob
# source: 'C:\Users\Selur\Desktop\Naruto DVD Folge 4_3 min.mkv'
# current color space: YUV420P8, bit depth: 8, resolution: 720x576, fps: 25, color matrix: 470bg, yuv luminance scale: limited, scanorder: top field first
# Loading C:\Users\Selur\Desktop\Naruto DVD Folge 4_3 min.mkv using DGSource
clip = core.dgdecodenv.DGSource("J:/tmp/mkv_2d1ce5e0c17bb199c7f9dc6f4331d407_853323747.dgi",fieldop=0)# 25 fps, scanorder: top field first
# Setting detected color matrix (470bg).
clip = core.std.SetFrameProps(clip, _Matrix=5)
# Setting color transfer info (470bg), when it is not set
clip = clip if not core.text.FrameProps(clip,'_Transfer') else core.std.SetFrameProps(clip, _Transfer=5)
# Setting color primaries info (BT.601 PAL), when it is not set
clip = clip if not core.text.FrameProps(clip,'_Primaries') else core.std.SetFrameProps(clip, _Primaries=5)
# Setting color range to TV (limited) range.
clip = core.std.SetFrameProp(clip=clip, prop="_ColorRange", intval=1)
# making sure frame rate is set to 25
clip = core.std.AssumeFPS(clip=clip, fpsnum=25, fpsden=1)
clip = core.std.SetFrameProp(clip=clip, prop="_FieldBased", intval=2) # tff
clip = TFMBob.TFMBobN(clip=clip, cthresh=5, openCL=True) # see: https://github.com/Selur/VapoursynthScriptsInHybrid/blob/master/TFMBob.py
# adjusting frame count and rate with sRestore
clip = havsfunc.srestore(source=clip, frate=23.9760)
# set output frame rate to 23.976fps (progressive)
clip = core.std.AssumeFPS(clip=clip, fpsnum=24000, fpsden=1001)
# Output
clip.set_output()
seems to be result in less blends, but there are still more than in Avisynth.
Argh, scratch that,.. this causes some ugly artifacts in some scenes.
__________________
Hybrid here in the forum, homepage

Last edited by Selur; 24th April 2023 at 17:40.
Selur is offline   Reply With Quote
Old 24th April 2023, 18:53   #11  |  Link
poisondeathray
Registered User
 
Join Date: Sep 2007
Posts: 5,346
DGSource,bwdif,srestore vpy works for me . Similar results to avs srestore

This is what I'm getting
https://www.mediafire.com/file/rbsx5...e_vpy.mp4/file

Last edited by poisondeathray; 24th April 2023 at 18:56.
poisondeathray is offline   Reply With Quote
Old 24th April 2023, 19:04   #12  |  Link
Selur
Registered User
 
Selur's Avatar
 
Join Date: Oct 2001
Location: Germany
Posts: 7,259
Strange, when I use:
Code:
# Imports
import vapoursynth as vs
import os
import sys
# getting Vapoursynth core
core = vs.core
# Import scripts folder
scriptPath = 'i:/Hybrid/64bit/vsscripts'
sys.path.insert(0, os.path.abspath(scriptPath))
# Loading Plugins
core.std.LoadPlugin(path="i:/Hybrid/64bit/vsfilters/DeinterlaceFilter/Bwdif/Bwdif.dll")
core.std.LoadPlugin(path="i:/Hybrid/64bit/vsfilters/SourceFilter/DGDecNV/DGDecodeNV.dll")
# Import scripts
import havsfunc
# source: 'C:\Users\Selur\Desktop\Naruto DVD Folge 4_3 min.mkv'
# current color space: YUV420P8, bit depth: 8, resolution: 720x576, fps: 25, color matrix: 470bg, yuv luminance scale: limited, scanorder: top field first
# Loading C:\Users\Selur\Desktop\Naruto DVD Folge 4_3 min.mkv using DGSource
clip = core.dgdecodenv.DGSource("J:/tmp/mkv_2d1ce5e0c17bb199c7f9dc6f4331d407_853323747.dgi",fieldop=0)# 25 fps, scanorder: top field first
# Setting detected color matrix (470bg).
clip = core.std.SetFrameProps(clip, _Matrix=5)
# Setting color transfer info (470bg), when it is not set
clip = clip if not core.text.FrameProps(clip,'_Transfer') else core.std.SetFrameProps(clip, _Transfer=5)
# Setting color primaries info (BT.601 PAL), when it is not set
clip = clip if not core.text.FrameProps(clip,'_Primaries') else core.std.SetFrameProps(clip, _Primaries=5)
# Setting color range to TV (limited) range.
clip = core.std.SetFrameProp(clip=clip, prop="_ColorRange", intval=1)
# making sure frame rate is set to 25
clip = core.std.AssumeFPS(clip=clip, fpsnum=25, fpsden=1)
clip = core.std.SetFrameProp(clip=clip, prop="_FieldBased", intval=2) # tff
# Deinterlace using Bwdif
clip = core.bwdif.Bwdif(clip=clip, field=3) # new fps: 50
# Making sure content is preceived as frame based
clip = core.std.SetFrameProp(clip=clip, prop="_FieldBased", intval=0) # progressive
# adjusting frame count and rate with sRestore
clip = havsfunc.srestore(source=clip, frate=23.9760)
# 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()
I get: Naruto DVD Folge 4_3 min_VS_DGSource_BWDIF_sRestore which isn't better than the qtgmc version.
No clue what I do differently than you.
-> can you open my script (with adjusted paths) and check whether it looks fine for you? Maybe something in my script is causing the issue.

Cu Selur
__________________
Hybrid here in the forum, homepage
Selur is offline   Reply With Quote
Old 24th April 2023, 19:13   #13  |  Link
poisondeathray
Registered User
 
Join Date: Sep 2007
Posts: 5,346
My script was in post #8 . I got similar problems earlier, and it was definitely from source filter d2vsource

I don't see anything in your script that would cause that problem

Maybe version and dependency differences. I used an old vapoursynth version, old plugins, old scripts, old havsfunc. I'll check with a newer version and see if problem pops up . (vapoursynth /python dependencies are 10x worse than "avs .dll hell" )

EDIT-
That was an R54 setup.

Yes, I got blends on R61 setup, and R57 setup. Something maybe with dependencies/scripts/plugins differences between those. It's going to take some work to figure out what's causing it...

Last edited by poisondeathray; 24th April 2023 at 19:19.
poisondeathray is offline   Reply With Quote
Old 24th April 2023, 19:24   #14  |  Link
Selur
Registered User
 
Selur's Avatar
 
Join Date: Oct 2001
Location: Germany
Posts: 7,259
Thanks for looking into it a bit further.
I'll send you links, to all the stuff I use in my Hybrid version.
Would be nice to know that causes the issue.
__________________
Hybrid here in the forum, homepage
Selur is offline   Reply With Quote
Old 24th April 2023, 20:06   #15  |  Link
poisondeathray
Registered User
 
Join Date: Sep 2007
Posts: 5,346
DGDecodeNV.dll was the same for my versions

Bwdif.dll was different, but using old version in R57 didn't make a difference

Does not appear to be srestore version issue either; using older srestore (or copying over old havsfunc) in R57 still gets blends . Using newer srestore in older R54 still ok.

Not sure why the difference, maybe some other dependency (or unlikely, core difference causing problem. Or maybe it is some API <4 vs. >=4 issue ?)
poisondeathray is offline   Reply With Quote
Old 25th April 2023, 13:52   #16  |  Link
HolyWu
Registered User
 
Join Date: Aug 2006
Location: Taiwan
Posts: 392
The culprit is that std.Cache filter becomes no-op in API4. Specifically, srestore requires the make_linear functionality from std.Cache in API3 to work as expected because it calculates some global statistics and those statistics get updated every frame inside FrameEval. Without make_linear, some calls inside FrameEval get skipped and the statistics calculated are incorrect. But it seems impossible to achieve the same result by using std.SetVideoCache in API4.
HolyWu is offline   Reply With Quote
Old 25th April 2023, 14:22   #17  |  Link
poisondeathray
Registered User
 
Join Date: Sep 2007
Posts: 5,346
Quote:
Originally Posted by HolyWu View Post
The culprit is that std.Cache filter becomes no-op in API4. Specifically, srestore requires the make_linear functionality from std.Cache in API3 to work as expected because it calculates some global statistics and those statistics get updated every frame inside FrameEval. Without make_linear, some calls inside FrameEval get skipped and the statistics calculated are incorrect. But it seems impossible to achieve the same result by using std.SetVideoCache in API4.

Thanks

Do you have any suggestions how to address that in API4 ?

Maybe have 2 types of Cache ? Perhaps Myrsloik can look at it ?

BTW - Nice to see you back here
poisondeathray is offline   Reply With Quote
Old 25th April 2023, 16:27   #18  |  Link
Selur
Registered User
 
Selur's Avatar
 
Join Date: Oct 2001
Location: Germany
Posts: 7,259
Interesting, didn't know about std.SetVideoCache.
(as a side note: this would also explain why muvsfunc.Cdeblend doesn't work as expected)
__________________
Hybrid here in the forum, homepage

Last edited by Selur; 25th April 2023 at 19:48.
Selur is offline   Reply With Quote
Old 25th April 2023, 22:10   #19  |  Link
Myrsloik
Professional Code Monkey
 
Myrsloik's Avatar
 
Join Date: Jun 2003
Location: Kinnarps Chair
Posts: 2,548
Quote:
Originally Posted by HolyWu View Post
The culprit is that std.Cache filter becomes no-op in API4. Specifically, srestore requires the make_linear functionality from std.Cache in API3 to work as expected because it calculates some global statistics and those statistics get updated every frame inside FrameEval. Without make_linear, some calls inside FrameEval get skipped and the statistics calculated are incorrect. But it seems impossible to achieve the same result by using std.SetVideoCache in API4.
I'm happy that it worked for you but unfortunately make_linear=True never was a guarantee of frames actually being requested linearly. Maybe it worked well enough for some of you sometimes. I'd honestly suggest turning srestore into a proper plugin.

As a really stupid plan b create a dummy passthrough filter (like the filter skeleton example), use Unordered as the mode and call setLinearFilter(). Replace the Cache() with this filter instead. Maybe it'll whack things into order enough.
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet
Myrsloik is offline   Reply With Quote
Old 26th April 2023, 14:45   #20  |  Link
HolyWu
Registered User
 
Join Date: Aug 2006
Location: Taiwan
Posts: 392
I think this is what really make a difference for srestore because it can no longer get statistics from the skipped frames.

Code:
from functools import partial

import vapoursynth as vs


def print_num(n, clip):
    print(f"frame number: {n}")
    return clip

clip = vs.core.std.BlankClip(length=20)
clip = clip.std.FrameEval(partial(print_num, clip=clip))
#clip = clip.std.Cache(make_linear=True)
clip = clip.std.SelectEvery(2, 0)

clip.set_output()
Test the script using R55-API3.

Without Cache(make_linear=True), it outputs:
Code:
frame number: 0
frame number: 2
frame number: 4
frame number: 6
frame number: 8
frame number: 10
frame number: 12
frame number: 14
frame number: 16
frame number: 18
With Cache(make_linear=True), now it outputs:
Code:
frame number: 0
frame number: 1
frame number: 2
frame number: 3
frame number: 4
frame number: 5
frame number: 6
frame number: 7
frame number: 8
frame number: 9
frame number: 10
frame number: 11
frame number: 12
frame number: 13
frame number: 14
frame number: 15
frame number: 16
frame number: 17
frame number: 18
HolyWu is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 22:31.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.