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 5th March 2023, 15:59   #2101  |  Link
anton_foy
Registered User
 
Join Date: Dec 2005
Location: Sweden
Posts: 721
Quote:
Originally Posted by LeXXuz View Post
Is there something missing? Taking a closer look at that script I don't see t3 being predefined
Oops looks like I hit a 3 somehow. Typo sorry.
anton_foy is offline   Reply With Quote
Old 5th March 2023, 16:54   #2102  |  Link
LeXXuz
21 years and counting...
 
LeXXuz's Avatar
 
Join Date: Oct 2002
Location: Germany
Posts: 716
Quote:
Originally Posted by Dogway View Post
The original by Terka uses 't' not 't3', anyway it's basically one of my prefilter recommendations but with ghosting and written in a convoluted manner.

Code:
function Calm2 (clip clp) {
    SMDegrain(clp,2,thSAD=1400,mode="TemporalGauss",pel=1,rfilter=0,str=0,tv_range=false,plane=0,truemotion=true)
    # vsTCanny(1.5,mode=-1,u=3,v=3) # This matched Terka's but I like ex_sbr() better
    ex_sbr(3,UV=3) }
And no, it didn't prevent the wobbling.

I don't know what's wrong with the one I suggested, it has no wobbling.
Have to work remotely on my machine via VNC from here so I don't have the visual fidelity like I would have by directly sitting in front of the screen. But I can still see a lot of ghosting in the prefilter clip. So I don't think it is suitable but surely was worth a try.

Your clip is wobbling a little on the left side in the archway. At least I think so, or is it just light flickering?
And it has a little bit too much noise for my taste. But still looks way better than the jelly look I came up with so far.

I'm sure now I have done something wrong. Because trying to merge your deflickering script bits with ex_autolevels into my scripts produced a lot of noticeable brightness changes along scenes which clearly is the opposite of what was intended.
LeXXuz is offline   Reply With Quote
Old 5th March 2023, 18:39   #2103  |  Link
Dogway
Registered User
 
Join Date: Nov 2009
Posts: 2,371
Quote:
Originally Posted by LeXXuz View Post
Have to work remotely on my machine via VNC from here so I don't have the visual fidelity like I would have by directly sitting in front of the screen. But I can still see a lot of ghosting in the prefilter clip. So I don't think it is suitable but surely was worth a try.
If you think that has ghosting I don't know what would be your stance on Calm(). The good part is you can protect more lowering thSAD, and prefilter doesn't need to be perfect either.

Quote:
Your clip is wobbling a little on the left side in the archway. At least I think so, or is it just light flickering?
That's local luma flicker, and can't be fixed at all, only reduced with temporal denoise. There might be a tiny bit of wobbling left here and there, but I would be curious to see how you improve that any further, that's the best you gonna get regarding that.
__________________
i7-4790K@Stock::GTX 1070] AviSynth+ filters and mods on GitHub + Discussion thread
Dogway is offline   Reply With Quote
Old 5th March 2023, 18:59   #2104  |  Link
LeXXuz
21 years and counting...
 
LeXXuz's Avatar
 
Join Date: Oct 2002
Location: Germany
Posts: 716
Quote:
Originally Posted by Dogway View Post
If you think that has ghosting I don't know what would be your stance on Calm().
Whoops. That actually was my stance on Calm() that anton_foy provided. Sorry for any misunderstanding.

Quote:
Originally Posted by Dogway View Post
That's local luma flicker, and can't be fixed at all, only reduced with temporal denoise.
I see. Well, I can accept that. What can't be fixed, can't be fixed as they say. And I don't have to bother with that anymore.

Could you please provide the script to your last sample clip. I'd like to give that a try on the whole film and see what it looks like in other scenes.
LeXXuz is offline   Reply With Quote
Old 5th March 2023, 19:58   #2105  |  Link
Dogway
Registered User
 
Join Date: Nov 2009
Posts: 2,371
Yes, it's the last one in this post, you can also try the one above, and play with some values if you want. Hope it's stable enough with SceneStats(), luckily pinterf fixed a memory leak in ScriptClip that could make things more stable (for next version).
__________________
i7-4790K@Stock::GTX 1070] AviSynth+ filters and mods on GitHub + Discussion thread
Dogway is offline   Reply With Quote
Old 5th March 2023, 21:40   #2106  |  Link
LeXXuz
21 years and counting...
 
LeXXuz's Avatar
 
