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 16th April 2023, 03:07   #2401  |  Link
kedautinh12
Registered User
 
Join Date: Jan 2018
Posts: 2,169
Hi Dogway, cause filmgrain+ different paramaters from grainfactory3mod. Can you trans this script to filmgrain+ for same result? thanks
Code:
gr     =  0.3
size   =  float(width())/2400
GrainFactory3mod(g1str=6*gr,g2str=8*gr,g3str=5*gr,g1size=1.2*size,g2size=1.5*size,g3size=1.4*size,g1cstr=1.5*gr,g2cstr=1.5*gr,g3cstr=1.5*gr,temp_avg=0)
kedautinh12 is offline   Reply With Quote
Old 16th April 2023, 14:31   #2402  |  Link
Dogway
Registered User
 
Join Date: Nov 2009
Posts: 2,372
As I see from the current presets 5218 is the most similar:
Code:
FilmGrainPlus(preset="Vision2 5218 500T")
It will auto-scale from input resolution.
__________________
i7-4790K@Stock::GTX 1070] AviSynth+ filters and mods on GitHub + Discussion thread
Dogway is offline   Reply With Quote
Old 16th April 2023, 14:40   #2403  |  Link
kedautinh12
Registered User
 
Join Date: Jan 2018
Posts: 2,169
Thanks
kedautinh12 is offline   Reply With Quote
Old 16th April 2023, 20:20   #2404  |  Link
Dogway
Registered User
 
Join Date: Nov 2009
Posts: 2,372
Just added SmoothMotion() to ResizersPack.
It's a concept from MPV. To display 24fps content smoothly on 60Hz displays and in real-time.
It works better than ChangeFPS() and ConvertFPS().
__________________
i7-4790K@Stock::GTX 1070] AviSynth+ filters and mods on GitHub + Discussion thread
Dogway is offline   Reply With Quote
Old 17th April 2023, 02:38   #2405  |  Link
Guest
Guest
 
Posts: n/a
Quote:
Originally Posted by Dogway View Post
Just added SmoothMotion() to ResizersPack.
It's a concept from MPV. To display 24fps content smoothly on 60Hz displays and in real-time.
It works better than ChangeFPS() and ConvertFPS().
This sounds interesting

So in a script that has an SMDegrain pre filter call, etc, where would this need to be, before or after ??
  Reply With Quote
Old 17th April 2023, 11:17   #2406  |  Link
Dogway
Registered User
 
Join Date: Nov 2009
Posts: 2,372
After, at the end of the filter stack.
__________________
i7-4790K@Stock::GTX 1070] AviSynth+ filters and mods on GitHub + Discussion thread
Dogway is offline   Reply With Quote
Old 17th April 2023, 11:31   #2407  |  Link
LeXXuz
21 years and counting...
 
LeXXuz's Avatar
 
Join Date: Oct 2002
Location: Germany
Posts: 716
Any news with Scene Stats?
I tried to mask out fades but it seems there are also error messages on camera pans which makes it not really usable right now.
LeXXuz is offline   Reply With Quote
Old 17th April 2023, 11:37   #2408  |  Link
Guest
Guest
 
Posts: n/a
Quote:
Originally Posted by Dogway View Post
After, at the end of the filter stack.
Thanks for the info, and thanks for the new filter (whatever it should be called)..

I tried it today, and it worked well on a 4K HDR10 clip

But I have to ask, even tho it states that it basically increases the original FPS x 2.5, is it possible to specify a custom fps ??

https://github.com/Dogway/Avisynth-S...Pack.avsi#L594
  Reply With Quote
Old 17th April 2023, 16:38   #2409  |  Link
Dogway
Registered User
 
Join Date: Nov 2009
Posts: 2,372
@LeXXuz: Provide me a sample so I can have a look.

