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 26th April 2023, 15:52   #21  |  Link
Setsugen no ao
Registered User
 
Join Date: Dec 2021
Posts: 3
Even though everything in this snippet is bad practice, it can be monkey patched by just forcing the requests

Code:
    last0 = source.std.FrameEval(eval=srestore_inside, prop_src=[bclpYStats, dclpYStats, dclipYStats])

    def _force_eval(n):
        for nn in range(max(n-5, 0), min(last0.num_frames, n + 1)):
            last0.get_frame(nn)

        return last0
    
    last = last0.std.FrameEval(_force_eval)
Setsugen no ao is offline   Reply With Quote
Old 26th April 2023, 19:29   #22  |  Link
Myrsloik
Professional Code Monkey
 
Myrsloik's Avatar
 
Join Date: Jun 2003
Location: Kinnarps Chair
Posts: 2,594
Quote:
Originally Posted by HolyWu View Post
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.

...
You may get away with something like PlaneStats(clip[1:], clip, prop='junk') instead of Cache to fill in the gap caused by selectevery. Or Stack*+Crop* or whatever to trigger requesting multiple frames to compensate
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet
Myrsloik is offline   Reply With Quote
Old 27th April 2023, 15:54   #23  |  Link
Selur
Registered User
 
Selur's Avatar
 
Join Date: Oct 2001
Location: Germany
Posts: 7,495
As a side note, I just stumbled over a workaround:
Using:
Code:
# clip is 50fps progressive due to QTGMC
clip = sRestore.srestore(clip, frate=29.94)
clip = core.std.AssumeFPS(clip=clip, fpsnum=30000, fpsden=1001)
clip = sRestore.srestore(clip, frate=23.976)
clip = core.std.AssumeFPS(clip=clip, fpsnum=24000, fpsden=1001)
instead of the normal:
Code:
clip = sRestore.srestore(clip, frate=23.976)
clip = core.std.AssumeFPS(clip=clip, fpsnum=24000, fpsden=1001)
seems to work fine, still a modified stestore script would be preferable.

Quote:
I'd honestly suggest turning srestore into a proper plugin.
that would be cool

Cu Selur

Ps.: calling sRestore two times helps, but doesn't fix it (still some blends left, that could be removed and get removed in Avisynth)
__________________
Hybrid here in the forum, homepage

Last edited by Selur; 29th April 2023 at 06:03.
Selur is offline   Reply With Quote
Old 29th April 2023, 06:36   #24  |  Link
Selur
Registered User
 
Selur's Avatar
 
Join Date: Oct 2001
Location: Germany
Posts: 7,495
Okay, since cddeblend and srestore don't properly work (may have never worked as good as the Avisynth alternatives) I was wondering what filters do folks use to remove (random) blends ?
I mean, especially folks filtering animes must deal with blends quite often.

Maybe:
1. creating a Vapoursynth script which loads the source and applies some filtering.
2. load that Vapoursynth script as source (using VapourSource) in an Avisynth script, which applies sRestore.
3. loading that AvisynthScript with vsavsreader and apply the rest of the filtering.
could work,.... (assuming VapourSource and vsavsreader still work at least on Windows, I have no hope for Linux&Mac)

Cu Selur
__________________
Hybrid here in the forum, homepage

Last edited by Selur; 29th April 2023 at 10:50.
Selur is offline   Reply With Quote
Old 17th September 2023, 23:46   #25  |  Link
ChaosKing
Registered User
 
Join Date: Dec 2005
Location: Germany
Posts: 1,821
Can you test again with:
Quote:
core = vs.core
core.num_threads=1
__________________
AVSRepoGUI // VSRepoGUI - Package Manager for AviSynth // VapourSynth
VapourSynth Portable FATPACK || VapourSynth Database
ChaosKing is offline   Reply With Quote
Old 19th September 2023, 17:21   #26  |  Link
Selur
Registered User
 
Selur's Avatar
 
