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
Register FAQ Calendar Today's Posts Search

Reply
 
Thread Tools Search this Thread Display Modes
Old 9th December 2016, 15:39   #41  |  Link
manolito
Registered User
 
manolito's Avatar
 
Join Date: Sep 2003
Location: Berlin, Germany
Posts: 3,079
Here is the little Speed Changing tool I was talking about. Download here:
https://files.videohelp.com/u/172211/ChangeSpeed.zip

I made it a while ago for a musician friend who needed this to slow down music clips while preserving the pitch so he could learn the songs more easily.

It is rough and ugly, but it does what it was intended for. Right now I integrated johnmeyer's FPS conversion script plus I updated all the tools.

Have fun...

Cheers
manolito

Last edited by manolito; 12th August 2018 at 10:51. Reason: fixed the documentation
manolito is offline   Reply With Quote
Old 9th December 2016, 17:59   #42  |  Link
johnmeyer
Registered User
 
Join Date: Feb 2002
Location: California
Posts: 2,695
Quote:
Originally Posted by manolito View Post
Anyway, johnmeyer's script seems to do a lot more seeking than the other scripts. Now I use DSS2Mod with a preroll value of 15, and the judder is completely gone...

... And the inherent problems for motion protected FPS conversions are the same for HD and SD.
I'd be interested to know what you meant by "seeking." I'd love to make it run faster.

As for your second statement, it it generally correct, but it also is misleading for two reasons. The first I already mention: there is a bug in some version of MVTools2 which only shows up at certain resolutions. The second reason is that the block sizes you choose are going to depend on the resolution. To illustrate, if you had a video that was only 16x16 pixels, a block size of 16 would not do much for you. Put another way, the block size needs to be chosen with some thought to the size of the "structures" you are attempting to track. As you increase the number of pixels used to represent the same scene, the block size (and overlap) probably have to be increased.

Last edited by johnmeyer; 9th December 2016 at 18:24. Reason: added "not" to "not do much for you"
johnmeyer is offline   Reply With Quote
Old 9th December 2016, 18:05   #43  |  Link
Groucho2004
 
Join Date: Mar 2006
Location: Barcelona
Posts: 5,034
Quote:
Originally Posted by johnmeyer View Post
I'd be interested to know what you meant by "seeking." I'd love to make it run faster.
It means that MVTools requests frames in a non-linear fashion in this script. The source filter has to provide past and future frames relative to the current frame. DirectShowSource is notorious for choking on non-linear frame requests and should be avoided if possible.
__________________
Groucho's Avisynth Stuff
Groucho2004 is offline   Reply With Quote
Old 9th December 2016, 18:28   #44  |  Link
johnmeyer
Registered User
 
Join Date: Feb 2002
Location: California
Posts: 2,695
Thanks for the clarification, Groucho2004. Is there any way to control this? I guess I've heard of this before because there is a "Requestlinear" statement that is available with some AVISynth filters.
johnmeyer is offline   Reply With Quote
Old 9th December 2016, 20:25   #45  |  Link
manolito
Registered User
 
manolito's Avatar
 
Join Date: Sep 2003
Location: Berlin, Germany
Posts: 3,079
Quote:
Originally Posted by johnmeyer View Post
The second reason is that the block sizes you choose are going to depend on the resolution. To illustrate, if you had a video that was only 16x16 pixels, a block size of 16 would not do much for you. Put another way, the block size needs to be chosen with some thought to the size of the "structures" you are attempting to track. As you increase the number of pixels used to represent the same scene, the block size (and overlap) probably have to be increased.
Yes, I see your point. But the values for block size and overlap you used in your script do work very well for all the SD clips I tested so far. Looks like you hit the sweet spot...

But even if there is a linear relation between the source resolution and the optimum block size and overlap, shouldn't it be possible to automatically pick the optimal values? AviSynth knows the source frame size.

My main use for motion protected fps conversion is not slo-mo, it is standard conversion between NTSC and PAL. The usual methods all have their flaws. PAL folks often have not much tolerance for repeated or dropped fields. Right now I am running a torture NTSC -> PAL conversion where the source is truly interlaced (Prince - The Hits). The usual method introduces some judder (bob deinterlace, changeFPS, resize and reinterlace). What I am trying now is same rate deinterlace, resize and convert framerate to progressive 25 fps using your script.

I already tried this a while ago using MotionProtectedFPS, the result was not bad at all, but still too many artifacts. I am very curious how this conversion using your script will come out.


