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 4th June 2022, 18:32   #881  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,288
Quote:
but do you think you could add an ID for feedback in Stab3, like the avs filename (RT_FilenameSplit(string filename,int "get"=4) I think*)
FN_NAME_ONLY = RT_FilenameSplit(FN,get=4) # Name node only, no path, no extension
__________________
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 5th June 2022, 00:19   #882  |  Link
Blankmedia
Registered User
 
Join Date: Oct 2011
Location: Dans le nord
Posts: 62
Quote:
Originally Posted by StainlessS View Post
FN_NAME_ONLY = RT_FilenameSplit(FN,get=4) # Name node only, no path, no extension
Thanks StainlessS but I think the feedback plugin only takes integer for argument.

Code:
Feedback
========

Feedback is a pair of filters that allow the output of a filter chain to be
passed back as an input, further up the chain, to be used in outputting the next
frame of the chain.

For example, it can be used to fill in the empty areas of a stablised clip by
compositing in the previous output frame (which itself will have been composited
using Feedback).

Usage
=====

FeedbackInput(
  (clip),
  (int) id
)

FeedbackOutput(
  (clip),
  (int) id
)

FeedbackInput will return frame 0 of its input clip as frame 0 of its output,
but after that it returns frame n-1 of the associated FeedbackOutput clip.

FeedbackOutput sets a clip as a source for a FeedbackInput clip.

The id parameter is optional, but must be given unique values whenever there is
more than one FeedbackInput/FeedbackOutput set in a script environment.
I tried, but maybe incorrectly.