Join Date: Oct 2002
Location: Germany
Posts: 716
Quote:
Originally Posted by Dogway View Post
Yes, it's the last one in this post, you can also try the one above, and play with some values if you want. Hope it's stable enough with SceneStats(), luckily pinterf fixed a memory leak in ScriptClip that could make things more stable (for next version).
Ah yes. I couldn't make that work because I couldn't find a StabPlus2() function in your repo.

Also I tried to process entirely in 16bit because I encode to 10bit afterwards. But when I removed that convert to 8bit in your upper sample script, I got an overlay error message in the output file shown saying something about bit depth mismatch. Can I run that in 16bit somehow?
LeXXuz is offline   Reply With Quote
Old 5th March 2023, 23:06   #2107  |  Link
Dogway
Registered User
 
Join Date: Nov 2009
Posts: 2,371
Stab2 is the proxy name I gave to Fred's stabilization example:
Code:
# https://forum.doom9.org/showthread.php?p=1981048
function Stabilize(clip c, int "offset", bool "info") {

    in = Default(info, false)
    of = Default(offset, 40)
 
    c
    vectors = MSuper().MAnalyse(isb=false)
    mdata   = MDepan(vectors, rot=false, zoom=false, error= 65)

    DePanStabilize(data=mdata,dxmax=of, dymax=of, zoommax=0, rotmax=0, method=1, mirror=15, prev=1, next=1, info=in)
    }
The script works for me, even at 16-bit removing the ConvertBits(8,dither=1) call after ex_Luma_Rebuild(). Don't use StabPlus(), Stabilization Tools Pack is outdated, use Fred's example.
__________________
i7-4790K@Stock::GTX 1070] AviSynth+ filters and mods on GitHub + Discussion thread

Last edited by Dogway; 5th March 2023 at 23:09.
Dogway is offline   Reply With Quote
Old 6th March 2023, 15:51   #2108  |  Link
Dogway
Registered User
 
Join Date: Nov 2009
Posts: 2,371
Quote:
Originally Posted by LeXXuz View Post
Quote:
Originally Posted by Dogway View Post
The original by Terka uses 't' not 't3', anyway it's basically one of my prefilter recommendations but with ghosting and written in a convoluted manner.

Code:
function Calm2 (clip clp) {
    SMDegrain(clp,2,thSAD=1400,mode="TemporalGauss",pel=1,rfilter=0,str=0,tv_range=false,plane=0,truemotion=true)
    # vsTCanny(1.5,mode=-1,u=3,v=3) # This matched Terka's but I like ex_sbr() better
    ex_sbr(3,UV=3) }
And no, it didn't prevent the wobbling.

I don't know what's wrong with the one I suggested, it has no wobbling.


Have to work remotely on my machine via VNC from here so I don't have the visual fidelity like I would have by directly sitting in front of the screen. But I can still see a lot of ghosting in the prefilter clip. So I don't think it is suitable but surely was worth a try.

Your clip is wobbling a little on the left side in the archway. At least I think so, or is it just light flickering?
And it has a little bit too much noise for my taste. But still looks way better than the jelly look I came up with so far.

I'm sure now I have done something wrong. Because trying to merge your deflickering script bits with ex_autolevels into my scripts produced a lot of noticeable brightness changes along scenes which clearly is the opposite of what was intended.
I found what was failing on Terka's function, the code is basically QTGMC's prefilter function when TR0=2 and SrchClipPP=3, but he omitted KeepOnlyBobShimmerFixes(). This gets rid of most ghosting, but leaves some behind though that might not impact output result (except for anime though). You can use my suggestion above raising thSAD even higher or use the alternative below.
Code:
function Calm2 (clip clp) {

    # temporal gaussian average
    clp.ex_blur3D(0,0,2,"weighted",UV=3)

    # Remove areas of difference between temporal blurred motion search clip and
    # bob that are not due to bob-shimmer - removes general motion blur
    QTGMCp_KeepOnlyBobShimmerFixes(clp,4,true,fulls=true)

    # Gaussian blur, or Smart blur for less damaged sources
    # vsTCanny(1.5,mode=-1,u=3,v=3)
    ex_sbr(3,UV=3) }
For very unstable sources this might be better as it will protect less and hence produce more stable output and less wobbling, it's also faster albeit a bit blurrier than TemporalGauss with SMDegrain. For your source replace ex_sbr(3) with the vsTCanny call. And I call this function as the last "pre" before SMDegrain()
__________________
i7-4790K@Stock::GTX 1070] AviSynth+ filters and mods on GitHub + Discussion thread

Last edited by Dogway; 6th March 2023 at 16:04.
Dogway is offline   Reply With Quote
Old 6th March 2023, 16:42   #2109  |  Link
anton_foy
Registered User
 