Cheers
manolito
manolito is offline   Reply With Quote
Old 9th December 2016, 21:42   #46  |  Link
Groucho2004
 
Join Date: Mar 2006
Location: Barcelona
Posts: 5,034
Quote:
Originally Posted by johnmeyer View Post
Thanks for the clarification, Groucho2004. Is there any way to control this? I guess I've heard of this before because there is a "Requestlinear" statement that is available with some AVISynth filters.
If you're using a decent source filter with frame accurate seeking you should usually not need helper functions like RequestLinear. I never needed it, even with multi-threaded QTGMC().
__________________
Groucho's Avisynth Stuff
Groucho2004 is offline   Reply With Quote
Old 10th December 2016, 14:43   #47  |  Link
manolito
Registered User
 
manolito's Avatar
 
Join Date: Sep 2003
Location: Berlin, Germany
Posts: 3,079
Quote:
Originally Posted by manolito View Post
Right now I am running a torture NTSC -> PAL conversion where the source is truly interlaced (Prince - The Hits Collection - US release). The usual method introduces some judder (bob deinterlace, changeFPS, resize and reinterlace). What I am trying now is same rate deinterlace, resize and convert framerate to progressive 25 fps using your script.

I already tried this a while ago using MotionProtectedFPS, the result was not bad at all, but still too many artifacts. I am very curious how this conversion using your script will come out.
This conversion took a long time on my ancient desktop machine at 1.5 fps, but it was worth it. The source is very demanding, and my older MotionProtectedFPS conversion displayed a lot of artifacts. Not too annoying, but still. Especially the end credits with vertically moving letters looked bad.

And now this conversion using johnmeyer's script does not have any of these artifacts. Near perfect, even the end credits. I think that for motion protected fps conversions this script is all you can ask for. It will certainly replace the MotionProtectedFPS routine for me.


Thanks and cheers
manolito
manolito is offline   Reply With Quote
Old 10th December 2016, 17:56   #48  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Ok, here mod of previous test function + a bit more.
Modded to be (I think) by default, same as JohnMeyer's offering, with exception of SearchParam in MRecalculate which is dropped down from 3 in MAnalyse (default 2),
down to 1. Flow default changed to True. Recalc to 1.
Also added Flow_ml and Block_Mode args.
Maybe someone like to test for modified SearchParam.

Also, Added John's Interleave original frames jiggery pokery [implemented in MulRate()] and works also with frames multiplier greater than 2.

Code:
Function ChangeFrameRate(clip c,Bool "Blend",Bool "Flow",Int "Num",Int "Den",
    \ Bool "Prefilter",Bool "Chroma",Bool "Chroma1",Bool "Chroma2",
    \ Int "BlkSize",Int "Recalc",
    \ Int "OverLap",Int "OverLap1",Int "OverLap2",
    \ Int "thSAD1",Int "thSAD2",
    \ Float "Flow_ml",
    \ Int   "Block_Mode"
    \ ) {
    # Req MvTools2 v2.7.1.22+ for FINAL Overlap>0
    Blend   = Default(Blend,False)                                     # Avoid blends at scene change (copy previous frame)
    Flow    = Default(Flow,True)                                       # If True, Use MFlowFps instead of MBlockFps
    n=Default(num,0) d=default(den,0) valid=(n>0 && d>0) n=(!valid)?c.FramerateNumerator*2:n d=(!valid)?c.FramerateDenominator:d # Default=doublerate
    Prefilter=Default(Prefilter,True)
    Chroma  = Default(Chroma ,True)
    Chroma1 = Default(Chroma1,True)
    Chroma2 = Default(Chroma2,True)
    BlkSize = Default(BlkSize,16)
    Recalc  = Default(Recalc,1)                                        # 0 -> 2.
    Overlap = Default(Overlap ,4)
    Overlap1= Default(Overlap1,2)
    Overlap2= Default(Overlap2,0)
    thSAD1  = Default(thSAD1,100)                                      # MRecalculate default is 200
    thSAD2  = Default(thSAD2,100)
    Flow_ml = Float(Default(Flow_ml,200.0))
    Block_Mode=Default(Block_Mode,0)                                   # 0 (Fastest, default) -> 5(debug)
    Assert(0 <= Recalc <=2,"ChangeFrameRate: 0 <= ReCalc  <= 2")
    super   = c.MSuper(pel=2, hpad=BlkSize, vpad=BlkSize,rfilter=4,Levels=(0<Recalc)?1:0) # MRecalculate needs only 1 Level, MAnalyse needs all Levels
    MAnal   = (Prefilter) ? c.RemoveGrain(22).MSuper(hpad=BlkSize, vpad=BlkSize) : Super
    bv = MAnal.MAnalyse(isb=true,       chroma=Chroma,      blksize=BlkSize,   OverLap=OverLap , search=3, searchparam=3, badrange=(-24), plevel=0)
    fv = MAnal.MAnalyse(isb=false,      chroma=Chroma,      blksize=BlkSize,   OverLap=OverLap , search=3, searchparam=3, badrange=(-24), plevel=0)
    bv = (0<ReCalc)?MRecalculate(super, chroma=Chroma1, bv, blksize=BlkSize/2, Overlap=OverLap1, search=3, searchparam=1, thSAD=thSAD1):bv
    fv = (0<ReCalc)?MRecalculate(super, chroma=Chroma1, fv, blksize=BlkSize/2, Overlap=OverLap1, search=3, searchparam=1, thSAD=thSAD1):fv
    bv = (1<ReCalc)?MRecalculate(super, chroma=Chroma2, bv, blksize=BlkSize/4, Overlap=OverLap2, search=3, searchparam=0, thSAD=thSAD2):bv
    fv = (1<ReCalc)?MRecalculate(super, chroma=Chroma2, fv, blksize=BlkSize/4, Overlap=OverLap2, search=3, searchparam=0, thSAD=thSAD2):fv
    Return (!Flow)
        \ ? c.MBlockFps(super, bv, fv, num=n, den=d, Blend=Blend, mode=Block_Mode)
        \ : c.MFlowFps(super,  bv, fv, num=n, den=d, Blend=Blend, ml  =Flow_ml)
}