Code:
function Stab31 (clip clp, int "ts", int "range", int "dxmax", int "dymax", bool "UVfix", bool "FixFalPos", float "zoom", int "mirror", float "PAR", clip "Prefilter", int "Luma_Exp", int "FillBorder", clip "FalPosclip", bool "use_ExInpaint", bool "use_InpaintDelogo", bool "use_Feedback", string "the_path") {

	ts     = default(ts, 7)        #frames to temporal average for better motion estimation (max. 7)
	range  = default(range, 1)     #frames before/after to estimate motion
	dxmax  = default(dxmax, Round(clp.width()/180.0)) #maximum deviation in pixels
	dymax  = default(dymax, dxmax) #x, and y should be the same
	zoom   = default(zoom, 1)      #maximum zoom factor (1 disabled)
	u_feed = default(use_Feedback, false)
	mirror = default(mirror, u_feed ? 15 : 0)    #Edge filling. 0 off, 15 everything on
	PAR    = default(PAR, 1.0)     #PAR of your source
	UVfix  = default(UVfix, false)  # Fixes the bug of change of HUE in Depan, not need in depan 1.13.1 and up
	bfix   = default(FillBorder, u_feed ? 2 : 1) # 1=Fixes borders of 3 or less pixels wide.
	u_ExIn = default(use_ExInpaint, false)
	u_InDe = default(use_InpaintDelogo, u_feed)
	b3fix  = bfix > 0
	FixFalPos  = default(FixFalPos, true) # Fixes borders of 3 or more pixels wide. Use along crop(2,2,-2,-2)...
										  # ...after stab2() to get rid of border issues entirely
	Lumae  = default(Luma_Exp, 1) #Luma Rebuild

	Pref   = Defined(Prefilter) ? Prefilter : clp
	temp   = Pref.TemporalSoften(ts,255,255,25,2) # SC thr to 25 otherwise pans will stutter
	rep    = temp.Repair(Pref.TemporalSoften(1,255,255,25,2))
	inter  = Interleave(rep,Pref)
	
	FN_NAME_ONLY = RT_FilenameSplit(the_path,get=4)

	# temporal stable auto-contrast (better subpixel detection)
	Luma_Expa = Lumae==2 ? AutoAdjust(inter,temporal_radius=10,auto_balance=false,auto_gain=true,use_interp=true,\
			   avg_safety=0.25,dark_limit=10,bright_limit=10,gamma_limit=1.0,dark_exclude=0.05,bright_exclude=0.05,\
			   chroma_process=0,scd_threshold=16,input_tv=false,output_tv=false,high_bitdepth=false,debug_view=false) : \
				Lumae==1 ? inter.ColorYUV(levels="TV->PC") : inter

	mdata = DePanEstimate(Luma_Expa,range=range,pixaspect=PAR,trust=0,dxmax=dxmax,dymax=dymax,zoommax=zoom)

	DePan(Defined(Prefilter)?Interleave(rep,clp):inter,data=mdata,offset=-1,mirror=b3fix ? 0 : mirror,pixaspect=PAR,matchfields=false,subpixel=2)
	SelectEvery(2,0)

	stabclip=last
	FalPosclip = !defined(FalPosclip) && FixFalPos && mirror==15 && b3fix ? clp : FalPosclip

	# from depansafe() function
	b3fix && defined(FalPosclip) ? FalPosclip : FixFalPos ? eval("""
	thick = b3fix ? 3.0 : 2.0  # removing >2px wide borders
	cropx = dxmax*2
	ratiox = "YPlaneMax("+string(ceil(99-thick/cropx*100))+")"

	crop(0,0,0,cropx).conditionalfilter(last,clp,ratiox,">","0")
	crop(0,height-cropx,0,0).conditionalfilter(last,clp,ratiox,">","0")
	crop(0,0,cropx,0).conditionalfilter(last,clp,ratiox,">","0")
	crop(width-cropx,0,0,0).conditionalfilter(last,clp,ratiox,">","0")""") : last

	subsampl = b3fix ? AvsPlusVersionNumber > 2294 ? !(clp.is444() || clp.isy()) : VersionNumber() < 2.60 ? clp.isyv12() : !(clp.isyv24() || clp.isy8()) : nop()

	bfixc = bfix > 0 ? stabclip.FillBorders_stabi(pad=subsampl && mirror!=15 ? 1 : 0,subsample=subsampl,FixFalPos=defined(FalPosclip) || FixFalPos ? last : Undefined, mirror=mirror==15,PAR=PAR, maskonly=bfix > 1) : last
	stabbclp = bfix > 1 && u_feed ? BlankClip(bfixc,color_yuv=$000000) : nop()
	stabclpa1 = bfix > 1 && u_feed ? stabclip.SCSelect(stabbclp,bfixc,bfixc).ExtractY().Invert() : nop()
	stabclpa2 = bfix > 1 && u_feed ? stabclip.SCSelect(stabbclp,stabbclp,bfixc).ExtractY().Invert() : nop()
	# [strike]stabclip = bfix > 1 && u_feed ? Layer(stabclip.AddAlphaPlane(stabclpa1).FeedbackInput(clp.AddAlphaPlane(stabclpa1), id=FN_NAME_ONLY).FeedbackOutput(id=FN_NAME_ONLY)) : stabclip[/strike]
        stabclip = bfix > 1 && u_feed ? Layer(stabclip.AddAlphaPlane(stabclpa1).FeedbackInput(id=FN_NAME_ONLY), clp.AddAlphaPlane(stabclpa1)).FeedbackOutput(id=FN_NAME_ONLY) : stabclip
	stabclip = bfix > 1 && u_feed ? stabclip.RemoveAlphaPlane() : stabclip
	preclip = mt_merge(stabclip,clp,bfixc,luma=true)
	preclip = bfix > 1 && u_feed ? mt_merge(stabclip,preclip,stabclpa2,luma=true).repair(preclip) : preclip
	bfix > 1 ? stabclip.FillBorders_stabi(pad=subsampl && mirror!=15 ? 1 : 0,subsample=subsampl,FixFalPos=defined(FalPosclip) || FixFalPos ? last : Undefined, mirror=mirror==15,PAR=PAR, FillBordersc=u_ExIn ? preclip.ExInpaint(bfixc.mt_lut(u=-255,v=-255)) : u_InDe ? preclip.InpaintDelogo(mask=bfixc, Loc="0,0,0,0",dPP=0,dPPm=1,diPP=1,diPPm=0,oPP=1,oPPm=0,Inflate=0) : preclip.InpaintLogo(bfixc)) : bfixc
	bfix > 1 && u_feed ? mt_merge(stabclip,last,stabclpa2.sh_Padding(2,2,2,2).mt_expand().crop(2,2,-2,-2),luma=true).repair(preclip) : last

	UVfix ? eval("""
	lumaf=last
	clpDith=Dither_convert_8_to_16()

	ScriptClip ("
	blue=round((AverageChromaU(clp) - AverageChromaU()) * 256.0)
	red=round((AverageChromaV(clp) - AverageChromaV()) * 256.0)

	SmoothTweak16(clpDith,saturation=1.0,hue1=min(384,blue),hue2=min(384,red),HQ=true)
	DitherPost(stacked=true,prot=false,mode=6,y=1,slice=false)
	", args="clp,clpDith" )
	Mergeluma(lumaf)
	""") : last

}
In this script :