@FTLOY: The algo is geared towards a 2.5 framerate upsample. What's your source and target FPS you want to do?
__________________
i7-4790K@Stock::GTX 1070] AviSynth+ filters and mods on GitHub + Discussion thread
Dogway is offline   Reply With Quote
Old 17th April 2023, 17:55   #2410  |  Link
Boulder
Pig on the wing
 
Boulder's Avatar
 
Join Date: Mar 2002
Location: Finland
Posts: 5,812
I tested FilmGrain+ and it looks really nice, thanks a lot I often need such a filter to create some fake detail on low-quality or overcleaned sources.
Just noticed that the preblur parameter doesn't seem to work, the strength looks the same with every value other than 0 which effectively does disable it. I was testing on a 8-bit YV12 source.
__________________
And if the band you're in starts playing different tunes
I'll see you on the dark side of the Moon...
Boulder is offline   Reply With Quote
Old 17th April 2023, 18:23   #2411  |  Link
Dogway
Registered User
 
Join Date: Nov 2009
Posts: 2,372
It's a multiplier so if internal blur is already 0 it won't do anything, rarely is 0 so you might see an effect for example multiplying by 2, 3 or 4.
Maybe post your call in case I missed something.
__________________
i7-4790K@Stock::GTX 1070] AviSynth+ filters and mods on GitHub + Discussion thread
Dogway is offline   Reply With Quote
Old 18th April 2023, 05:01   #2412  |  Link
Boulder
Pig on the wing
 
Boulder's Avatar
 
Join Date: Mar 2002
Location: Finland
Posts: 5,812
Quote:
Originally Posted by Dogway View Post
It's a multiplier so if internal blur is already 0 it won't do anything, rarely is 0 so you might see an effect for example multiplying by 2, 3 or 4.
Maybe post your call in case I missed something.
For example this one, I cannot see a visible difference between the preblur values. The image is blurred quite heavily compared to the original one so I was thinking of damping it down.

DGSource("test.dgi")
interleave(FilmGrainPlus(preset="Vision 5274 200T", preblur=0.01, deterministic=true), FilmGrainPlus(preset="Vision 5274 200T", preblur=1, deterministic=true))
__________________
And if the band you're in starts playing different tunes
I'll see you on the dark side of the Moon...
Boulder is offline   Reply With Quote
Old 18th April 2023, 06:39   #2413  |  Link
Guest
Guest
 
Posts: n/a
Quote:
Originally Posted by Dogway View Post
@LeXXuz: Provide me a sample so I can have a look.

@FTLOY: The algo is geared towards a 2.5 framerate upsample. What's your source and target FPS you want to do?
I was actually just wondering if it was an option, the 2.5 x is pretty damn close...

As I haven't had too much luck with RIFEwrap , mainly GPU memory issues.

I have a sample of a scene from GoT 4K HDR10 that I used SmoothMotion on, and I'd like to get your opinion of which scene is "smoother"..

GoT trees

At 20 seconds in, there are trees passing across the screen...do I detect a slight "shudder" with the "smooth" clip ??, the other clip is original FPS. It might be my eye's...
  Reply With Quote
Old 18th April 2023, 14:58   #2414  |  Link
Dogway
Registered User
 
Join Date: Nov 2009
Posts: 2,372
@FTLOY: They serve different purposes though. RIFEwrap will create new frames so the content will have the soap opera effect if target is 60fps. Meanwhile SmoothMotion is only to smoothly display 24fps on a 60Hz display, but honoring the original film framerate cadence. Nowadays most Smart TVs adapt the refresh rate to accomodate to 24fps.

As for the camera pan on the trees I can see the judder but that's what the algo is. For those areas you would RIFEwrap or some kind of interpolation. Maybe ConvertFPS() blending all frames in that area.

@Boulder: I don't get much blur, you can get the gaussian blur sigma with the following expression which is what's parsed to vsTCanny directly. As you can see for 1080p you get like only 0.09 sigma (preblur=1), and for 2160p 0.49 which is still quite low. On that I think I'm going to bypass gaussian blur for sigmas of 0.35 and lower since they only slow down the filter.