Function MulRate(clip c,Bool "Blend",Bool "Flow",int "mul",Bool "ILeave") {
    Function MulRate_EvS(String s,int n,int mul) {
        s=(s!="")?","+s:s
        s="SelectEvery("+String(mul)+","+String(n)+")"+s
         # RT_DebugF("s='%s'",s,name="MulRate: ")
        return (n>1)?MulRate_EvS(s,n-1,mul):s
    }
    c
    mul=default(mul,2)
    Ileave=Default(Ileave,True)
    ChangeFrameRate(Blend,Flow,c.FramerateNumerator*mul,c.FramerateDenominator)
    (ILeave&&mul>=2) ? Eval("Interleave(c,"+MulRate_EvS("",mul-1,mul)+")") : NOP
    Return Last
}

Function DoubleRate(clip c,Bool "Blend",Bool "Flow",Bool "ILeave") { return c.MulRate(Blend,Flow,2,ILeave) }

Function SlowMo(clip c,Bool "Blend",Bool "Flow", int "mul",Bool "ILeave") {
    c
    MulRate(Blend,Flow,mul,ILeave)
    Return Last.assumefps(c.FrameRateNumerator,c.FrameRateDenominator)
}
client
Code:
AVISource("D:\SlowMoTester.mkv.AVI")

SlowMo(mul=2,iLeave=True)       # Double framecount, Interleave (EDIT: replace with) original frames every even frame.
EDIT: Blend=False, unlike John's default true, I refuse to use blend mode (change yourself if you prefer not being able to detect scene changes).

EDIT: On-site edit broke script, fixed.

Creates some weird warping if you set mul to 10.
__________________
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 ???

Last edited by StainlessS; 11th December 2016 at 18:59.
StainlessS is offline   Reply With Quote
Old 11th December 2016, 10:06   #49  |  Link
manolito
Registered User
 
manolito's Avatar
 
Join Date: Sep 2003
Location: Berlin, Germany
Posts: 3,079
Thanks StainlessS for the new script. Very nifty scripting. especially the MulRate function for the ILeave thing, you are a real AviSynth wiz...

I did a few tests already, the source was the most critical section of my Anime clip.

Results:
johnmeyer's script still gets my top rating.

Yours is very close, probably no visual difference with natural film. But still the artifacts on this vertical grill are a little more prominent. The Blend and ILeave variables made no difference at all to my eyes.

And MotionProtectedFPS is just not competetive any longer...

Download the resulting clips here:
http://www47.zippyshare.com/v/lJmnElOu/file.html


Cheers
manolito
manolito is offline   Reply With Quote
Old 11th December 2016, 17:00   #50  |  Link
johnmeyer
Registered User
 