Join Date: Dec 2005
Location: Sweden
Posts: 721
Quote:
I found what was failing on Terka's function, the code is basically QTGMC's prefilter function when TR0=2 and SrchClipPP=3, but he omitted KeepOnlyBobShimmerFixes(). This gets rid of most ghosting, but leaves some behind though that might not impact output result (except for anime though). You can use my suggestion above raising thSAD even higher or use the alternative below.
Code:
function Calm2 (clip clp) {

    # temporal gaussian average
    clp.ex_blur3D(0,0,2,"weighted",UV=3)

    # Remove areas of difference between temporal blurred motion search clip and
    # bob that are not due to bob-shimmer - removes general motion blur
    QTGMCp_KeepOnlyBobShimmerFixes(clp,4,true,fulls=true)

    # Gaussian blur, or Smart blur for less damaged sources
    # vsTCanny(1.5,mode=-1,u=3,v=3)
    ex_sbr(3,UV=3) }
For very unstable sources this might be better as it will protect less and hence produce more stable output and less wobbling, it's also faster albeit a bit blurrier than TemporalGauss with SMDegrain. For your source replace ex_sbr(3) with the vsTCanny call. And I call this function as the last "pre" before SMDegrain()
This I forgot. But what about the vertical only shimmering in "QTGMCp_KeepOnlyBobShimmerFixes"? Can it be altered to fix horizontal and vertical shimmer since it is a progressive source?
Haven't tried but just removing mode_vertical can maybe screw it up.
anton_foy is offline   Reply With Quote
Old 6th March 2023, 17:10   #2110  |  Link
Dogway
Registered User
 
Join Date: Nov 2009
Posts: 2,371
Quote:
Originally Posted by anton_foy View Post
This I forgot. But what about the vertical only shimmering in "QTGMCp_KeepOnlyBobShimmerFixes"? Can it be altered to fix horizontal and vertical shimmer since it is a progressive source?
Haven't tried but just removing mode_vertical can maybe screw it up.
I would run it twice in that case, with TurnLeft()
By the way, I noticed that in QTGMC the source is blurred vertically before prefiltering, so I added spatial blur before ex_blur3d()
At the end I applied a deconvolution so it mimics more what QTGMC prefilter looks.
Code:
function Calm2 (clip clp) {

    # temporal gaussian average
    blr  = clp.removegrain(12)
    blr1 = clp.ex_boxblur(0,1,"weighted")
    blr2 = clp.ex_boxblur(1,0,"weighted")
    blr.ex_blur3D(0,0,2,"weighted",UV=3)

    # Remove areas of difference between temporal blurred motion search clip and
    # bob that are not due to bob-shimmer - removes general motion blur
    QTGMCp_KeepOnlyBobShimmerFixes(blr1,           4,true,true)
    TurnLeft()
    QTGMCp_KeepOnlyBobShimmerFixes(blr2.TurnLeft(),4,true,true)
    TurnRight()

    # Final edge blur
    removegrain(20)
    ex_unsharp(-0.25,Fc=width()/2.5) }
But this showed more wobbling than my previous example. Using your alternative to turn "vertical" into "square" in KeepOnlyBobShimmerFixes() removes the wobbling, but that's because now the Calm prefiltering isn't removing ghosting at all. So it's kind of a balance, maybe using my SMDegrain approach with a high enough thSAD could be the better alternative (also has SCD) even if some ghosting makes it through it should be safer.

EDIT: So for wobbling the best option is an unprotected temporal gauss as prefilter, later in my script I use MotionMask() to use a more protective denoiser to motion areas.
Code:
function pref_DeWobble(clip clp) {

    # temporal gaussian average
    clp.ex_blur3D(0,0,2,"weighted",UV=3)

    # Final edge blur
    removegrain(20)
    ex_unsharp(-0.3,Fc=width()/2.5) }
And here the script
Code:
    ffvideosource("noisy_original.mkv")
    propSet("_FieldBased",0)

    ConvertBits(16)
    ex_Luma_Rebuild(15.0, 0.004, 21, tv_out=true)
    ConvertBits(8,dither=1)

    Stabilize()
    crop(2,2,-6,-2)
    SceneStats("Range+Stats")

    pref  = ex_autolevels(     true ,true, true,Deflicker=true,tv_out=false)
    pref  = ex_autolevels(pref,false,true,false,Deflicker=true,tv_out=false)
    pref3 = pref_DeWobble(pref)

    bk=SMDegrain(tr=2,mode="TemporalSoften",blksize=16,thSAD=400,LFR=false,refinemotion=true,prefilter=pref3)
    ft=SMDegrain(tr=2,mode="MDegrain"      ,blksize=16,thSAD=300,LFR=false,refinemotion=true,prefilter=bk)
    ex_merge(bk, ft, MotionMask(pref3,scale=10,sharpness=5))

    ex_unsharp(0.3)
    # And some film grain here