Join Date: Oct 2001
Location: Germany
Posts: 7,495
using (with R63):
Code:
# Imports
import vapoursynth as vs
import os
import ctypes
# Loading Support Files
Dllref = ctypes.windll.LoadLibrary("F:/Hybrid/64bit/vsfilters/Support/libfftw3f-3.dll")
import sys
# getting Vapoursynth core
core = vs.core
# Limit thread count to 1
core.num_threads = 1
# Import scripts folder
scriptPath = 'F:/Hybrid/64bit/vsscripts'
sys.path.insert(0, os.path.abspath(scriptPath))
# Loading Plugins
core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/GrainFilter/RemoveGrain/RemoveGrainVS.dll")
core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/GrainFilter/AddGrain/AddGrain.dll")
core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DenoiseFilter/DFTTest/DFTTest.dll")
core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DenoiseFilter/NEO_FFT3DFilter/neo-fft3d.dll")
core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/EEDI3m_opencl.dll")
core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/ResizeFilter/nnedi3/NNEDI3CL.dll")
core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/libmvtools.dll")
core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/scenechange.dll")
core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/fmtconv.dll")
core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/MiscFilter/MiscFilters/MiscFilters.dll")
core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DeinterlaceFilter/Bwdif/Bwdif.dll")
core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/SourceFilter/DGDecNV/DGDecodeNV.dll")
# Import scripts
import havsfunc
# source: 'C:\Users\Selur\Desktop\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 C:\Users\Selur\Desktop\Naruto DVD Folge 4_3 min.m2v using DGSource
clip = core.dgdecodenv.DGSource("J:/tmp/m2v_89c111c29e9cbbcf0ca7e1f8c9f8aa6b_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
# Deinterlacing using QTGMC
clip = havsfunc.QTGMC(Input=clip, Preset="Fast", TFF=True, opencl=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)
# adjusting output color from: YUV420P8 to YUV420P10 for QSVEncModel
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()
doesn't really help.

Cu Selur
__________________
Hybrid here in the forum, homepage
Selur is offline   Reply With Quote
Old 23rd September 2023, 18:05   #27  |  Link
Myrsloik
Professional Code Monkey
 
Myrsloik's Avatar
 
Join Date: Jun 2003
Location: Kinnarps Chair
Posts: 2,594
Quote:
Originally Posted by Selur View Post
using (with R63):
Code:
...
doesn't really help.

Cu Selur
Exactly how are you outputting it for comparison? Single threaded mode should work identically to the avisynth version.
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet
Myrsloik is offline   Reply With Quote
Old 23rd September 2023, 18:08   #28  |  Link
Selur
Registered User
 
Selur's Avatar
 
Join Date: Oct 2001
Location: Germany
Posts: 7,495
I used vsViewer (= older Vapoursynth Editor), will do a reencode and compare the results.
=> You are right seems to be an issue with the preview, so disabling MultiThreading helps.
(Added the file to my Google Drive next to the others.)

Is there a way to just disable multithreading for sRestore/cdeblend/...?

Cu Selur
__________________
Hybrid here in the forum, homepage

Last edited by Selur; 23rd September 2023 at 23:51.
Selur is offline   Reply With Quote
Old 24th September 2023, 10:09   #29  |  Link
ChaosKing
Registered User
 
Join Date: Dec 2005
Location: Germany
Posts: 1,821
preview in vsedit is kinda "broken" for cdeblend, but seems to work then using the encode function. Tested with VapourSynth-Editor-r19-mod-5-x86_64
Try
Quote:
Cdeblend(clip, omode=4) # 4=stats
this is always show 0.0 in vsedit.

This editor shows it correct: https://github.com/Irrational-Encodi...dry/vs-preview
__________________
AVSRepoGUI // VSRepoGUI - Package Manager for AviSynth // VapourSynth
VapourSynth Portable FATPACK || VapourSynth Database
ChaosKing is offline   Reply With Quote
Old 27th October 2023, 17:33   #30  |  Link
Selur
Registered User
 
Selur's Avatar
 
Join Date: Oct 2001
Location: Germany
Posts: 7,495
Has anyone tested srestore from https://github.com/WolframRhodium/mu...er/muvsfunc.py ?
"srestore with serialized execution by explicit node processing dependency" sounds promising.

Okay, did a quick test. Decimation works wonderful, but the serialization basically means if you jump to frame X, all frames before X have to be processed first.
So still hoping for someone to implement this in a filter or that the muvsfunc.srestore will be tweaked,...

Cu Selur
__________________
Hybrid here in the forum, homepage

Last edited by Selur; 27th October 2023 at 18:15.
Selur is offline   Reply With Quote
Old 31st October 2023, 10:40   #31  |  Link
WolframRhodium
Registered User
 
Join Date: Jan 2016
Posts: 163
Quote:
Originally Posted by Selur View Post
..., but the serialization basically means if you jump to frame X, all frames before X have to be processed first.
So still hoping for someone to implement this in a filter or that the muvsfunc.srestore will be tweaked,...
This is a basic design of srestore for deterministic result, so the encoding output is the same as previewing.

Another problem of this approach is that, after jumping to frame X, previewing any frame long before X is time consuming. In this case, re-processing is currently out of my control (from a script writer perspective) because that is related to vapoursynth's caching of frames. And I think it can't be perfect here because for immediate jumping one will need to cache all frames in memory.

An improvement could be like, allowing the user to specify what frames should be cached. This can be implemented as a standalone caching plugin, but I'm not sure whether that is useful.

Last edited by WolframRhodium; 31st October 2023 at 10:48.
WolframRhodium is offline   Reply With Quote
Old 1st November 2023, 06:11   #32  |  Link
Selur
Registered User
 
Selur's Avatar
 
Join Date: Oct 2001
Location: Germany
Posts: 7,495
Do you think it would make much of a difference if the caching would be restricted to 100frames?
__________________
Hybrid here in the forum, homepage
Selur is offline   Reply With Quote
Old 1st November 2023, 11:29   #33  |  Link
WolframRhodium
Registered User
 
Join Date: Jan 2016
Posts: 163
I have no clear thoughts in favor or against this approach. From a user perspective, similar to your approach, I would expect the program provide an option to specify what frames need to be cached (although not all of them may be processed before previewing). Initial thought on implementation of this kind of program is they seem too restrictive and each sequential filter (Cdeblend, srestore) would require a new plugin.
WolframRhodium is offline   Reply With Quote
Old 9th November 2024, 11:22   #34  |  Link
Selur
Registered User
 
Selur's Avatar
 
Join Date: Oct 2001
Location: Germany
Posts: 7,495
Trying to adjust srestore (https://github.com/Selur/Vapoursynth...sfunc.py#L2656) like cdeblend (https://github.com/WolframRhodium/mu...82f3a0eb8cddee) was adjusted.
(Having no clue) I thought it would be basically replacing:
Code:
    ###### evaluation call & output calculation ######
    bclpYStats = bclp.std.PlaneStats()
    dclpYStats = dclp.std.PlaneStats()
    dclipYStats = core.std.PlaneStats(dclip, dclip.std.Trim(first=2))
    last = source.std.FrameEval(eval=srestore_inside, prop_src=[bclpYStats, dclpYStats, dclipYStats])

    ###### final decimation ######
    return ChangeFPS(last.std.Cache(make_linear=True), source.fps_num * numr, source.fps_den * denm)
with:
Code:
    ###### evaluation call & output calculation ######
    bclpYStats = bclp.std.PlaneStats()
    dclpYStats = dclp.std.PlaneStats()
    dclipYStats = core.std.PlaneStats(dclip, dclip.std.Trim(first=2))
    
    prop_src = []
    for i in range(preroll, 0, -1):
      prop_src.extend([bclpYStats[0] *i +  bclpYStats, dclpYStats[0]*i+dclpYStats, dclipYStats[0]*i+dclipYStats])
    prop_src.extend([bclpYStats, dclpYStats, dclipYStats])
          
    last = source.std.FrameEval(functools.partial(srestore_inside), prop_src=prop_src)

    ###### final decimation ######
    return ChangeFPS(last,  source.fps_num * numr, source.fps_den * denm)
but with that, it does not seem that sRestore has any effect aside from the ChangeFPS.
Standalone version of the current script: https://pastebin.com/ycrgv45t
=> does someone know how to fix this?

Cu Selur
__________________
Hybrid here in the forum, homepage
Selur is offline   Reply With Quote
Old Today, 11:54   #35  |  Link
Dust Signs
Registered User
 
Join Date: Jun 2004
Location: Salzburg, Austria
Posts: 220
Are there any updates or workarounds for using srestore in Vapoursynth like in AviSynth?

The bug report here resulted (as far as I can tell) in the removal of srestore altogether (affecting newer versions of VapourSynth).

Is there any workaround or combination of filters around it or does this mean that there is currently no way to use srestore in VapourSynth (and to fall back to AviSynth instead)?
__________________
The number you dialed is imaginary. Please turn your phone by 90° and try again
Dust Signs is offline   Reply With Quote
Old Today, 15:11   #36  |  Link
Selur
Registered User
 
Selur's Avatar
 
Join Date: Oct 2001
Location: Germany
Posts: 7,495
No update.
a. you could use sRestore which forces linear processing in muvsfunc.py (this is what Hybrid does atm.)
b. write a mod of havsfunc sRestore which adds a preroll to it, like Myrsloik did for cdeblend. If you get this working, please share.

Cu Selur
__________________
Hybrid here in the forum, homepage
Selur 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:12.


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