Join Date: Feb 2002
Location: California
Posts: 2,695
Just a note to anyone who does their own comparisons: you have to tune the script to get good results. I am flattered that "my script" produces good results, but that is mostly due to the fact that I spent ten minutes trying dozens of different settings (block size, overlap, threshholds, etc.) until I got a good result. I then posted the script with those settings. I suspect that you might get equal -- or perhaps better -- results with some of the other scripts if you did similar tuning yourself.

More to the point: don't think that my script is some sort of slow-motion panacea. It too will produce worse results than will some other scripts when fed a different test case.

Last edited by johnmeyer; 11th December 2016 at 22:14. Reason: typo
johnmeyer is offline   Reply With Quote
Old 11th December 2016, 19:09   #51  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Quote:
Very nifty scripting
I'de swap it all to have a smile like your Mani
__________________
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 12th December 2016, 18:17   #52  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
OK, nuther tester.
Added all args to higher level funcs, Added SearchParam args and changed defaults slightly, seems to me that old SearchParam = 0 (recalc=2) might be a NOP (not sure how implemented).
Should SearchParam be based on current MAnaylse/Recalc OverLap ??? (search==3=Exhastive search, where SearchParam=Radius and square side=2*Radius+1).

here mod:
Code:
Function ChangeFrameRate(clip c,Bool "Blend",Bool "Flow",Int "Num",Int "Den",
    \ Bool "Prefilter",Bool "Chroma",Bool "Chroma1",Bool "Chroma2",
    \ Int "BlkSize",Int "Recalc",
    \ Int "OverLap",Int "OverLap1",Int "OverLap2",
    \ Int "SearchParam",Int "SearchParam1",Int "SearchParam2",
    \ Int "thSAD1",Int "thSAD2",
    \ Float "Flow_ml",
    \ Int   "Block_Mode"
    \ ) {
    # Req MvTools2 v2.7.1.22+ for FINAL Overlap>0
    Blend   = Default(Blend,False)                                     # Avoid blends at scene change (copy previous frame)
    Flow    = Default(Flow,True)                                       # If True, Use MFlowFps instead of MBlockFps
    n=Default(num,0) d=default(den,0) valid=(n>0 && d>0) n=(!valid)?c.FramerateNumerator*2:n d=(!valid)?c.FramerateDenominator:d # Default=doublerate
    Prefilter=Default(Prefilter,True)
    Chroma       = Default(Chroma ,True)
    Chroma1      = Default(Chroma1,True)
    Chroma2      = Default(Chroma2,True)
    BlkSize      = Default(BlkSize,16)
    Recalc       = Default(Recalc,1)                                        # 0 -> 2.
    Assert(0 <= Recalc <=2,"ChangeFrameRate: 0 <= ReCalc  <= 2")
    Overlap      = Default(Overlap ,4)
    Overlap1     = Default(Overlap1,2)
    Overlap2     = Default(Overlap2,0)
    SearchParam  = Default(SearchParam ,Recalc==2?3:2)                      # MAnalyse default (as John's default) = 2 (presume MRecalculate same, not doc'ed)
    SearchParam1 = Default(SearchParam1,Recalc==2?2:1)                      #   Search==3=Exhaustive search, where SearchParam=Radius, square side = 2*Radius+1
    SearchParam2 = Default(SearchParam2,          1  )                      #   From above, SearchParam of 0, seems like might be useless NOP (not sure).
    thSAD1       = Default(thSAD1,100)                                      # MRecalculate default is 200
    thSAD2       = Default(thSAD2,100)                                      # ditto
    Flow_ml      = Float(Default(Flow_ml,200.0))                            # MFlowFPS default is 100.0
    Block_Mode   = Default(Block_Mode,0)                                    # 0 (Fastest, default) -> 5(debug)
    super   = c.MSuper(pel=2, hpad=BlkSize, vpad=BlkSize,rfilter=4,Levels=(0<Recalc)?1:0) # MRecalculate needs only 1 Level, MAnalyse needs all Levels
    MAnal   = (Prefilter) ? c.RemoveGrain(22).MSuper(hpad=BlkSize, vpad=BlkSize) : Super
    bv = MAnal.MAnalyse(isb=true,       chroma=Chroma,      blksize=BlkSize,   OverLap=OverLap , search=3, searchparam=SearchParam,  badrange=(-24), plevel=0)
    fv = MAnal.MAnalyse(isb=false,      chroma=Chroma,      blksize=BlkSize,   OverLap=OverLap , search=3, searchparam=SearchParam,  badrange=(-24), plevel=0)
    bv = (0<ReCalc)?MRecalculate(super, chroma=Chroma1, bv, blksize=BlkSize/2, Overlap=OverLap1, search=3, searchparam=SearchParam1, thSAD=thSAD1):bv
    fv = (0<ReCalc)?MRecalculate(super, chroma=Chroma1, fv, blksize=BlkSize/2, Overlap=OverLap1, search=3, searchparam=SearchParam1, thSAD=thSAD1):fv
    bv = (1<ReCalc)?MRecalculate(super, chroma=Chroma2, bv, blksize=BlkSize/4, Overlap=OverLap2, search=3, searchparam=SearchParam2, thSAD=thSAD2):bv
    fv = (1<ReCalc)?MRecalculate(super, chroma=Chroma2, fv, blksize=BlkSize/4, Overlap=OverLap2, search=3, searchparam=SearchParam2, thSAD=thSAD2):fv
    Return (!Flow)
        \ ? c.MBlockFps(super, bv, fv, num=n, den=d, Blend=Blend, mode=Block_Mode)
        \ : c.MFlowFps(super,  bv, fv, num=n, den=d, Blend=Blend, ml  =Flow_ml)
}

