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 > Avisynth Usage

Reply
 
Thread Tools Search this Thread Display Modes
Old 13th October 2018, 00:00   #1  |  Link
ErazorTT
Registered User
 
Join Date: Mar 2003
Location: Germany
Posts: 215
TemporalDegrainV2

Hi all,

I want to share an updated version of the script TemporalDegrain.

The reason for the update was to combine TemporalDegrain with the relevant parts of QTGMC:
Although MDegrain of MVTools with Didees contra-sharpening already performes great, the additional stage of motion compensated fourier denoising can do wonders.
Together with this, the original motion estimation is also much improved using the exceptional approach of QTGMC instead of the very mushy intermediate stream which was losing some vectors in sceenes with low contrast and diverging movement.

With this optional fourier denoising setting the result can be up to completely grainless, much better compressable and together with the optional dithering it is guaranteed to produce no banding, yielding a very natural look in total.

Here a comparison of a scene of s2e1 of Breaking Bad, starting with the original [505KB for the JPEG still]:


v1.23: TemporalDegrain(degrain=2) [310KB for the JPEG still]


v2.0: TemporalDegrain2(degrainTR=2,postFFT=3,postSigma=3) [216KB for the JPEG still]

Compared to V1.23 the out-of-focus regions of V2.0 have almost no remaining grain anymore (can be even better seen on the moving picture) helping compressablity (see the JPEG file sizes as a proxy).
The in-focus regions however have still all details of the original frame.

And now the comparison of why I think it was time for an improved motion estimation over v1 of TemproralDegrain.
original from Breaking Bad s1e1, the camera moves following the car:


v1.23: TemporalDegrain(degrain=2)

The motion of the low contrast tarmac is not captured well and thus the details are being washed away.

v2.10: TemporalDegrain2(degrainTR=2)

More of the details of the tarmac are preserved.

In this thread further down are some movie samples: here
I have also made some performance measurements: here

Greets,
enjoy!

Changelog:

Dec 20, 2021: v2.3.4 (if you ever had a reason to use something else than postFFT 0, 1 or 2 try again now!)
- dithering is delayed to after contraSharpending which increases quality of dithering, decreasing banding and noise (postDither=2), old behaviour is regained with postDither=1
- postDither argument has been inverted! [new postDither = (-1) * old postDither] <--- if you ever explicitly set the postDither argument, read this line

