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 7th October 2022, 16:41   #1  |  Link
Selur
Registered User
 
Selur's Avatar
 
Join Date: Oct 2001
Location: Germany
Posts: 7,259
using sRestore,...

Over at videohelp there is a thread where Avisynth can be nicely used to remove some ghosting using:
Code:
ClearAutoloadDirs()
SetFilterMTMode("DEFAULT_MT_MODE", MT_MULTI_INSTANCE)
LoadPlugin("I:\Hybrid\64bit\Avisynth\AVISYN~1\LSMASHSource.dll")
LoadPlugin("I:\Hybrid\64bit\Avisynth\AVISYN~1\RgTools.dll")
LoadPlugin("I:\Hybrid\64bit\Avisynth\AVISYN~1\masktools2.dll")
LoadPlugin("I:\Hybrid\64bit\Avisynth\AVISYN~1\mvtools2.dll")
LoadPlugin("I:\Hybrid\64bit\Avisynth\AVISYN~1\nnedi3.dll")
LoadPlugin("I:\Hybrid\64bit\Avisynth\AVISYN~1\TIVTC.dll")
LoadPlugin("I:\Hybrid\64bit\Avisynth\AVISYN~1\Average.dll")
LoadPlugin("I:\Hybrid\64bit\Avisynth\AVISYN~1\grunt-x64.dll")
LoadPlugin("I:\Hybrid\64bit\Avisynth\AVISYN~1\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: C:\Users\Selur\Desktop\spots_beg_ufo_sIII1c_amtv_v2_cut.avi
# color sampling YUY2@8, matrix: bt601, scantyp: top field first, luminance scale: limited
LWLibavVideoSource("C:\Users\Selur\Desktop\SPOTS_~1.AVI",cache=false,dr=true,format="YUV422P8", prefer_hw=0)
# current resolution: 720x576
# deinterlacing
AssumeTFF()
QTGMC(Preset="Fast", ediThreads=2)
# removing ghosting
srestore(omode=6)
Preroll(Int(last.FrameRate())) # for consistent preview
# filtering
# adjust color to YV12 (color matrix: Rec601)
ConvertToYV12()
# setting output fps to 23.976fps
AssumeFPS(24000,1001)
#  output: color sampling YV16@8, matrix: bt601, scantyp: progressive, luminance scale: limited
return last

using Vapoursynth:
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/FFT3DFilter/fft3dfilter.dll")
core.std.LoadPlugin(path="i:/Hybrid/64bit/vsfilters/DenoiseFilter/DFTTest/DFTTest.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/LSmashSource/vslsmashsource.dll")
# Import scripts
import havsfunc
# source: 'C:\Users\Selur\Desktop\spots_beg_ufo_sIII1c_amtv_v2_cut.avi'
# current color space: YUV422P8, bit depth: 8, resolution: 720x576, fps: 25, color matrix: 470bg, yuv luminance scale: limited, scanorder: top field first
# Loading C:\Users\Selur\Desktop\spots_beg_ufo_sIII1c_amtv_v2_cut.avi using LWLibavSource
clip = core.lsmas.LWLibavSource(source="C:/Users/Selur/Desktop/spots_beg_ufo_sIII1c_amtv_v2_cut.avi", format="YUV422P8", stream_index=0, cache=0, fpsnum=25, prefer_hw=0)
# Setting color matrix to 470bg.
clip = core.std.SetFrameProps(clip, _Matrix=5)
clip = clip if not core.text.FrameProps(clip,'_Transfer') else core.std.SetFrameProps(clip, _Transfer=5)
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)
# setting field order to what QTGMC should assume (top field first)
clip = core.std.SetFrameProp(clip=clip, prop="_FieldBased", intval=2)
# Deinterlacing using QTGMC
clip = havsfunc.QTGMC(Input=clip, Preset="Fast", TFF=True) # new fps: 50
# make sure content is preceived as frame based
clip = core.std.SetFieldBased(clip, 0)
# adjusting frame count and rate with sRestore
clip = havsfunc.srestore(source=clip,omode=6)
# adjusting output color from: YUV422P8 to YUV420P8 for x264Model
clip = core.resize.Bicubic(clip=clip, format=vs.YUV420P8, range_s="limited")
# set output frame rate to 23.976fps
clip = core.std.AssumeFPS(clip=clip, fpsnum=24000, fpsden=1001)
# Output
clip.set_output()
I get:

At first, I thought it might be a preview issue with sRestore, like I get in Avisynth when not using Preroll.
(I Avisynth you won't get proper preview with sRestore unless you start xy frame before the scene you want to look at or add Preroll after sRestore.)
Sadly, unlike with Avisynth, where the encoding is always, proper (even if the preview was wrong), I'm still left with the ghosting when using sRestore in Vapoursynth.

=> Anyone got an idea how to get sRestore to work in Vapoursynth as good as it does in Avisynth?


Cu Selur

Ps.: is there something similar to Preroll in Vapoursynth which might help with the issue?
__________________
Hybrid here in the forum, homepage
Selur is offline   Reply With Quote
Old 7th October 2022, 19:01   #2  |  Link
poisondeathray
Registered User
 
Join Date: Sep 2007
Posts: 5,346
Works for me. Similar results to avs version for the preview (when going back a few frames and advancing linearly frame by frame), or when encoded
poisondeathray is offline   Reply With Quote
Old 8th October 2022, 05:29   #3  |  Link
Selur
Registered User
 
Selur's Avatar
 
Join Date: Oct 2001
Location: Germany
Posts: 7,259
Thanks for testing.
Sadly, for me, with Vapoursynth, frame 46 (after QTGMC() and sRestore()) still has the ghosting.
I could live with the preview being 'broken', but the encoding has the same ghosting.

So it must be something with my setup.
Since it's also in the reencode for me, it must be something with the scripts I use.

havsfunc script I'm using is:
https://github.com/Selur/Vapoursynth...er/havsfunc.py
(no change when using FFMS2 over L-SmashSource)

Also: Does anyone know whether there is an alternative to Preroll in Vapoursynth?

Cu Selur
__________________
Hybrid here in the forum, homepage

Last edited by Selur; 8th October 2022 at 05:39.
Selur is offline   Reply With Quote
Old 8th October 2022, 08:42   #4  |  Link
cretindesalpes
͡҉҉ ̵̡̢̛̗̘̙̜̝̞̟̠͇̊̋̌̍̎̏̿̿
 
cretindesalpes's Avatar
 
Join Date: Feb 2009
Location: No support in PM
Posts: 712
Does the difference come from srestore or from QTGMC, which is a quite complex function?
__________________
dither 1.28.1 for AviSynth | avstp 1.0.4 for AviSynth development | fmtconv r30 for Vapoursynth & Avs+ | trimx264opt segmented encoding
cretindesalpes is offline   Reply With Quote
Old 8th October 2022, 09:14   #5  |  Link
Selur
Registered User
 
Selur's Avatar
 
Join Date: Oct 2001
Location: Germany
Posts: 7,259
Must be sRestore.
Here's the output of QTGMC(Fast) for Vapoursynth (94/95/96):

and for Avisynth (94/95/96):


=> QTGMC output looks identical to me.

Cu Selur
__________________
Hybrid here in the forum, homepage
Selur is offline   Reply With Quote
Old 8th October 2022, 09:49   #6  |  Link
lollo2
Registered User
 
lollo2's Avatar
 
Join Date: Aug 2017
Location: Italy
Posts: 113
In AviSynth I used Srestore(). The omode parameter defaults at 6, the same you used.

Is it possible than in VapourSynth omode parameter is handled differently?

Just a guess...
__________________
A channel on S-VHS / VHS capture and AviSynth restoration https://www.youtube.com/channel/UCMs...h1MmNAs7I8nu4g
lollo2 is offline   Reply With Quote
Old 8th October 2022, 10:01   #7  |  Link
Selur
Registered User
 
Selur's Avatar
 
Join Date: Oct 2001
Location: Germany
Posts: 7,259
I tried all omode values, so if it's handled differently it's not a simple mapping difference. :/
__________________
Hybrid here in the forum, homepage
Selur is offline   Reply With Quote
Old 8th October 2022, 10:32   #8  |  Link
ChaosKing
Registered User
 
Join Date: Dec 2005
Location: Germany
Posts: 1,795
Probably a some kind of bug. Dehalo_alpha and finedehalo had also different results for years.
https://github.com/HomeOfVapourSynth...func/issues/30

Debugging srestore will certainly be more difficult.
__________________
AVSRepoGUI // VSRepoGUI - Package Manager for AviSynth // VapourSynth
VapourSynth Portable FATPACK || VapourSynth Database
ChaosKing is offline   Reply With Quote
Old 8th October 2022, 11:28   #9  |  Link
Selur
Registered User
 
Selur's Avatar
 
Join Date: Oct 2001
Location: Germany
Posts: 7,259
Hmm,... I hate those expressions in polish format,...

Problem is, to me, basically all the expr calls seem different to me in Vapoursynth than in Avisynth. :/
Would be nice if anyone having more experience than me can say if he sees a difference.

Cu Selur

Ps.: Also created an issue entry https://github.com/HomeOfVapourSynth...func/issues/78.
__________________
Hybrid here in the forum, homepage

Last edited by Selur; 8th October 2022 at 11:41.
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 08:58.


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