Code:
MPEG2Source (chemin, idct=5)
# RequestLinear(clim=100)
RoboCrop(LeftAdd=2, TopAdd=0, RightAdd=0, BotAdd=0)
Scomb(Decrawing=False, ntsccombmask=False)
# Convertbits(16)
A=STGMC( Preset="very slow",sourcematch=3, Sharpness=0.0, lossless=2 ).selecteven()
B=STGMC( Preset="very slow",sourcematch=3, Sharpness=0.0, lossless=2 ).selectodd()
C=Tfm(field=1,Mode=5,PP=2,cthresh=2,mthresh=2,clip2=A,micmatching=0,chroma=true,display=false, d2v=chemin, slow=2)
D=Tfm(field=0,Mode=5,PP=2,cthresh=2,mthresh=2,clip2=B,micmatching=0,chroma=true,display=false, d2v=chemin, slow=2)
Interleave(C,D)

Stab31(use_feedback=True, the_path=chemin)
I get this error in FFMPEG:
Code:
[avisynth @ 00000153a3375a00] Script error: Invalid arguments to function 'FeedbackInput'.
(D:/A encoder/avs_plugin_372/Stab31.avsi, line 68)
(simpsons_s02e01_p1_scomb3.avs, line 45)
simpsons_s02e01_p1_scomb3.avs: Unknown error occurred

Last edited by Blankmedia; 5th June 2022 at 00:42. Reason: i messed up
Blankmedia is offline   Reply With Quote
Old 5th June 2022, 00:26   #883  |  Link
Blankmedia
Registered User
 
Join Date: Oct 2011
Location: Dans le nord
Posts: 62
I messed up that line in stab31* :

Code:
	stabclip = bfix > 1 && u_feed ? Layer(stabclip.AddAlphaPlane(stabclpa1).FeedbackInput(id=FN_NAME_ONLY), clp.AddAlphaPlane(stabclpa1)).FeedbackOutput(id=FN_NAME_ONLY) : stabclip
Now it's the "good" error code:

Code:
avisynth @ 000001fc10ed5a00] Script error: the named argument "id" to FeedbackInput had the wrong type
(D:/A encoder/avs_plugin_372/Stab31.avsi, line 69)
(simpsons_s02e01_p1_scomb3.avs, line 45)
simpsons_s02e01_p1_scomb3.avs: Unknown error occurred
It works if I put id=123

Last edited by Blankmedia; 5th June 2022 at 00:35.
Blankmedia is offline   Reply With Quote
Old 5th June 2022, 01:28   #884  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,288
I only added that stuff so that Real.Finder would not have to look up what it did. (was not meant as any kind of solution)
__________________
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 5th June 2022, 01:50   #885  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,288
OK, here extracts PartNo from multi-part Filename, only tested with given script.

Code:
Function GetMultipartFileNamePartNo(String FN) {
    FN = RT_FilenameSplit(FN,get=4) # Name node only, no path, no extension eg, "FFMS_MultiPart_Source_PART_1"
    RFN = RevStr(FN)
    S="" # Init
    C = RFN.MidStr(1,1)
    While("0" <= C <= "9") {
        S = C + S
        RFN = RFN.MidStr(2)
        C = RFN.MidStr(1,1)
    }
    Return Eval("0" + S)
}


FN = "FFMS_MultiPart_Source_PART_123.avs"