Function MulRate(clip c,Bool "Blend",Bool "Flow",int "mul",Bool "ILeave",
    \ Bool "Prefilter",Bool "Chroma",Bool "Chroma1",Bool "Chroma2",Int "BlkSize",Int "Recalc", Int "OverLap",Int "OverLap1",Int "OverLap2",
    \ Int "SearchParam",Int "SearchParam1",Int "SearchParam2",Int "thSAD1",Int "thSAD2",Float "Flow_ml",Int   "Block_Mode") {
    Function MulRate_EvS(String s,int n,int mul) {
        s="SelectEvery("+String(mul)+","+String(n)+")"+((s!="")?","+s:s)
        # RT_DebugF("s='%s'",s,name="MulRate: ")
        return (n>1)?MulRate_EvS(s,n-1,mul):s
    }
    c
    mul=default(mul,2)
    Ileave=Default(Ileave,True)
    ChangeFrameRate(Blend,Flow,c.FramerateNumerator*mul,c.FramerateDenominator,Prefilter,Chroma,Chroma1,Chroma2,BlkSize,Recalc,
        \ OverLap,OverLap1,OverLap2,SearchParam,SearchParam1,SearchParam2,thSAD1,thSAD2,Flow_ml,Block_Mode)
    (ILeave&&mul>=2) ? Eval("Interleave(c,"+MulRate_EvS("",mul-1,mul)+")") : NOP
    Return Last
}

Function DoubleRate(clip c,Bool "Blend",Bool "Flow",Bool "ILeave",
    \ Bool "Prefilter",Bool "Chroma",Bool "Chroma1",Bool "Chroma2",Int "BlkSize",Int "Recalc", Int "OverLap",Int "OverLap1",Int "OverLap2",
    \ Int "SearchParam",Int "SearchParam1",Int "SearchParam2",Int "thSAD1",Int "thSAD2",Float "Flow_ml",Int   "Block_Mode") {
    return c.MulRate(Blend,Flow,2,ILeave,Prefilter,Chroma,Chroma1,Chroma2,BlkSize,Recalc,
        \ OverLap,OverLap1,OverLap2,SearchParam,SearchParam1,SearchParam2,thSAD1,thSAD2,Flow_ml,Block_Mode)
}

Function SlowMo(clip c,Bool "Blend",Bool "Flow", int "mul",Bool "ILeave",
    \ Bool "Prefilter",Bool "Chroma",Bool "Chroma1",Bool "Chroma2",Int "BlkSize",Int "Recalc", Int "OverLap",Int "OverLap1",Int "OverLap2",
    \ Int "SearchParam",Int "SearchParam1",Int "SearchParam2",Int "thSAD1",Int "thSAD2",Float "Flow_ml",Int   "Block_Mode") {
    c
    MulRate(Blend,Flow,mul,ILeave,Prefilter,Chroma,Chroma1,Chroma2,BlkSize,Recalc,
        \ OverLap,OverLap1,OverLap2,SearchParam,SearchParam1,SearchParam2,thSAD1,thSAD2,Flow_ml,Block_Mode)
    Return Last.assumefps(c.FrameRateNumerator,c.FrameRateDenominator)
}
Client
Code:
AVISource("D:\SlowMoTester.mkv.AVI")

#DoubleRate(ILeave=True,Recalc=1)

SlowMo(mul=2,iLeave=True,ReCalc=1)          # Double framecount, Interleave (replace with) original frames every even frame, 1 instance of MRecalculate.
EDIT: Mani, Blend only matters at scene change (1st frame of scene NOT blended, copied from End Of Scene frame, when Blend=False).
__________________
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 ???

