Log in

View Full Version : RemoveDirt crashes depending on mod


Selur
16th October 2023, 14:55
I noticed something odd when I using (this avi (https://drive.google.com/file/d/1KsUWZbPSrtUBdmg9GzcrcCa_7hZVmZEQ/view?usp=drive_link))
MPEG-4 Visual, color space: YUV420P8, bit depth: 8, resolution: 1500x1080, fps: 24, color matrix: 709, yuv luminance scale: limited, scanorder: progressive

and the following script:

# Imports
import vapoursynth as vs
# getting Vapoursynth core
import sys
import os
core = vs.core
# 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/DenoiseFilter/RemoveDirt/RemoveDirtVS.dll")
core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/SourceFilter/LSmashSource/vslsmashsource.dll")
# Import scripts
import removeDirt
# current color space: YUV420P8, bit depth: 8, resolution: 1500x1080, fps: 24, color matrix: 709, yuv luminance scale: limited, scanorder: progressive
# Loading C:\Users\Selur\Desktop\RemoveDirtCras\RemoveDirtConfusion.avi using LWLibavSource
clip = core.lsmas.LWLibavSource(source="G:/clips/RemoveDirtCrash/RemoveDirtConfusion.avi", format="YUV420P8", stream_index=0, cache=0, prefer_hw=0)
# Setting detected color matrix (709).
clip = core.std.SetFrameProps(clip, _Matrix=1)
# Setting color transfer info (709), when it is not set
clip = clip if not core.text.FrameProps(clip,'_Transfer') else core.std.SetFrameProps(clip, _Transfer=1)
# Setting color primaries info (), when it is not set
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 24
clip = core.std.AssumeFPS(clip=clip, fpsnum=24, fpsden=1)
clip = core.std.SetFrameProp(clip=clip, prop="_FieldBased", intval=0) # progressive

clip = removeDirt.RemoveDirt(input=clip, limit=10)

# set output frame rate to 24fps (progressive)
clip = core.std.AssumeFPS(clip=clip, fpsnum=24, fpsden=1)
# Output
clip.set_output()


Processing the script directly crashes when rendering the second frame.

when add to mod8:

clip = core.std.AddBorders(clip=clip, left=2, right=2, top=2, bottom=2) # add borders to archive mod 8 (vsRemoveDirt) - 1504x1084
# denoising using VsRemoveDirt
clip = removeDirt.RemoveDirt(input=clip, limit=10)
clip = core.std.CropRel(clip=clip, left=2, right=2, top=2, bottom=2) # removing borders (vsRemoveDirt) - 1500x1080

it works fine.
using:

clip = core.std.AddBorders(clip=clip, left=2, right=2, top=0, bottom=0) # add borders to archive mod 8 (vsRemoveDirt) - 1504x1080
# denoising using VsRemoveDirt
clip = removeDirt.RemoveDirt(input=clip, limit=10)
clip = core.std.CropRel(clip=clip, left=2, right=2, top=0, bottom=0) # removing borders (vsRemoveDirt) - 1500x1080

so seems like mod16 width is the problem.

when add to mod16:

clip = core.std.AddBorders(clip=clip, left=4, right=4, top=4, bottom=4) # add borders to archive mod 16 (vsRemoveDirt) - 1508x1088
# denoising using VsRemoveDirt
clip = removeDirt.RemoveDirt(input=clip, limit=10)
clip = core.std.CropRel(clip=clip, left=4, right=4, top=4, bottom=4) # removing borders (vsRemoveDirt) - 1500x1080

it crashes.

=> Would be nice to know if others can reproduce this too.

Cu Selur

_Al_
17th October 2023, 03:23
Is there RemoveDirtVS.dll available for download somewhere?
I think it is needed to run core.rdvs in script.

Selur
17th October 2023, 17:20
I uploaded the two RemoveDirt libaries I got (RemoveDirtVS.dll and vsremoveDirt.dll) to my GoogleDrive (https://drive.google.com/drive/folders/1ZzH44_L1tf3ABi0lZgKXKxpPyX7ZGQyX).
RemoveDirtVS.dll was from (https://forum.doom9.org/showthread.php?t=169771 when the download worked and no clue where the other was from, but both have this issue.
If someone has a newer RemoveDirt build which might fix this, please let me know.

Cu Selur

_Al_
18th October 2023, 01:11
same results as you described, original video crushed, it worked with first crop(mod8), not the second(mod16), used this script:
import vapoursynth as vs
from vapoursynth import core

def RemoveDirt(input, repmode=16, remgrainmode=17, limit=10):
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=limit, noisy=12)
return core.rgvs.RemoveGrain(corrected, mode=[remgrainmode,remgrainmode,1])

clip = core.ffms2.Source("RemoveDirtConfusion.avi")
clip = RemoveDirt(input=clip, limit=10)
clip.set_output()

Selur
18th October 2023, 04:13
Thanks for testing, now I at least know that it is not some strange thing due to my system.

yuygfgg
2nd October 2025, 10:04
I've converted all SSE code to scalar, and the 1508x1088 input clip works for me.

Also fixed an issue related to dFactor.

Please test to see if it resolves your issue.

My fork: https://github.com/yuygfgg/removedirtvs. Binaries can be found in Actions.

Selur
2nd October 2025, 14:23
Nice :D Will test and report back.

Cu Selur

Selur
2nd October 2025, 14:47
Ran it through ~20 test clips and had no crash, so it looks fine so far.
Will report back in case I encounter problems.
Thanks.

Cu Selur

Selur
4th October 2025, 17:54
@yuygfgg: planning a release any time soon? :D

yuygfgg
4th October 2025, 18:09
@yuygfgg: planning a release any time soon? :D

https://github.com/yuygfgg/removedirtvs/releases/tag/R1

Z2697
5th October 2025, 07:16
Of course you need a release, actions artifacts arn't "perpetual"

Selur
5th October 2025, 07:37
Thanks!
I usually try to build the last tagged release, and actions tend to vanish after a while. :)

Cu Selur

yuygfgg
7th October 2025, 07:59
I just found that pinterf's fork also supports vapoursynth. If it works, it would be a better replacement of mine.

https://github.com/pinterf/RemoveDirt

Selur
7th October 2025, 16:09
Thanks for the info.

Z2697
8th October 2025, 07:07
The SSE code might just be too old, the scalar version or more precisely the optimization done by compiler is slightly faster.
Maybe you can do it on the pfmod fork, or port the pfmod to your fork.

Selur
8th October 2025, 15:40
yes, a pull request to pinterf would be cool.