PartNo = GetMultipartFileNamePartNo(FN)
Assert(PartNo > 0, "Bad PartNo")

BlankClip
Subtitle("Got PartNo = " + String(PartNo))
Produces clip Subtitled with "123".

EDIT: Extracts the bit in RED as int.

EDIT: Added "0" +
in the Eval, ie Return Eval(S) to Return Eval("0" + S).
__________________
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 2022 at 02:17.
StainlessS is offline   Reply With Quote
Old 6th June 2022, 21:40   #886  |  Link
Blankmedia
Registered User
 
Join Date: Oct 2011
Location: Dans le nord
Posts: 62
This is a good idea
Blankmedia is offline   Reply With Quote
Old 5th July 2022, 21:06   #887  |  Link
dREV
Registered User
 
dREV's Avatar
 
Join Date: Jan 2019
Location: Antarctica
Posts: 74
I wanted to ask if this script below from https://forum.doom9.org/showthread.p...22#post1906222 doesn't need an update to it after a year and many months of updates later? Thanks for sharing that script as I been using it since even now.

Code:
useDebilinearM=false #Depend on the source
nativeWidth=1504 #Depend on the source
nativeHeight=846 #Depend on the source
outputWidth=1280 #Depend on what you need
outputHeight=720 #Depend on what you need
noDesample=(nativeWidth > outputWidth && nativeHeight > outputHeight) || (nativeHeight >= Height && nativeWidth >= Width)
luma=IsAvsPlus() ? ExtractY() : ConvertToY8()
chroma=Interleave(IsAvsPlus() ? ExtractU() : UToY8(), IsAvsPlus() ? ExtractV() : VToY8())
desampleluma=noDesample ? luma : useDebilinearM ? luma.DebilinearM(nativeWidth,nativeHeight, DeResizeMT=true) : luma.ResizeX(nativeWidth,
nativeHeight,kernel="bicubic",a1=0,a2=1,dither_mode=0,desampling=true) #you must set the correct kernel and the settings here (Depend on the source)
outputluma=!(noDesample || (nativeWidth != outputWidth || nativeHeight != outputHeight)) ? desampleluma : desampleluma.nnedi3_resize16(outputWidth, 
outputHeight) #you can add another settings depend on what you need
outputchroma=chroma.nnedi3_resize16(outputWidth, outputHeight,kernel_u="blackman"src_top=0.0,src_left=0.50) #you can add another settings depend on what you need
YtoUV(outputchroma.SelectEven(),outputchroma.SelectOdd(),outputluma)
I tried adding LSB to it and seems to work with no issues
Code:
useDebilinearM=false #Depend on the source
nativeWidth=1504 #Depend on the source
nativeHeight=846 #Depend on the source
outputWidth=1280 #Depend on what you need
outputHeight=720 #Depend on what you need
noDesample=(nativeWidth > outputWidth && nativeHeight > outputHeight) || (nativeHeight >= Height && nativeWidth >= Width)
luma=IsAvsPlus() ? ExtractY() : ConvertToY8()
chroma=Interleave(IsAvsPlus() ? ExtractU() : UToY8(), IsAvsPlus() ? ExtractV() : VToY8())
desampleluma=noDesample ? luma : useDebilinearM ? luma.DebilinearM(nativeWidth,nativeHeight, DeResizeMT=true,thr=01, lsb_inout=true) : luma.ResizeX(nativeWidth,
nativeHeight,kernel="bicubic",a1=0,a2=1,dither_mode=0,lsb_in=true,lsb_out=true,desampling=true) #you must set the correct kernel and the settings here (Depend on the source)
outputluma=!(noDesample || (nativeWidth != outputWidth || nativeHeight != outputHeight)) ? desampleluma : desampleluma.nnedi3_resize16(outputWidth, 
outputHeight, lsb_in=true,lsb=true) #you can add another settings depend on what you need
outputchroma=chroma.nnedi3_resize16(outputWidth, outputHeight,0.50,kernel_u="blackman",src_top=0.0,src_left=0.50,lsb_in=true,lsb=true) #you can add another settings depend on what you need
YtoUV(outputchroma.SelectEven(),outputchroma.SelectOdd(),outputluma)
In addition, I wanted to ask if you think it doesn't need the "prefetch" and the "MT" parameter to take advantage of JPSDR's dll's like "ResampleMT" to use "Spline36MT" instead of the regular "Spline36" or when using "DebilinearM" using "BicubicResizeMT" instead of "BicubicResize" and so on.