__________________
i7-4790K@Stock::GTX 1070] AviSynth+ filters and mods on GitHub + Discussion thread

Last edited by Dogway; 6th March 2023 at 21:55.
Dogway is offline   Reply With Quote
Old 6th March 2023, 18:38   #2111  |  Link
anton_foy
Registered User
 
Join Date: Dec 2005
Location: Sweden
Posts: 721
Quote:
now the Calm prefiltering isn't removing ghosting at all
Usually I use
Code:
temporaldenoiser().repair(src, mode=13)
to remove motionblur, but I don't know if there are many downsides to that.
anton_foy is offline   Reply With Quote
Old 6th March 2023, 18:46   #2112  |  Link
Dogway
Registered User
 
Join Date: Nov 2009
Posts: 2,371
Thanks, yes that's a great idea, it's actually used in some stages of LSFplus and SMDegrain, anyway I tested and it brings back some wobbling so the unprotected version is ok with the above code, but only for wobbling, for high noise I would motion protect it in some way.
__________________
i7-4790K@Stock::GTX 1070] AviSynth+ filters and mods on GitHub + Discussion thread
Dogway is offline   Reply With Quote
Old 6th March 2023, 19:37   #2113  |  Link
anton_foy
Registered User
 
Join Date: Dec 2005
Location: Sweden
Posts: 721
Quote:
Originally Posted by Dogway View Post
Thanks, yes that's a great idea, it's actually used in some stages of LSFplus and SMDegrain, anyway I tested and it brings back some wobbling so the unprotected version is ok with the above code, but only for wobbling, for high noise I would motion protect it in some way.
Yes it seems some thresholding (or something) should be involved, I noticed it too.
anton_foy is offline   Reply With Quote
Old 6th March 2023, 20:14   #2114  |  Link
LeXXuz
21 years and counting...
 
LeXXuz's Avatar
 
Join Date: Oct 2002
Location: Germany
Posts: 716
Quote:
Originally Posted by Dogway View Post
Stab2 is the proxy name I gave to Fred's stabilization example:
Code:
# https://forum.doom9.org/showthread.php?p=1981048
function Stabilize(clip c, int "offset", bool "info") {

    in = Default(info, false)
    of = Default(offset, 40)
 
    c
    vectors = MSuper().MAnalyse(isb=false)
    mdata   = MDepan(vectors, rot=false, zoom=false, error= 65)

    DePanStabilize(data=mdata,dxmax=of, dymax=of, zoommax=0, rotmax=0, method=1, mirror=15, prev=1, next=1, info=in)
    }
The script works for me, even at 16-bit removing the ConvertBits(8,dither=1) call after ex_Luma_Rebuild(). Don't use StabPlus(), Stabilization Tools Pack is outdated, use Fred's example.
I agree with you, Fred's script works better. I tried that example on a film where the entire scene wobbles with my usual SMDegrain script. And I could hardly notice any wobble, which is great, but still have to tweak on denoising strength since the picture now looks like the noise has been made stand still, like a curtain over the picture. Kinda hard to describe. If I can reduce that some more the result is very satisfying.

But I will also try your latest script idea and see how that performs in comparison.

And everything now works in 16-bit as well. I've updated everything from your repo and no weird on screen message about bitdepth-missmatch anymore.

Speaking of QTGMC. The film is progressive but the transfer was bad and has field drops here and there from capturing causing field shifts.
So I let Ceppos tools run with your version of QTGMC+ at the very beginning of my script, like:
Code:
#
LoadPlugin("C:\Video Editing\MeGUI (x64)\tools\lsmash\LSMASHSource.dll")
LWLibavVideoSource("H:\WORK\test.mkv")
#
AssumeFPS(25)
CTelecine()
CPostProcessing()
propSet("_FieldBased",0)
#
(Denoising script here)
#
Could this cause problems regarding wobbling? Or is there a better approach taking care of phase shifts in PAL DVDs?
LeXXuz is offline   Reply With Quote
Old 6th March 2023, 21:17   #2115  |  Link
anton_foy
Registered User
 
Join Date: Dec 2005
Location: Sweden
Posts: 721
Quote:
like the noise has been made stand still, like a curtain over the picture
FFT3Dfilter can be good for it.
anton_foy is offline   Reply With Quote
Old 6th March 2023, 22:05   #2116  |  Link
Dogway
Registered User
 