Dec 21, 2021: v2.4.0 (This and later releases need AviSynth 3.7.1+)
- add BM3D_CPU & BM3D_CUDA (based on BM3D prefilter of Dogway's SMDegrain) and mods by kedautinh12 (Aug 12 - Dec 19)

Dec 21, 2021: v2.4.1
- small speed increase for BM3D (thanks to kedautinh12)

Jan 05, 2022: v2.4.2
- allow enabling or disabling of chroma and luma filtering for BM3D (thanks to kedautinh12)
- allow denoising on different planes at the two stages (degrainPlane vs postPlane)

Feb 15, 2022: v2.4.3
- add limit r to 3 when CUDA=true for BM3D (based on BM3D prefilter of Dogway's SMDegrain) and mods by kedautinh12
- add preset for BM3D (based on BM3D prefilter of Dogway's SMDegrain) and mods by kedautinh12

Apr 05, 2022: v2.5.0
- allow distinct postFFT and postSigma for luma and chroma

May 01, 2022: v2.6.0
- clean chroma more by also using the first degrain step
- tweak scene change detection factors

May 02, 2022: v2.6.1
- fix grainLevelSetup which was broken in previous release

May 10, 2022: v2.6.2
- some fixes and cleanup

Jun 06, 2022: v2.6.3
- increase possible range of grainLevel
- allow for multiple usages of this script

Feb 11, 2023: v2.6.4
- always undot before postFFT stage, increasing FFT efficiency by quite a bit when degrain was disabled
- mention suggested settings inside the script file

Feb 28, 2023: v2.6.6
- cleaning chroma only in one step, to ameliorate the chroma shift bug in mvtools MDegrain

Jan 14, 2024: v2.6.7
- forward device_type and device_id to KNLMeansCL

Link to newest version: >here<
All current and old versions can be downloaded: >here<
Attached Files
File Type: zip TemporalDegrain-v2.3.4.zip (9.6 KB, 278 views)
File Type: zip TemporalDegrain-v2.6.6.zip (11.9 KB, 107 views)
Attachments Pending Approval
File Type: zip TemporalDegrain-v2.6.7.zip

Last edited by ErazorTT; 5th January 2024 at 14:39.
ErazorTT is offline   Reply With Quote
Old 13th October 2018, 12:35   #2  |  Link
tormento
Acid fr0g
 
tormento's Avatar
 
Join Date: May 2002
Location: Italy
Posts: 2,630
Quote:
Originally Posted by ErazorTT View Post
I want to share an updated version of the script TemporalDegrain.
I will try ASAP and tell you results.

You did a little mistype in the comments:
Code:
# KNLMeansCLL: https://github.com/Khanattila/KNLMeansCL/releases            #
I am a bit confused too about the role of KNLMeansCL in the script. You state as optional but I can't see any knob or boolean to use it, even if I see trace of it in the code.

I am a bit puzzled why you use FFT3DFilter and FFT3DGPU and not only one of them.

I'd like also to know if the script is high bitdepth aware or internally working in high bit precision or 8 bit only.

I humbly suggest to use thumbnails for the images, not to send to hell thread formatting
__________________
@turment on Telegram

Last edited by tormento; 13th October 2018 at 12:41.
tormento is offline   Reply With Quote
Old 13th October 2018, 18:06   #3  |  Link
johnmeyer
Registered User
 
Join Date: Feb 2002
Location: California
Posts: 2,699
I've tried a lot of noise reduction and degraining plugins and scripts. You really cannot tell much from static shots because many of these approaches can cause really weird artifacts that can only be seen when you watch the resulting video. This is because you sometimes get correlation between grain in adjacent frames which results in really weird alignment of some of the residual grains, as well as other artifacts, none of which are apparent in a single frame.

So, it would be useful to have a side-by-side before/after video.
johnmeyer is offline   Reply With Quote
Old 14th October 2018, 15:09   #4  |  Link
ErazorTT
Registered User
 
Join Date: Mar 2003
Location: Germany
Posts: 215
Thanks a lot for the quick feedback!!

Quote:
Originally Posted by tormento View Post
You did a little mistype in the comments:
Oh I will correct that.

Quote:
Originally Posted by tormento View Post
I am a bit confused too about the role of KNLMeansCL in the script. You state as optional but I can't see any knob or boolean to use it, even if I see trace of it in the code.
Yeah, right I forgot to mention that in the file. It is being set by postFTT=4.

Quote:
Originally Posted by tormento View Post
I am a bit puzzled why you use FFT3DFilter and FFT3DGPU and not only one of them.
I was asuming FFT3DGPU would be a faster version of FFT3DFilter but if I am not mistaken currently only FFT3DFilter is still maintained, thus I though to leave the decission to the user.

Quote:
Originally Posted by tormento View Post
I'd like also to know if the script is high bitdepth aware or internally working in high bit precision or 8 bit only.
I have made some of the necessary changes to the inner working as a first step to supporting high bitdepth but I am not there yet. Thats what I plan to do as a next step.

Quote:
Originally Posted by tormento View Post
I humbly suggest to use thumbnails for the images, not to send to hell thread formatting
Let me see if I can figure out how to do that...

Quote:
Originally Posted by johnmeyer View Post
...it would be useful to have a side-by-side before/after video.
Yes very true, I will prepare some samples
ErazorTT is offline   Reply With Quote
Old 14th October 2018, 16:47   #5  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,981
Quote:
Let me see if I can figure out how to do that...
PostImage.org allows anonymous upload, but also easy to make account.
Below, HotLink for forum, and then Thumbnail for forum below that.



__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???
StainlessS is offline   Reply With Quote
Old 14th October 2018, 18:21   #6  |  Link
ErazorTT
Registered User
 
Join Date: Mar 2003
Location: Germany
Posts: 215
Quote:
Originally Posted by StainlessS View Post
PostImage.org allows anonymous upload, but also easy to make account.
Awesome
ErazorTT is offline   Reply With Quote
Old 15th October 2018, 11:42   #7  |  Link
tormento
Acid fr0g
 
tormento's Avatar
 
Join Date: May 2002
Location: Italy
Posts: 2,630
Quote:
Originally Posted by ErazorTT View Post
Awesome
I use lensdump too.
__________________
@turment on Telegram
tormento is offline   Reply With Quote
Old 15th October 2018, 22:02   #8  |  Link
Forteen88
Herr
 
Join Date: Apr 2009
Location: North Europe
Posts: 556
Thanks! Is this script of yours also great against "dancing grain"?
I've noticed that I can barely stand "dancing grain" in videos anymore :P
Oh, I remember that the movie "The Good, the Bad and the Ugly" Blu-ray had really much annoying grain, I could barely concentrate on the movie.
EDIT: But this does not mean that I hate all grain. I can accept a bit of grain if it's not too much!

Last edited by Forteen88; 17th October 2018 at 12:17.
Forteen88 is offline   Reply With Quote
Old 16th October 2018, 04:41   #9  |  Link
hello_hello
Registered User
 
Join Date: Mar 2011
Posts: 4,861
Interesting.....

For a long time QTGMC has been my "go to" noise filter. Not that it's perfect, as being a de-interlacer it can sometimes create unwanted side effects "normal" denoising scripts don't, but where there's movement it's blurring to noise removal ratio tends to be pretty good. Only the other day I found myself wondering how hard it'd be to modify QTGMC to remove the de-interlacing completely for progressive video, and if it was possible, would it adversely effect it's ability to denoise.

Anyhow..... for a quick and very unscientific comparison. The "original video" is the script output with only resizing applied. The filtered screenshots were taken after encoding with x264, CRF18, Preset Slower(ish). I'm not sure why I did it that way, but I guess ultimately it's all about how the encoded version looks.

Thumbnails so as not to upset the scrolling police (and because it is annoying). It looks like you need to click on a thumbnail to open an image on the PostImage site, then right click and select "view image" for the full size version.

Screenshot 1. The camera was panning down a little. The playing card top/left shows the most detail difference.
Screenshot 2 was static.
Screenshot 3 had lots of movement. The stripes on the guy's shirt would be typical noise removal victims.

Edit: Whoops. The first three screenshots were off by a frame relative to the others. They're fixed.


Original 1080p video resized to 720p.
Spline36Resize(1280,536)








Spline36Resize(1280,536)
QTGMC(InputType=1, EzDenoise=1.5)
GradFun3()








Spline36Resize(1280,536)
TemporalDegrainV2()
GradFun3()








Spline36Resize(1280,536)
TemporalDegrain()
GradFun3()






Last edited by hello_hello; 16th October 2018 at 15:24.
hello_hello is offline   Reply With Quote
Old 19th October 2018, 22:52   #10  |  Link
ErazorTT
Registered User
 
Join Date: Mar 2003
Location: Germany
Posts: 215
I updated the first post to include a comparison concerning the motion estimation! Since this was one of the main driving points I figured it would be good to show.

Quote:
Originally Posted by hello_hello View Post
Screenshot 1. The camera was panning down a little. The playing card top/left shows the most detail difference.
Screenshot 2 was static.
Screenshot 3 had lots of movement. The stripes on the guy's shirt would be typical noise removal victims.
Hm QTGMC yeilds better results for 1 and 3. I wonder why... What version of QTGMC were you using?
Could you please try to run again with version 2.0.1 and play with options meBlksz=8/16 and/or meTM=true/false for TemporalDegrain2?
(Use the new updated version 2.0.1 from the first post. With the function renamed to TemporalDegrain2 it should also be easier to compare to v1)

Last edited by ErazorTT; 20th October 2018 at 00:29.
ErazorTT is offline   Reply With Quote
Old 20th October 2018, 01:26   #11  |  Link
ErazorTT
Registered User
 
Join Date: Mar 2003
Location: Germany
Posts: 215
Quote:
Originally Posted by johnmeyer View Post
So, it would be useful to have a side-by-side before/after video.
Here you have the motion pricture you requested. I used x264 with crf 16 at "Very Slow" for all three:
Original
TD1.23: TemporalDegrain(degrain=2)
TD2.10: TemporalDegrain2(degrainTR=2,postFFT=3,postSigma=3,postDither=-1)

Be sure to actually download the files and do not just watch the preview in the browser! The quality of the browser preview is miserable..

Quote:
Originally Posted by Forteen88 View Post
... Is this script of yours also great against "dancing grain"?
Yes you should be able to go from "mostly gone" to "OMG WFT, how is that even possible that a movie looks that clean"
Look at the files in this post, the grain is gone.

Last edited by ErazorTT; 26th October 2018 at 23:14.
ErazorTT is offline   Reply With Quote
Old 20th October 2018, 16:06   #12  |  Link
Taurus
Registered User
 
Taurus's Avatar
 
Join Date: Mar 2002
Location: Krautland
Posts: 903
@ErazorTT:
Please upload your Temporaldegrain2.zip to a filehoster.
It can take days, weeks or months for "Attachments Pending Approval"
Or just show the avsi in quotes here in this thread.
Thank you.
Taurus is offline   Reply With Quote
Old 20th October 2018, 18:13   #13  |  Link
ErazorTT
Registered User
 
Join Date: Mar 2003
Location: Germany
Posts: 215
@Taurus
Great you made me aware of that! I just updated the first post accordingly. I wonder however why the attachment could be downloaded right after I opened the thread...

Last edited by ErazorTT; 20th October 2018 at 18:27.
ErazorTT is offline   Reply With Quote
Old 21st October 2018, 00:21   #14  |  Link
tebasuna51
Moderator
 
tebasuna51's Avatar
 
Join Date: Feb 2005
Location: Spain
Posts: 7,019
If you modify the first post I can't know when I need approve the attachment, sorry.
Approved now.

I only read new post.
__________________
BeHappy, AviSynth audio transcoder.
tebasuna51 is offline   Reply With Quote
Old 21st October 2018, 07:33   #15  |  Link
ErazorTT
Registered User
 
Join Date: Mar 2003
Location: Germany
Posts: 215
@tebasuna51: I have seen in other threads that this is the way people seem to operate, namely having the first post up to date. What would then be the best way to update the attachments? Do other let you know that they want something approved?
ErazorTT is offline   Reply With Quote
Old 21st October 2018, 10:09   #16  |  Link
tebasuna51
Moderator
 
tebasuna51's Avatar
 
Join Date: Feb 2005
Location: Spain
Posts: 7,019
When avsi text is bigger than 16000 chars (like TemporalDegrain2.avsi is) can't be included like text in the post, then you can use:

1) Pastebin (the user can read the source before download it)

2) Other upload free sites: DriveGoogle, Mediafire, Sendspace,... (like you make here)

3) If attach please make a new post with something like:

"New version X.Y attached in first post, please approve it"
__________________
BeHappy, AviSynth audio transcoder.
tebasuna51 is offline   Reply With Quote
Old 21st October 2018, 13:27   #17  |  Link
hello_hello
Registered User
 
Join Date: Mar 2011
Posts: 4,861
Quote:
Originally Posted by ErazorTT View Post
What version of QTGMC were you using?
QTGMC 3.357s.

Quote:
Originally Posted by ErazorTT View Post
Could you please try to run again with version 2.0.1 and play with options meBlksz=8/16 and/or meTM=true/false for TemporalDegrain2?
(Use the new updated version 2.0.1 from the first post. With the function renamed to TemporalDegrain2 it should also be easier to compare to v1)
I didn't bother uploading screenshots with TemporalDegrain2(meTM=true) as the blurring always increased. It appears to have been true for the last version of the script. Were there any other changes aside from making meTM=false the default? It seems to be better now.

Two of the screenshots are the same frames as before, although this time the screenshots are taken directly from the script output and I increased QTGMC's noise removal a bit as I think it had an advantage there.

The new screenshot is of Val Kilmer's face as he was moving a little. Often the blurring of detail on someone's skin increases dramatically when they move, but it seems to be on a par with QTGMC now. There's a halo above the brim of his hat on the left side. It's in the source but largely hidden by noise. If there's an existing halo, QTGMC sometimes enhances it more than I'd like. TemporalDegrain2 enhanced it too, but so far, not quite as much.