Last edited by StainlessS; 5th June 2017 at 14:38.
StainlessS is offline   Reply With Quote
Old 13th December 2016, 08:43   #53  |  Link
manolito
Registered User
 
manolito's Avatar
 
Join Date: Sep 2003
Location: Berlin, Germany
Posts: 3,079
Thanks for the update, but IMO it's still not completely there yet...

Test result:
http://www16.zippyshare.com/v/b0eFhc3u/file.html

I only judge the result by the warping artifacts on those vertical edges of the grill to the right of the clip. John Meyer's result has fewer artifacts.

I kept all the defaults for JM and for your script. Encoding by X264 at CRF 20.

I also simplified your script to be just an FPS converter because this is all I need:

Code:
Function StainlessS_fps(clip c, float "fps") {
    # Req MvTools2 v2.7.1.22+ for FINAL Overlap>0
    fps          = default(fps, 25.000)
    fps_num      = int(fps * 1000)
    fps_den      = 1000
    Blend        = False                              # Avoid blends at scene change (copy previous frame)
    Flow         = True                               # If True, Use MFlowFps instead of MBlockFps
    Prefilter    = True
    Chroma       = True
    Chroma1      = True
    Chroma2      = True
    BlkSize      = 16
    Recalc       = 1                                  # 0 -> 2.
    Assert(0 <= Recalc <=2,"ChangeFrameRate: 0 <= ReCalc  <= 2")
    Overlap      = 4
    Overlap1     = 2
    Overlap2     = 0
    SearchParam  = Recalc==2?3:2                      # MAnalyse default (as John's default) = 2 (presume MRecalculate same, not doc'ed)
    SearchParam1 = Recalc==2?2:1                      # Search==3=Exhaustive search, where SearchParam=Radius, square side = 2*Radius+1
    SearchParam2 = 1                                  # From above, SearchParam of 0, seems like might be useless NOP (not sure).
    thSAD1       = 100                                # MRecalculate default is 200
    thSAD2       = 100                                # ditto
    Flow_ml      = Float(200.0)                       # MFlowFPS default is 100.0
    Block_Mode   = 0                                  # 0 (Fastest, default) -> 5(debug)
    super = c.MSuper(pel=2, hpad=BlkSize, vpad=BlkSize,rfilter=4,Levels=(0<Recalc)?1:0) # MRecalculate needs only 1 Level, MAnalyse needs all Levels
    MAnal = (Prefilter) ? c.RemoveGrain(22).MSuper(hpad=BlkSize, vpad=BlkSize) : Super
    bv = MAnal.MAnalyse(isb=true, chroma=Chroma, blksize=BlkSize, OverLap=OverLap, search=3, searchparam=SearchParam, badrange=(-24), plevel=0)
    fv = MAnal.MAnalyse(isb=false, chroma=Chroma, blksize=BlkSize, OverLap=OverLap, search=3, searchparam=SearchParam, badrange=(-24), plevel=0)
    bv = (0<ReCalc)?MRecalculate(super, chroma=Chroma1, bv, blksize=BlkSize/2, Overlap=OverLap1, search=3, searchparam=SearchParam1, thSAD=thSAD1):bv
    fv = (0<ReCalc)?MRecalculate(super, chroma=Chroma1, fv, blksize=BlkSize/2, Overlap=OverLap1, search=3, searchparam=SearchParam1, thSAD=thSAD1):fv
    bv = (1<ReCalc)?MRecalculate(super, chroma=Chroma2, bv, blksize=BlkSize/4, Overlap=OverLap2, search=3, searchparam=SearchParam2, thSAD=thSAD2):bv
    fv = (1<ReCalc)?MRecalculate(super, chroma=Chroma2, fv, blksize=BlkSize/4, Overlap=OverLap2, search=3, searchparam=SearchParam2, thSAD=thSAD2):fv
    Return (!Flow)
        \ ? c.MBlockFps(super, bv, fv, num=fps_num, den=fps_den, Blend=Blend, mode=Block_Mode)
        \ : c.MFlowFps(super, bv, fv, num=fps_num, den=fps_den, Blend=Blend, ml=Flow_ml)
}
The slowdown to half speed was done by "AssumeFPS(framerate / 2)" before calling the script.


Even if johnmeyer is adamant in requesting to find optimal parameters for every source, these params so far have given me the best results for every source I have tried. I experimented a lot using different values for block size and overlap, but the result was either the same or it was worse.