Join Date: Nov 2009
Posts: 2,371
Since the source is progressive I'm not sure what you are doing there before, but as long the outcome is also progressive there shouldn't be any problem.

Using the pref_DeWobble() as in my above script example gives virtually no wobble, that prefilter is not motion protected but it passes through one SMDegrain and then another one as prefilters masking out any blending in the process. For the grain curtain adding some grain in the end helps mask out the effect, as well as add some hallucination and psychovisual sharpness. Personally I don't like FFT3DFilter because it's too slow, and the output can be worm-like.

Here the result: Link

And this is a before-after comparison, download for best quality: https://drive.google.com/file/d/1iI3...6WyOy-0iBwn-ib
__________________
i7-4790K@Stock::GTX 1070] AviSynth+ filters and mods on GitHub + Discussion thread

Last edited by Dogway; 31st October 2023 at 23:50.
Dogway is offline   Reply With Quote
Old 6th March 2023, 22:47   #2117  |  Link
LeXXuz
21 years and counting...
 
LeXXuz's Avatar
 
Join Date: Oct 2002
Location: Germany
Posts: 716
Quote:
Originally Posted by Dogway View Post
Since the source is progressive I'm not sure what you are doing there before, but as long the outcome is also progressive there shouldn't be any problem.
Maybe I explained it wrong. You see the source is supposed to be progressive but during poor digitisation sometimes a field of a frame is missing or the field order is shifted. Making it appear interlaced. Back in the first years of DVD production a lot of studios didn't care about this because it would not matter when playing these DVDs on old PAL TV-sets because of the way the picture was created by their electron-beam tubes. Since we are long past that aera, on modern flatscreen TVs this is a visual issue. Especially when the source is flagged progressive and the playback device doesn't do any field processing you can clearly see those field mismatches.

With Ceppos tools I can fix that and put the fields back in the right order. It uses QTGMC in the process but I have no idea how exactly and to what extend.

Since you talked about QTGMC I thought it could maybe abet the wobbling effect when processing the picture? If no, I'm fine. If it maybe does, I have to look for some other tools that check for the correct field order of a PAL frame and shuffles them back in the right sequence or duplicates a field if there is one missing.

Last edited by LeXXuz; 7th March 2023 at 11:03.
LeXXuz is offline   Reply With Quote
Old 6th March 2023, 23:02   #2118  |  Link
anton_foy
Registered User
 
Join Date: Dec 2005
Location: Sweden
Posts: 721
Quote:
Here the result: Link
But come on that looks amazing! Too good for me I enjoy the "imperfections" of celluloid though.

Edit: Yes fft3d is probably a bit slow but it actually helped me alot. The combination of fft3d(spatio-temporal) with mvtools is pretty smooth. Knlmeanscl is for me too slow (2013 old setup) and temporally jittery. I would love to love able to stabilize the jitter/shimmer/dancing of fft3d or any other good spatial filter to get a fine result. Just so you know @Dogway I read your scripts with a magnifying glass. Loads of great inspiration.

Last edited by anton_foy; 7th March 2023 at 08:00.
anton_foy is offline   Reply With Quote
Old 6th March 2023, 23:37   #2119  |  Link
LeXXuz
21 years and counting...
 
LeXXuz's Avatar
 
Join Date: Oct 2002
Location: Germany
Posts: 716
Can't really complain about speed. I used neo_fft3d quite a lot before mainly using SMDegrain. Or the latest GPU version which also worked fine but lacks a few parameters.
LeXXuz is offline   Reply With Quote
Old 7th March 2023, 07:24   #2120  |  Link
kedautinh12
Registered User
 
Join Date: Jan 2018
Posts: 2,169
Quote:
Originally Posted by anton_foy View Post
But common that looks amazing! Too good for me I enjoy the "imperfections" of celluloid though.

Edit: Yes fft3d is probably a bit slow but it actually helped me alot. The combination of fft3d(spatio-temporal) with mvtools is pretty smooth. Knlmeanscl is for me too slow (2013 old setup) and temporally jittery. I would love to love able to stabilize the jitter/shimmer/dancing of fft3d or any other good spatial filter to get a fine result. Just so you know @Dogway I read your scripts with a magnifying glass. Loads of great inspiration.
Here have replace CL of KNLMeansCL with Cuda ver but only in VS, you can waiting for someone port it to avs
https://github.com/AmusementClub/vs-nlm-cuda
kedautinh12 is offline   Reply With Quote
Reply

Tags
avisynth, dogway, filters, hbd, packs

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:31.


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