Code:
w=1920
str=0.4
shrp=1
pbl=1
subtitle(string(max(0,((sqrt(((1-clamp(shrp*(-0.347*w*0.001+1.667),0,1))*3)+1)/2.)*sqrt(2))*(pow(str*(0.409*w*0.001+0.214),0.318)-0.61)*(pow(w/1920.-0.46,0.4)+0.2)*pbl)))

By the way, I'm going to update ResizersPack and TransformsPack since I commited a few typos yesterday.
__________________
i7-4790K@Stock::GTX 1070] AviSynth+ filters and mods on GitHub + Discussion thread

Last edited by Dogway; 18th April 2023 at 15:07.
Dogway is offline   Reply With Quote
Old 18th April 2023, 15:26   #2415  |  Link
Boulder
Pig on the wing
 
Boulder's Avatar
 
Join Date: Mar 2002
Location: Finland
Posts: 5,812
Quote:
Originally Posted by Dogway View Post
@Boulder: I don't get much blur, you can get the gaussian blur sigma with the following expression which is what's parsed to vsTCanny directly. As you can see for 1080p you get like only 0.09 sigma (preblur=1), and for 2160p 0.49 which is still quite low. On that I think I'm going to bypass gaussian blur for sigmas of 0.35 and lower since they only slow down the filter.

Code:
w=1920
str=0.4
shrp=1
pbl=1
subtitle(string(max(0,((sqrt(((1-clamp(shrp*(-0.347*w*0.001+1.667),0,1))*3)+1)/2.)*sqrt(2))*(pow(str*(0.409*w*0.001+0.214),0.318)-0.61)*(pow(w/1920.-0.46,0.4)+0.2)*pbl)))

By the way, I'm going to update ResizersPack and TransformsPack since I commited a few typos yesterday.
The source is 1024x576 (originally 1080p, then inverted the upscale and cleaned the video), here are sample screenshots where the blur is rather visible in the clothes and in the earring.




Your code shows 0.014060 if I set w=1024, but maybe any vsTCanny is just blurring noticably. If I set str to 0.2, like I've also tested, the value is 0 but still preblur 0 vs 1 affects the output the same way.
__________________
And if the band you're in starts playing different tunes
I'll see you on the dark side of the Moon...
Boulder is offline   Reply With Quote
Old 18th April 2023, 15:54   #2416  |  Link
Dogway
Registered User
 
Join Date: Nov 2009
Posts: 2,372
What I see is vertical blur only. Is vsTCanny updated? This is my first and probably only suspect. Just tested resizing a clip to 1024 width and no issues either.

-----------------------

By the way I wanted to update the rationale for per-shot grain restoration posted here, with some fixes and updates.
The main change here aside using FilmGrainPlus now is that the regrain filter is outside ScriptClip runtime environment, this is not only faster but will yield more stable and probably better results.
The main takeaway here is that you can't run SceneStats after heavy filtering, otherwise the look-ahead and lookbacks will take too much time, so we render the stats to an external file.
First for the scene stats, later for the grain diff stats.

Code:
# First Pass (fast)
setmemorymax(2048*4)
DGSource("C:\source.dgi",cl=0,ct=0,cr=0,cb=0)

SceneStats(mode="Range",path="C:\Range.log")

Prefetch(1)
Code:
# Second Pass (slowish)
setmemorymax(2048*4)
DGSource("C:\source.dgi",cl=0,ct=0,cr=0,cb=0)

ReadStats("C:\Range.log")
ExtractY()
dirt = last
# If this is too slow use a faster spatio-temporal denoiser
SMDegrain(1, 400, prefilter=1, ContraSharp=false, RefineMotion=false, LFR=400)

ex_makediff(dirt,dif=false) # dirt mask
SceneStats(mode="Stats", path="C:\Stats.log")  # per-shot dirt mask average