The remaining artifacts in my test clip using JM's script are probably not avoidable. At least I tried, but I could not get a better result.

And the StainlessS script is just a little bit worse. The new test script did not make any difference to the previous one BTW.
What does this comment mean?
Quote:
Req MvTools2 v2.7.1.22+ for FINAL Overlap>0
Is the FINAL Overlap == Overlap2 ? The reason I ask is that I have to use the latest Fizick version of MVTools2, PinterF versions do not run on my machine.


Cheers
manolito

Last edited by manolito; 13th December 2016 at 08:46.
manolito is offline   Reply With Quote
Old 13th December 2016, 18:37   #54  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Quote:
Originally Posted by manolito View Post
What does this comment mean?

Is the FINAL Overlap == Overlap2 ? The reason I ask is that I have to use the latest Fizick version of MVTools2, PinterF versions do not run on my machine.
In non pinterf version, Overlap cannot be non zero in vectors used in MBlockFPS, ie from final MRecalculate, or from MAnalyse if MRecalculate not used at all.
So, script will probably fail with your version MVTools if Flow=False.
[EDIT: Except if set Recalc=2, where Overlap2 defaults 0, OR if you set relevant OverlapN=0].

http://forum.doom9.org/showthread.ph...81#post1785781

Also if you wanted easy interface but with all defaults could have created stub eg (untested)
Code:
Function Manolito_fps(clip c, float "fps") { fps=default(fps,25.0) num=int(fps*1000) Return ChangeFrameRate(c,num=num,den=1000) }
EDIT: For stub using eg Recalc=0 and Overlap=0, then just create new stub using non defaults, calling
ChangeFrameRate(..., Recalc=0,OverLap=0)
__________________
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 ???

Last edited by StainlessS; 13th December 2016 at 18:53.
StainlessS is offline   Reply With Quote
Old 25th July 2018, 00:18   #55  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Mod of the fabled jm_fps, modded by Manolito and again a little by this humble soul.

JohnFPS.avs
Code:
Function JohnFPS(clip c,Val "num", int "den",int "Sharp",int "rFilter",Int "BlkSize",int "Search",int "dct",Float  "ml",Int "Mask",Bool "Blend") {
/*
    https://forum.doom9.org/showthread.php?p=1847109#post1847109
    Motion Protected FPS converter script by JohnMeyer from Doom9
    Slightly modified interface by Manolito, and a smidgen more by ssS.
    Requires MVTools V2 and RemoveGrain
    Also needs fftw3.dll in the System32 or SysWOW64 folder for Dct values other than 0
    Specify FrameRate using num (Numerator) and den (Denominator)
        num only,  eg num=25.0,           FrameRate = 25.0  FPS
        num & den, eg num=24000 den=1001, FrameRate = 23.976 FPS (Both should be type Int).
        neither specified                 FrameRate = Double input framerate.
*/
    def = num.Defined ? (den.Defined ?1:0) : (!den.Defined) ? 2 : -1    # 0=NumOnlyDef, 1=BothDef, 2=NoneDef, -1=DenOnlyError
    Assert(0<=def,"JohnFPS: Cannot specify framerate using den only")
    #              Rate=num            :       Rate=num/den  :    Rate=DoubleRate
    n=(def==0) ? Round(num * 1000): (def==1) ?   Int(num)    : 2*c.FrameRateNumerator
    d=(def==0) ?             1000 : (def==1) ?   den         :   c.FrameRateDenominator
    Sharp  = Default(Sharp,1)      # MSuper default = 2
    rFilter= Default(rFilter,4)    # MSuper default = 2
    BlkSize= Default(BlkSize,16)   # Manalyse default 8, Maybe 32 for HD
    Search = Default(Search,3)     # Manalyse default 4
    dct    = Default(dct,0)        # Manalyse default 0, 1=Slow
    ml     = Default(ml,200.0)     # MFlowFps default 100.0
    Mask   = Default(Mask,2)       # MFlowFps default 2
    Blend  = Default(Blend,False)  # MFlowFps default True
    prefilt  = c.RemoveGrain(22)
    super    = c.MSuper(hpad=16,vpad=16,levels=1,sharp=Sharp,rfilter=rFilter)   # One level is enough for MRecalculate
    superfilt= prefilt.MSuper(hpad=16,vpad=16,sharp=Sharp,rfilter=rFilter)      # All levels for MAnalyse
    bv = superfilt.MAnalyse(isb=true ,blksize=BlkSize,overlap=4,search=Search,dct=dct)
    fv = superfilt.MAnalyse(isb=false,blksize=BlkSize,overlap=4,search=Search,dct=dct)
    bv = super.MRecalculate(bv,blksize=8,overlap=2,thSAD=100)
    fv = super.MRecalculate(fv,blksize=8,overlap=2,thSAD=100)
    return c.MFlowFps( super,bv,fv,num=n,den=d,blend=Blend,ml=ml,mask=Mask)
}
EDIT: Update, add Blend arg.