QTGMC 3.357s takes functionality from SMDegrain to expand the levels to full range. I think it's only used for the motion search. The idea is to make it more accurate, but I don't know how much difference it makes. Any thoughts there?

Rather than upload 15 screenshots and post thumbnail links, here's a zip file.

Screenshots.zip
(13.1MB)

Last edited by hello_hello; 22nd October 2018 at 06:58.
hello_hello is offline   Reply With Quote
Old 21st October 2018, 13:30   #18  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,981
Another moderator suggested using "Report Post", to report where new attachment requires approval,
Report Post is found below avatar of the offending post as Red triangle with ! symbol inside.
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???
StainlessS is offline   Reply With Quote
Old 21st October 2018, 22:50   #19  |  Link
ErazorTT
Registered User
 
Join Date: Mar 2003
Location: Germany
Posts: 215
Quote:
Originally Posted by hello_hello View Post
Were there any other changes aside from making meTM=false the default?
Setting truemotion to false was the only functional change.

Quote:
Originally Posted by hello_hello View Post
It seems to be better now.
Thats really awesome! I pretty much forgot that truemotion switch in MVTools. So, huge thanks for you screenshots. Looking at those and comparing back and forth with the ones from QTGMC somehow reminded me of that again.

Quote:
Originally Posted by hello_hello View Post
QTGMC 3.357s takes functionality from SMDegrain to expand the levels to full range. I think it's only used for the motion search. The idea is to make it more accurate, but I don't know how much difference it makes. Any thoughts there?
Hm I will have to analyze that. Right off the top of my head I do not know what exactly you mean. I will look into the code and come back if I see something.