Prefetch(1)
Code:
# Third Pass
setmemorymax(2048*4)
DGSource("C:\source.dgi",cl=0,ct=0,cr=0,cb=0)

ConvertBits(16)
SMDegrain(3, 400, RefineMotion=true) # your actual denoiser or whatever filtering here

ReadStats("C:\Range.log")
ReadStats("C:\Stats.log")

bright = FilmGrainPlus(size=0.8,str=0.2,mode="log")
mid    = FilmGrainPlus(size=0.9,str=0.4,mode="log")
dark   = FilmGrainPlus(size=1.1,str=0.6,mode="log")

# per-shot modulated grain
# Normally motion leads to a greater degrain mask (up to 4 times the values) so you might...
# also want to compute that in First Pass to rule out false positives
ScriptClip(function [bright,mid,dark] () {

    avg  = propGetAsArray("_SceneStats")[6] # IQM. values are stored as 8-bit

    avg > 0.6 ? dark : \
    avg > 0.4 ?  mid : bright
    
    } )

ConvertBits(8, dither=1)

Prefetch(6)
__________________
i7-4790K@Stock::GTX 1070] AviSynth+ filters and mods on GitHub + Discussion thread

Last edited by Dogway; 18th April 2023 at 18:03.
Dogway is offline   Reply With Quote
Old 18th April 2023, 17:44   #2417  |  Link
Boulder
Pig on the wing
 
Boulder's Avatar
 
Join Date: Mar 2002
Location: Finland
Posts: 5,812
Quote:
Originally Posted by Dogway View Post
What I see is vertical blur only. Is vsTCanny updated? This is my first and probably only suspect. Just tested resizing a clip to 1024 width and no issues either.
That was it - I didn't have the latest version Thanks again!
__________________
And if the band you're in starts playing different tunes
I'll see you on the dark side of the Moon...
Boulder is offline   Reply With Quote
Old 22nd April 2023, 08:22   #2418  |  Link
LeXXuz
21 years and counting...
 
LeXXuz's Avatar
 
Join Date: Oct 2002
Location: Germany
Posts: 716
Out of all those many presets and settings for Filmgrain+,
what would be a good starting point for a quite subtle grain in SD, HD and 4k, just enough to help poor displays as additional dithering to fight banding?

I encode with x265 @ CRF16 and below with a very slow custom preset, so I'm not concerned it it would be hurt too much by compression.

Last edited by LeXXuz; 22nd April 2023 at 10:38.
LeXXuz is offline   Reply With Quote
Old 22nd April 2023, 12:51   #2419  |  Link
kedautinh12
Registered User
 
Join Date: Jan 2018
Posts: 2,169
Quote:
Originally Posted by LeXXuz View Post
Out of all those many presets and settings for Filmgrain+,
what would be a good starting point for a quite subtle grain in SD, HD and 4k, just enough to help poor displays as additional dithering to fight banding?

I encode with x265 @ CRF16 and below with a very slow custom preset, so I'm not concerned it it would be hurt too much by compression.
Need more example about only enough to help poor displays as additional dithering to fight banding
kedautinh12 is offline   Reply With Quote
Old 22nd April 2023, 18:35   #2420  |  Link
Dogway
Registered User
 
Join Date: Nov 2009
Posts: 2,372
I'm lacking a few presets, specially on the 50 and 200 range which would be more subtle but you can check Vision3 5219, if it's too slow (because of grain small size) try 5218 or play with 'size' and also 'str' if you want it more subtle.

To avoid banding you need to run FGP in HBD as well.

By the way, just refactored FastLineDarkenMOD(), now it's 13% faster in 8-bit and +39% in HBD.
__________________
i7-4790K@Stock::GTX 1070] AviSynth+ filters and mods on GitHub + Discussion thread

Last edited by Dogway; 25th April 2023 at 22:21.
Dogway 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 21:52.


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