One day they will sing the ballad of JohnFPS (unfortunately, the hero always dies in a horrible & painful way, well you cant have everything I suppose).
__________________
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 ???

Last edited by StainlessS; 26th July 2018 at 09:23.
StainlessS is offline   Reply With Quote
Old 25th July 2018, 00:44   #56  |  Link
Sparktank
47.952fps@71.928Hz
 
Sparktank's Avatar
 
Join Date: Mar 2011
Posts: 940
Can't wait to check out these mods.

Always looking for something new and fun
__________________
Win10 (x64) build 19041
NVIDIA GeForce GTX 1060 3GB (GP106) 3071MB/GDDR5 | (r435_95-4)
NTSC | DVD: R1 | BD: A
AMD Ryzen 5 2600 @3.4GHz (6c/12th, I'm on AVX2 now!)
Sparktank is offline   Reply With Quote
Old 26th July 2018, 01:00   #57  |  Link
manolito
Registered User
 
manolito's Avatar
 
Join Date: Sep 2003
Location: Berlin, Germany
Posts: 3,079
@ StainlessS

Nice mod you posted, I played a little bit with it, these are my 2 cents:

1. You exposed a lot more MVTools parameters in the function. Nice for users who like to play, I certainly don't need this.

2. The way you enabled either a float FPS value as a param or using int params for num and den is very nifty. This will make both camps happy. I really tried to break it, but I couldn't. Hats off...

3. Unsure about the "BadRange" param. I did a few conversions with the default "Search=3", either using "BadRange=-24" or omitting the BadRange parameter. The conversion results were bit identical in all cases, so I assume that MVTools is smart enough to use "-24" by default if "Search=3" is specified.


I also found that there are differences in the output depending on the method which gets used for specifying the target frame rate. Probably just rounding errrors, but still...

Using either
JohnFPS(60000/1001)
or
JohnFPS(60000, 1001)

results in very different outputs. I cannot say if one looked better than the other, but the method using num and den is definitely considerably faster.


Cheers
manolito


OT:
Your advice to not forget to bring my brolly for my recent motorcycle trip to Scotland was unjustified. Only great weather, no rain or drizzle at all. This was my third Scotland trip, and I never got wet up there...

Last edited by manolito; 26th July 2018 at 01:10.
manolito is offline   Reply With Quote
Old 26th July 2018, 08:53   #58  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
BadRange,
Was little addition just before posting,based purely on docs suggestion, no harm to either remove or leave as is.

Quote:
JohnFPS(60000/1001)
I hope you did something in test like
Code:
JohnFPS(60000/Float(1001)) 
JohnFPS(Float(60000)/1001) 
JohnFPS(60000.0/1001) 
JohnFPS(60000/1001.0)
Quote:
but the method using num and den is definitely considerably faster.
Did not really expect that, but good to know (I tend to use num, den myself).

OT, you lucky lucky lad
__________________
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 26th July 2018, 09:24   #59  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Post #55 Update. Remove BadRange, added MFlowFPS Blend arg (defaulted false, EDIT:MFlowFPS default is true).
__________________
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 ???

Last edited by StainlessS; 26th July 2018 at 09:39.
StainlessS is offline   Reply With Quote
Old 26th July 2018, 19:11   #60  |  Link
manolito
Registered User
 
manolito's Avatar
 
Join Date: Sep 2003
Location: Berlin, Germany
Posts: 3,079
Quote:
Originally Posted by StainlessS View Post
I hope you did something in test like
Code:
JohnFPS(60000/Float(1001)) 
JohnFPS(Float(60000)/1001) 
JohnFPS(60000.0/1001) 
JohnFPS(60000/1001.0)
No, I didn't. And this is exactly what I want to avoid no matter what. I do not want to have to specify a variable type when calling the function. This is just too prone to errors.

What if I change "Val" to "Float" in the function declaration for "num"? I think this should not break anything, but then you are the AviSynth wiz, not me...


Cheers
manolito
manolito is offline   Reply With Quote
Reply


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 23:46.


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