One more thing, does "nnedi3_resize16" use the "MT's" or take advantage of "ResampleMT"? I think you did this for "DebilinearM" to use "MT" in the script. Maybe I am wrong but seems to be "DeRMT". I just don't see it in "nnedi3_resize16" as I see "kernel_d = Default(kernel_d, "Spline36" " so I think it uses the normal "Spline36". You think it's fine the way it is? or could use an update or would that take too long?

Last edited by dREV; 5th July 2022 at 21:16. Reason: minor edit
dREV is offline   Reply With Quote
Old 23rd September 2022, 00:26   #888  |  Link
PoeBear
Registered User
 
Join Date: Jan 2017
Posts: 25
Quote:
Originally Posted by real.finder View Post
Did this get merged into another package, or is there a better solution now?
PoeBear is offline   Reply With Quote
Old 23rd September 2022, 00:52   #889  |  Link
Reel.Deel
Registered User
 
Join Date: Mar 2012
Location: Texas
Posts: 1,454
Quote:
Originally Posted by PoeBear View Post
Did this get merged into another package, or is there a better solution now?
It is now a plugin: https://github.com/Asd-g/AviSynth-AGM
Reel.Deel is offline   Reply With Quote
Old 23rd September 2022, 04:44   #890  |  Link
PoeBear
Registered User
 
Join Date: Jan 2017
Posts: 25
Quote:
Originally Posted by Reel.Deel View Post
Cheers! Now can someone smarter than I help me figure out how I would use AGM with GrainFactory3, a la "AdaptiveGrain(grain=GrainFactory3(..."?
PoeBear is offline   Reply With Quote
Old 23rd September 2022, 05:42   #891  |  Link
kedautinh12
Registered User
 
Join Date: Jan 2018
Posts: 1,279
Quote:
Originally Posted by PoeBear View Post
Cheers! Now can someone smarter than I help me figure out how I would use AGM with GrainFactory3, a la "AdaptiveGrain(grain=GrainFactory3(..."?
You need make a script wraper to use them
kedautinh12 is offline   Reply With Quote
Old 23rd September 2022, 08:15   #892  |  Link
PoeBear
Registered User
 
Join Date: Jan 2017
Posts: 25
Quote:
Originally Posted by kedautinh12 View Post
You need make a script wraper to use them
That seems... like a lot of extra work lol. The old one looked good enough to me with just a single line. Luckily I found a copy of it on gitlab, if anyone wants to try/compare/have an alternate solution/hold onto for posterity/etc
PoeBear is offline   Reply With Quote
Old 23rd September 2022, 14:19   #893  |  Link
StvG
Registered User
 
Join Date: Jul 2018
Posts: 301
Quote:
Originally Posted by PoeBear View Post
Cheers! Now can someone smarter than I help me figure out how I would use AGM with GrainFactory3, a la "AdaptiveGrain(grain=GrainFactory3(..."?
Like this:

Code:
MPEG2Source("D:\Edit\DVD\ntscDVD.d2v")
TFM()
TDecimate()
neo_f3kdb(y=64, cb=64, cr=64, grainy=0, grainc=0)
z_Spline36Resize(1440,1080)
AdaptiveGrain(grain=GrainFactory3(g1str=1, g2str=2, g3str=3))
z_Spline36Resize(640,480)
Code:
MPEG2Source("D:\Edit\DVD\ntscDVD.d2v")
TFM()
TDecimate()
neo_f3kdb(y=64, cb=64, cr=64, grainy=0, grainc=0)
z_Spline36Resize(1440,1080)
mt_merge(GrainFactory3(g1str=1, g2str=2, g3str=3), agm())
z_Spline36Resize(640,480)
StvG is offline   Reply With Quote
Reply

Tags
avisynth, avs script, avs+, banding, generator, hbd, mod

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


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