Last edited by ErazorTT; 21st October 2018 at 22:55.
ErazorTT is offline   Reply With Quote
Old 22nd October 2018, 06:30   #20  |  Link
hello_hello
Registered User
 
Join Date: Mar 2011
Posts: 4,861
Quote:
Originally Posted by ErazorTT View Post
Hm I will have to analyze that. Right off the top of my head I do not know what exactly you mean. I will look into the code and come back if I see something.
It expands levels from TV range to PC range for the MSuper clip. I don't know how much difference it makes. Have a look under line #187 here.

https://pastebin.com/u1xsPLwK
# Default Auto-Prefilter - Luma expansion TV->PC (up to 16% more values for motion estimation)

Maybe now I understand why I've always thought SMDegrain and other mvtools2 based denoising scripts blur too much when there's motion. A quick look at the SMDegrain script indicates TrueMotion is disabled by default for resolutions above standard definition (although it still blurs more than QTGMC), and it's enabled by default for mvtools2 itself.
It's disabled by default for MCTemporalDenoise and MCTemporalDenoiseMod (MCTD), so maybe that's why they tend to blur less (from memory, I haven't used them for a while).
I hadn't played with the TrueMotion option myself until now.

Cheers.

Last edited by hello_hello; 24th October 2018 at 14:15.
hello_hello 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 10:14.


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