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. |
18th November 2013, 19:22 | #1 | Link |
Guest
Posts: n/a
|
RemoveDirtVS
So I've finally finished porting RemoveDirt to Vapoursynth. I've tested it a little bit but it could definitely use more extensive testing.
To use it in Vapoursynth here is also the ported version of the Avisynth script as a function: Code:
#removedirtvs.py import vapoursynth as vs def RemoveDirt(input, repmode=16): core = vs.get_core() cleansed = core.rgvs.Clense(input) sbegin = core.rgvs.ForwardClense(input) send = core.rgvs.BackwardClense(input) scenechange = core.rdvs.SCSelect(input, sbegin, send, cleansed) alt = core.rgvs.Repair(scenechange, input, mode=[repmode,repmode,1]) restore = core.rgvs.Repair(cleansed, input, mode=[repmode,repmode,1]) corrected = core.rdvs.RestoreMotionBlocks(cleansed, restore, neighbour=input, alternative=alt, gmthreshold=70, dist=1, dmode=2, noise=10, noisy=12, grey=0) return core.rgvs.RemoveGrain(corrected, mode=[17,17,1]) Code:
import vapoursynth as vs import removedirtvs core = vs.get_core() core.std.LoadPlugin(plugins_vs + r'ffms2.dll') core.std.LoadPlugin(plugins_vs + r'RemoveDirt.dll') clip = core.ffms2.Source(src) clip = removedirtvs.RemoveDirt(clip) clip.set_output() Source code is here. Last edited by handaimaoh; 21st November 2013 at 01:03. |
18th November 2013, 19:51 | #2 | Link |
Guest
Posts: n/a
|
I forgot to mention, if you are compiling it yourself make sure that "VS_TARGET_CPU_X86" is defined because there is no fallback code in case it isn't right now. I will also eventually create a makefile.
Edited to add: Just added an #error case in case that is not defined. Last edited by handaimaoh; 18th November 2013 at 20:00. |
18th November 2013, 20:40 | #3 | Link | |
Professional Code Monkey
Join Date: Jun 2003
Location: Kinnarps Chair
Posts: 2,596
|
Quote:
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet |
|
18th November 2013, 20:44 | #5 | Link | |
Professional Code Monkey
Join Date: Jun 2003
Location: Kinnarps Chair
Posts: 2,596
|
Quote:
Code:
#removedirtvs.py import vapoursynth as vs def RemoveDirt(input, repmode=16): core = vs.get_core() cleansed = core.rgvs.Clense(input) sbegin = core.rgvs.ForwardClense(input) send = core.rgvs.BackwardClense(input) scenechange = core.rdvs.SCSelect(input, sbegin, send, cleansed) alt = core.rgvs.Repair(scenechange, input, mode=[repmode,repmode,1]) restore = core.rgvs.Repair(cleansed, input, mode=[repmode,repmode,1]) corrected = core.rdvs.RestoreMotionBlocks(cleansed, restore, neighbour=input, alternative=alt, gmthreshold=70, dist=1, dmode=2, noise=10, noisy=12, grey=0) return core.rgvs.RemoveGrain(corrected, mode=[17,17,1])
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet |
|
19th November 2013, 17:16 | #6 | Link | |
Guest
Posts: n/a
|
Quote:
|
|
20th November 2013, 00:30 | #7 | Link |
Guest
Posts: n/a
|
RemoveDirtVS
So I guess no one has actually tested this yet but myself since there was a crash bug introduced where I forgot to add back in an EMMS call that was removed at one point from a method that would call into the few functions using MMX intrinsics. Sometimes it would manifest at the very beginning of a video and sometimes after a few hundred to a few thousand frames. So that has now been fixed and a new binary is posted here.
I knew that stupid MMX code would haunt me in some way... Last edited by handaimaoh; 20th November 2013 at 00:34. |
20th November 2013, 00:40 | #8 | Link | |
Professional Code Monkey
Join Date: Jun 2003
Location: Kinnarps Chair
Posts: 2,596
|
Quote:
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet |
|
20th November 2013, 00:44 | #9 | Link |
Guest
Posts: n/a
|
RemoveDirtVS
I realize that. It's not a seperate code path, though. It's a couple of functions that were only written in MMX. I was already going to rewrite them since the MMX intrinsics prevents compiling for x64. It's just that I hadn't done it yet and I noticed that it was causing the plugin to instantly crash in some cases because of the lack of emms.
Last edited by handaimaoh; 20th November 2013 at 00:55. |
20th November 2013, 02:16 | #11 | Link | ||
Registered User
Join Date: Mar 2012
Location: Texas
Posts: 1,672
|
Quote:
Quote:
|
||
20th November 2013, 02:19 | #13 | Link |
Registered User
Join Date: Mar 2012
Location: Texas
Posts: 1,672
|
Code:
import vapoursynth as vs core = vs.get_core() core.avs.LoadPlugin(path=r'C:\Program Files\AviSynth 2.5\plugins\DGDecodeNV.dll') core.std.LoadPlugin(path=r'C:\Vapoursynth\RemoveDirtVS\RemoveDirtVS.dll') # Source src = core.avs.DGSource(dgi=r'C:\Vapoursynth\RemoveDirtVS\00110.dgi') # Proccesing src = core.vivtc.VFM(clip=src, order=1, field=1) src = core.vivtc.VDecimate(clip=src) # RemoveDirt clip = src cleansed = core.rgvs.Clense(clip) sbegin = core.rgvs.ForwardClense(clip) send = core.rgvs.BackwardClense(clip) scenechange = core.rdvs.SCSelect(clip, sbegin, send, cleansed) alt = core.rgvs.Repair(scenechange, clip, mode=[16,16,1]) restore = core.rgvs.Repair(cleansed, clip, mode=[16,16,1]) corrected = core.rdvs.RestoreMotionBlocks(cleansed, restore, neighbour=clip, alternative=alt, gmthreshold=70, dist=1, dmode=2, noise=10, noisy=12, grey=0) clip = core.rgvs.RemoveGrain(clip, mode=[17,17,1]) clip.set_output() |
20th November 2013, 02:24 | #15 | Link |
Registered User
Join Date: Mar 2012
Location: Texas
Posts: 1,672
|
Hmm that's odd. If I replace the binary with the older one, it loads without errors.
Im using VS R21 on 32-bit Windows XP sp3. Going to update to R22 test version to see if that does anything. Update: With R22 test 2, I can't even load a script. It just freezes VDub. I also removed RemoveDirt and tried with a simpler script and still froze. Will investigate a little more. Last edited by Reel.Deel; 20th November 2013 at 02:37. |
15th December 2014, 20:52 | #18 | Link |
Registered User
Join Date: Mar 2012
Location: Texas
Posts: 1,672
|
The links in the OP are dead so just in case someone is looking for them here they are: RemoveDirtVS.zip
|
20th February 2022, 16:47 | #19 | Link |
Registered User
Join Date: Oct 2001
Location: Germany
Posts: 7,551
|
I'm using a script called 'killerspots' (https://github.com/Selur/Vapoursynth...killerspots.py) which works find unless I use:it with advanced = True (the default) in which case:
Code:
def RemoveDirtMod(clip: vs.VideoNode, limit: int =10): core = vs.core clensed = core.rgvs.Clense(clip) alt = core.rgvs.RemoveGrain(clip,mode=1) clip = core.rdvs.RestoreMotionBlocks(clensed, clip, alternative=alt, pthreshold=4, cthreshold=6, gmthreshold=40, dist=3, dmode=2, noise=limit, noisy=12) return clip The script I use is: Code:
# Imports import os import sys import ctypes # Loading Support Files Dllref = ctypes.windll.LoadLibrary("I:/Hybrid/64bit/vsfilters/Support/libfftw3f-3.dll") import vapoursynth as vs # 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/MiscFilter/MiscFilters/MiscFilters.dll") core.std.LoadPlugin(path="I:/Hybrid/64bit/vsfilters/DenoiseFilter/TTempSmooth/TTempSmooth.dll") core.std.LoadPlugin(path="I:/Hybrid/64bit/vsfilters/DenoiseFilter/DFTTest/DFTTest.dll") core.std.LoadPlugin(path="I:/Hybrid/64bit/vsfilters/DenoiseFilter/NEO_FFT3DFilter/neo-fft3d.dll") core.std.LoadPlugin(path="I:/Hybrid/64bit/vsfilters/Support/DCTFilter.dll") core.std.LoadPlugin(path="I:/Hybrid/64bit/vsfilters/DeblockFilter/Deblock/Deblock.dll") core.std.LoadPlugin(path="I:/Hybrid/64bit/vsfilters/DenoiseFilter/RemoveDirt/RemoveDirtVS.dll") core.std.LoadPlugin(path="I:/Hybrid/64bit/vsfilters/Support/libmvtools.dll") core.std.LoadPlugin(path="I:/Hybrid/64bit/vsfilters/GrainFilter/RemoveGrain/RemoveGrainVS.dll") core.std.LoadPlugin(path="I:/Hybrid/64bit/vsfilters/SourceFilter/LSmashSource/vslsmashsource.dll") # Import scripts import havsfunc import killerspots # source: 'G:\TestClips&Co\files\noisy cartoons examples\1080p_v2.mp4' # current color space: YUV420P8, bit depth: 8, resolution: 1440x1080, fps: 25, color matrix: 709, yuv luminance scale: limited, scanorder: progressive # Loading G:\TestClips&Co\files\noisy cartoons examples\1080p_v2.mp4 using LibavSMASHSource clip = core.lsmas.LibavSMASHSource(source="G:/TestClips&Co/files/noisy cartoons examples/1080p_v2.mp4") # Setting color matrix to 709. clip = core.std.SetFrameProps(clip, _Matrix=1) clip = clip if not core.text.FrameProps(clip,'_Transfer') else core.std.SetFrameProps(clip, _Transfer=1) clip = clip if not core.text.FrameProps(clip,'_Primaries') else core.std.SetFrameProps(clip, _Primaries=1) # 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 = killerspots.KillerSpots(clip=clip) # denoising using MCTemporalDenoise clip = havsfunc.MCTemporalDenoise(i=clip, settings="very high", ncpu=1) # set output frame rate to 25.000fps clip = core.std.AssumeFPS(clip=clip, fpsnum=25, fpsden=1) # Output clip.set_output() Calling: Code:
VSPipe.exe --progress E:\Output\encodingTempSynthSkript_2022-02-20@16_37_30_9010.vpy -c y4m NUL] Code:
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001fe31031d00] stream 0, timescale not set Script evaluation done in 1.18 seconds Frame: 209/1992 (11.73 fps) When not using advanced=True, only 'clip = core.rgvs.Clense(clip)' will be called and the scripts runs fine. So I suspect the issue is with 'rdvs.RestoreMotionBlocks'. since the RemoveDirt version I use is the 64bit one from above which from 2013 I was wondering whether this could be due to some incompatibility with the current Vapoursynth version or if anyone has an idea how to fix this. Cu Selur Ps.: read over at https://forum.doom9.org/showthread.php?t=176199 that the Vapoursynth port seems to be known to be buggy,.. :/ Last edited by Selur; 20th February 2022 at 17:04. |
5th June 2022, 15:10 | #20 | Link |
Registered User
Join Date: Oct 2001
Location: Germany
Posts: 7,551
|
In case someone has the knowledge and motivation to look into RemoveDirts RestoreMotionBlocks randomly crashing:
When I change Code:
clip = core.rdvs.RestoreMotionBlocks(clensed, clip, alternative=alt, pthreshold=4, cthreshold=6, gmthreshold=40, dist=3, dmode=2, noise=limit, noisy=12) Code:
clip = core.rdvs.RestoreMotionBlocks(clensed, clip, alternative=alt, pthreshold=4, cthreshold=6, gmthreshold=40, dist=3, dmode=2, noise=limit, noisy=0) So the problem probably lies somehwere in the noise handling during motion detection. Cu Selur |
Thread Tools | Search this Thread |
Display Modes | |
|
|