View Full Version : 21 grams — Degraining challenge
tormento
7th May 2020, 00:28
This is really hard. The entire movie is a mess to degrain, with different films and so.
But this part (https://www.mediafire.com/file/htifu1tuy5gmhuu/BD_21_grammi.mkv/file) is a real nightmare.
I went up to MDegrain9 and ThSAD 800 with really poor results.
I need your help.
Enjoy. :devil:
lansing
7th May 2020, 01:45
Neatvideo is your friend
hello_hello
7th May 2020, 04:02
I tried a few different scripts, resizing to 720p first to speed it up, but the scripts seemed to do better at 720p anyway. I don't know how you'd remove a lot of that noise without creating some degree of mush, but the best result was from QTGMC in progressive mode (I'm sure you'll be happy to hear that). I only played with QTGMC's presets, and for some reason slower NoisePreset settings than the default removed less noise. You might be able to improve on it if you mess around with QTGMC's noise removal options. I think this is the first time I've used a value greater than 4 for EzDenoise.
QTGMC(InputType=1, Preset="very slow", EzDenoise=12)
QTGMC InputType_1_ Preset_very slow_ EzDenoise_12 720p.mkv (https://files.videohelp.com/u/210984/QTGMC%20InputType_1_%20Preset_very%20slow_%20EzDenoise_12%20720p.mkv) (1.7MB)
manolito
7th May 2020, 07:18
Extreme source - extreme filters... :devil:
Here is my result:
https://www.sendspace.com/file/4cosmg
My filters (all very retro):
RemoveGrain(mode=22)
degrainmedian(mode=2)
undot()
deen()
DenoiseSharpen(mode=22)
asharp(1,4)
RemoveGrain(mode=22)
degrainmedian(mode=2)
undot()
deen()
DenoiseSharpen(mode=22)
asharp(1,4)
Just 1 instance of the filter chain was not enough, so I repeated the whole chain. Doesn't look that bad to me...
real.finder
7th May 2020, 07:36
try STpresso/Spresso then denoise my help
hello_hello
7th May 2020, 08:12
My filters (all very retro):
Just 1 instance of the filter chain was not enough, so I repeated the whole chain. Doesn't look that bad to me...
And I thought I was at risk of causing tormento's head to spin by downscaling my encode to 720p. :)
tormento
7th May 2020, 08:18
Resizing is extreme ratio. On thousand of sources, I did it only twice, if I recall well.
Come on, you can do better than that. :D
tormento
7th May 2020, 08:20
Just 1 instance of the filter chain was not enough, so I repeated the whole chain. Doesn't look that bad to me...
Good try but too many details lost.
SMDegrain on extreme settings can do better but not the best.
tormento
7th May 2020, 08:25
try STpresso/Spresso then denoise my help
Come on... you can do better than this. At least try some script out of your hat. :rolleyes:
How about:
dfttest(sigma=400) #try out different sigma, up to 800 …..
smdegrain(tr=9,thsad=1000)
MCDegrainSharp(frames=3)
Boulder
7th May 2020, 08:46
The grain is an artistic effect in this case, so I really wouldn't worry about downscaling to 720p if you already change the vision the director had :)
I challenge you to test if you can spot the difference between a properly downscaled (Bicubic parameters optimized by Zopti) and a non-downscaled version during playback on your TV. You'd be surprised how small or even negligible the difference is for many, many sources. The bitrate savings are quite big..
ChaosKing
7th May 2020, 08:46
Theoretically https://github.com/HomeOfVapourSynthEvolution/VapourSynth-BM3D should give good results, but I don't get good results. :( Maybe it is only really good for noise but not for grain.
My try with MLDegrain+smdegrain
https://filehorst.de/d/deJciyII
SlowDelivery
7th May 2020, 08:53
I don't have much experience but recently I've tried a lot of different denoising filters and found MCTemporalDenoise to be good.:)
This is really slow but gave good results:
MCTemporalDenoise(settings="very high",thSAD=800,sharp=false,stabilize=false)
SMDegrain(tr=2,thSAD=800)
RemoveDirtMC(5,false)
Picture: https://ibb.co/rMCbMfS
If the above is too slow, perhaps you can try
MCTemporalDenoise(settings="high",thSAD=800,sharp=false,stabilize=false)
SMDegrain(tr=1,thSAD=800)
RemoveDirtMC(10,false)
Picture: https://ibb.co/K04YKYr
real.finder
7th May 2020, 09:01
Come on... you can do better than this. At least try some script out of your hat. :rolleyes:
maybe later, but IIRC Didée did Degraining source like this before (I remember the video sample was of a man drinking with glass) but I don't know where the link for the post now :D, anyway IIRC it's done by mdegrain with some strong prefilter
Theoretically https://github.com/HomeOfVapourSynthEvolution/VapourSynth-BM3D should give good results, but I don't get good results. :( Maybe it is only really good for noise but not for grain.
My try with MLDegrain+smdegrain
https://filehorst.de/d/deJciyII
isn't Theoretically BM3D mean MC + 3D Denoiser?
Boulder
7th May 2020, 09:14
maybe later, but IIRC Didée did Degraining source like this before
This is something that might be interesting. I remembered that he did some tricks with Aliens -- lots of grain but not excessive like 21 grams.
https://forum.doom9.org/showthread.php?t=161413
tormento
7th May 2020, 10:31
My last attempt:
SMDegrain (tr=9, thSAD=1000, refinemotion=false, n16=true, mode=0, contrasharp=false, PreFilter=4, truemotion=true, plane=4, chroma=true)
Results:
image (https://lensdump.com/i/jBA0Yb)
video (https://www.mediafire.com/file/57w6422rtb8vez2/grams_9_1000_TM.mkv/file)
maybe later
I tried to use subpixel=3 option, that uses NNEDI3, but nothing happened. Can you check the SMDegrain script?
real.finder
7th May 2020, 11:04
Spresso(10,30).STpresso(10,30,4,22,8,49,1,mc=true) #last updates
SMDegrain (tr=6, thSAD=1000, refinemotion=false, mode=0, contrasharp=false, PreFilter=2, truemotion=true, plane=4, chroma=true)
https://i.postimg.cc/fSMdrJ5Y/New-File-10-000020.png (https://postimg.cc/fSMdrJ5Y)
real.finder
7th May 2020, 11:08
I tried to use subpixel=3 option, that uses NNEDI3, but nothing happened. Can you check the SMDegrain script?
I don't think it's good to use it with your source, maybe that why it did nothing, anyway IIRC it's for better quality and less detail loss not for remove more grain, and it's seems do nothing for HD source since HD use pel=1 by default
tormento
7th May 2020, 11:10
I don't think it's good to use it with your source, maybe that why it did nothing, anyway IIRC it's for better quality and less detail loss not for remove more grain, and it's seems do nothing for HD source since it use pel=1
I did not mean it does visually nothing, I mean it doesn't change fps or file size even of a byte, as if it wouldn't be enabled.
ChaosKing
7th May 2020, 11:18
"subpixel=3" condition is pelclip = pel>1 && subpixel == 3
so pel needs to be > 1 to use nnedi. otherwise it does nothing, like you said.
see
https://github.com/realfinder/AVS-Stuff/blob/ef64bca62a430ee17f76f651a0f032a586912a93/avs 2.5 and up/SMDegrain.avsi#L88
https://github.com/realfinder/AVS-Stuff/blob/ef64bca62a430ee17f76f651a0f032a586912a93/avs 2.5 and up/SMDegrain.avsi#L212
tormento
7th May 2020, 11:21
"subpixel=3" condition is pelclip = pel>1 && subpixel == 3
so pel needs to be > 1 to use nnedi
You are right.
I'd like, anyway, to try and use it with standard pel.
Boulder
7th May 2020, 11:27
NNEDI3 is probably used for upscaling the pelclip. If pel=1 --> no upscale. I see no reason to not use pel=2 for HD.
hello_hello
7th May 2020, 11:39
Based on his screenshot, real.finder's example seems to be the winner so far. I'll have to try Spresso.STpresso myself. I was completely oblivious to them.
tormento
7th May 2020, 12:04
Spresso(10,30).STpresso(10,30,4,22,8,49,1,mc=true) #last updates
SMDegrain (tr=6, thSAD=1000, refinemotion=false, mode=0, contrasharp=false, PreFilter=2, truemotion=true, plane=4, chroma=true)
video (https://www.mediafire.com/file/iae1l6fnejoikev/grams_SPresso.mkv/file) output
Really hard to say which is better, if mine or yours. The discriminating factor could be fps: mine is 6.10, yours is 4.09.
P.S: I have always questioned myself about real meaning of truemotion. I read explanation multiple times and it's really a dice roll to find when it's good and when it's bad for a movie. Your idea?
P.P.S: Why to you chain the spatiotemporal version of Spresso with the spatial one? Isn't STpresso already including the spatial part? And why have two version of the same script exist? Isn't STpresso a superset of Spresso?
My last attempt:
SMDegrain (tr=9, thSAD=1000, refinemotion=false, n16=true, mode=0, contrasharp=false, PreFilter=4, truemotion=true, plane=4, chroma=true)
What is PreFilter=4? Isn't the selection range -1 …… 3?
Which version of SMDegrain are you using? Thanks.
tormento
7th May 2020, 12:34
What is PreFilter=4?
Use KNLMeansCL, lot faster.
Which version of SMDegrain are you using? Thanks.
SMDegrain-3.1.2·106.avsi
tormento
7th May 2020, 12:36
I did some tries using either clang plugins or msvc plugins (where available) on latest Spresso script from real.finder.
They funny thing is they ended with the same 4.24 fps result. And not on the short clip I sent here, a much longer one I use to better test (if you need I can upload).
Seems the bottleneck is MVTools or something else but not the compiler version.
P.S: Final bitrate of clang is 4450.15 kB/s, of msvc is 4450.16 kB/s. LOL
real.finder
7th May 2020, 16:12
P.S: I have always questioned myself about real meaning of truemotion. I read explanation multiple times and it's really a dice roll to find when it's good and when it's bad for a movie. Your idea?
https://forum.videohelp.com/threads/369142-Simple-MDegrain-Mod-v3-1-2d-A-Quality-Denoising-Solution/page6#post2458832
and like other settings, it depend on the source you deal with
P.P.S: Why to you chain the spatiotemporal version of Spresso with the spatial one? Isn't STpresso already including the spatial part? And why have two version of the same script exist? Isn't STpresso a superset of Spresso?
I see Didée use it like this https://forum.doom9.org/showpost.php?p=1551871&postcount=2
Dogway
8th May 2020, 10:42
My last attempt:
SMDegrain (tr=9, thSAD=1000, refinemotion=false, n16=true, mode=0, contrasharp=false, PreFilter=4, truemotion=true, plane=4, chroma=true)
Really liking the result from that smdegrain call. I tried it myself with some tweaks and it looks like it recovers further details. With such kind of source I would add some digital noise on top to mask the remaining static grain.
Attempt: mediafire (https://www.mediafire.com/file/lj7yaadhcvbrt9b/Nuevo_AviSynth_Script5.mkv/file)
Never thought thsad=1000 was a thing, it gave me some ideas to improve smdegrain.
tormento
8th May 2020, 10:45
Really liking the result from that smdegrain call.
Welcome back!
I tried it myself with some tweaks and it looks like it recovers further details.
Would you share the script?
Never thought thsad=1000 was a thing, it gave me some ideas to improve smdegrain.
As you probably noticed, real.finder is now maintaining your script. A collaboration would be terrific!
Dogway
8th May 2020, 11:07
Thanks, from time to time I come over to update things, I'm grateful he is maintaining it I lost track of all updates so still need to catch up!
The script is a proof of concept, I did it in some passes, the last one a smear recovery which I found was interesting, I searched around and cretindesalpes had an implementation, so I tweaked it. It's some hard coded values but I would like to integrate it in a safe manner.
ffvideosource("BD 21 grammi.mkv").crop(0,20,0,-20).Dither_convert_8_to_16()
src=last
Dfttest(sstring="0.0:4.0 0.2:9.0 1.0:15.0",tbsize=1,u=true,v=true,lsb=true,quiet=true)
ditherpost(mode=6)
smdegrain(src.fluxsmoothT(3), tr=9, thSAD=1000, mfilter=last, n16=true, mode=0, contrasharp=false, prefilter=4, truemotion=true, plane=4, chroma=true)
smdegrain(tr=3, thSAD=250, refinemotion=true, n16=true, mode=0, contrasharp=true, prefilter=2, plane=4, chroma=true)
fslg_fix_dc(last,src, 1.0)
DitherPost(stacked=true,prot=false,mode=6)
Function fslg_fix_dc (clip flt16, clip src16, float "thr")
{
thr = Default (thr, 1.0)
lp_f = flt16.fslg_fix_dc_lowpass ()
lp_s = src16.KNLMeansCL(D=2, A=2, h=7.0,device_type="GPU",stacked=true).fslg_fix_dc_lowpass ()
hp_f = Dither_sub16 (flt16, lp_f, dif=true)
(thr < 0.1) ? lp_s : lp_f.Dither_limit_dif16 (lp_s, thr=thr, elast=2.0)
msk=SafeMotionMask(DitherPost(stacked=true,prot=false,mode=6),gam=0.6,mv=3,em=false,lm=1, motion=100,darkb=55)
Dither_merge16_8(flt16,Dither_add16 (hp_f, dif=true),msk,luma=true)
}
Function fslg_fix_dc_lowpass (clip src16)
{
src16
w = Width ()
h = Height () / 2
r = 8.5
Dither_resize16 (w, h, kernel="bicubic", a1=1, a2=0, fv=-1.0/r)
Dither_resize16 (w, h, kernel="bicubic", a1=1, a2=0, fh=-1.0/r)
}
tormento
8th May 2020, 11:39
The script is a proof of concept, I did it in some passes, the last one a smear recovery which I found was interesting
Do you mind to upload the finished product? :p
Dogway
8th May 2020, 11:44
Do you mean the script? it's the above one. I have to integrate it and try to make it faster by reusing code. I will add some other ideas I have, basically protection against high thSAD.
tormento
8th May 2020, 11:53
Do you mean the script?
I meant the video.
Dogway
8th May 2020, 12:38
I linked it above to mediafire, good morning haha
real.finder
8th May 2020, 22:41
what is SafeMotionMask?
anyway, since fslg_fix_dc_lowpass use Dither_resize16 with fv paramter this function can't be ported to HBD, just like https://forum.doom9.org/showpost.php?p=1907352&postcount=1125
Dogway
9th May 2020, 00:58
Guess I forgot to upload at the time. It's a function I used to work with masks, specially to mask out problematic motion artifacts like smearing. It's not pretty but it wasn't for release.
https://github.com/Dogway/Avisynth-Scripts/blob/master/SafeMotionMask.avsi
real.finder
9th May 2020, 03:14
maybe later, but IIRC Didée did Degraining source like this before (I remember the video sample was of a man drinking with glass) but I don't know where the link for the post now :D, anyway IIRC it's done by mdegrain with some strong prefilter
ok, I find it :cool: https://forum.doom9.org/showthread.php?p=1512464#post1512464
so I did some update https://raw.githubusercontent.com/realfinder/AVS-Stuff/Community/avs%202.5%20and%20up/SMDegrain.avsi
Spresso(10,30).STpresso(10,30,4,22,8,49,1,mc=true) #last updates
o = last
ox = o.width
oy = o.height
ox1 = 1280
oy1 = 704
ox2 = 640
oy2 = 360
sm1 = o.bicubicresize(ox1,oy1) # medium scale
sm2 = sm1.bicubicresize(ox2,oy2) # small scale
D12 = mt_makediff(sm2.bicubicresize(ox1,oy1),sm1,U=3,V=3) # residual of (small)<>(medium)
D1o = mt_makediff(sm1.bicubicresize(ox,oy),o,U=3,V=3) # residual of (medium)<>(original)
lev2 = sm2.MCDegrainMod(3,soft=true,TV_range=false) # filter on smalle scale
up1 = lev2.bicubicresize(ox1,oy1)
up2 = up1.bicubicresize(ox,oy)
D12.MCDegrainMod(3,up1,soft=false,thSAD=480,TV_range=false) # filter on medium scale
lev1 = up1.mt_makediff(last,U=3,V=3)
up3 = lev1.bicubicresize(ox,oy)
D1o.MCDegrainMod(6,up2,soft=true,thSAD=480) # filter on original scale
up3.mt_makediff(last,U=3,V=3)
https://i.postimg.cc/ZWz1sHX0/New-File-11-000020.png (https://postimg.cc/ZWz1sHX0)
real.finder
9th May 2020, 05:20
I don't have much experience but recently I've tried a lot of different denoising filters and found MCTemporalDenoise to be good.:)
This is really slow but gave good results:
MCTemporalDenoise(settings="very high",thSAD=800,sharp=false,stabilize=false)
SMDegrain(tr=2,thSAD=800)
RemoveDirtMC(5,false)
Picture: https://ibb.co/rMCbMfS
If the above is too slow, perhaps you can try
MCTemporalDenoise(settings="high",thSAD=800,sharp=false,stabilize=false)
SMDegrain(tr=1,thSAD=800)
RemoveDirtMC(10,false)
Picture: https://ibb.co/K04YKYr
yes, seems MCTemporalDenoise is very good!
tormento
9th May 2020, 09:38
so I did some update
Shouldn't be better fitted in the generic zswhatever.avsi?
Anyway what srfilter does, what are the possible values and consequences?
Could you explain please once for all the parameters not covered by smdegrain.html from Dogway too?
Anyway 3 level of resize degrain is insane :D
real.finder
9th May 2020, 10:03
Shouldn't be better fitted in the generic zswhatever.avsi?
Anyway what srfilter does, what are the possible values and consequences?
Could you explain please once for all the parameters not covered by smdegrain.html from Dogway too?
Anyway 3 level of resize degrain is insane :D
it's just to control rfilter in msuper (to make it output like Didée script)
tormento
9th May 2020, 10:32
it's just to control rfilter in msuper (to make it output like Didée script)
Ok, I just read MSuper documentation. How does rfilter influence denoising?
tormento
9th May 2020, 14:32
Spresso(10,30).STpresso(10,30,4,22,8,49,1,mc=true) #last updates
o = last
ox = o.width
oy = o.height
ox1 = 1280
oy1 = 704
ox2 = 640
oy2 = 360
sm1 = o.bicubicresize(ox1,oy1) # medium scale
sm2 = sm1.bicubicresize(ox2,oy2) # small scale
D12 = mt_makediff(sm2.bicubicresize(ox1,oy1),sm1,U=3,V=3) # residual of (small)<>(medium)
D1o = mt_makediff(sm1.bicubicresize(ox,oy),o,U=3,V=3) # residual of (medium)<>(original)
lev2 = sm2.MCDegrainMod(3,soft=true,TV_range=false) # filter on smalle scale
up1 = lev2.bicubicresize(ox1,oy1)
up2 = up1.bicubicresize(ox,oy)
D12.MCDegrainMod(3,up1,soft=false,thSAD=480,TV_range=false) # filter on medium scale
lev1 = up1.mt_makediff(last,U=3,V=3)
up3 = lev1.bicubicresize(ox,oy)
D1o.MCDegrainMod(6,up2,soft=true,thSAD=480) # filter on original scale
up3.mt_makediff(last,U=3,V=3)
Tried and I prefer the previous one you posted:
Spresso(10,30).STpresso(10,30,4,22,8,49,1,mc=true) #last updates
SMDegrain (tr=6, thSAD=1000, refinemotion=false, mode=0, contrasharp=false, PreFilter=2, truemotion=true, plane=4, chroma=true)
Look at the back glass borders, they are shaky.
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.