gispos
19th July 2020, 20:59
I rewrote a found function that does not work under Avs + (every frame is written in the log file) for whatever reason.
Now I get an error with WriteFileIf. With Neo I don't get an error, but I have to declare all variables as global because Neo and Grunt are incompatible.
'Invalid argument to' WriteFileIf '
What am I doing wrong?
the original by 06_taro
Function SCDetect(clip c, string "scFile", int "thSCD1", int "thSCD2", float "mDiff", int "pel", int "search", int "searchparam", bool "preblur", bool "info"){
scFile = Default(scFile, "scFile.log")
thSCD1 = Default(thSCD1, 360)
thSCD2 = Default(thSCD2, 120)
mDiff = Default(mDiff, 2.5)
pel = Default(pel, 1)
search = Default(search, 4)
searchparam = Default(searchparam, 2)
preblur = Default(preblur, true)
info = Default(info, false)
last = preblur ? c.RemoveGrain(20, 0) : c
Assert( IsYV12 , "SCDetect needs YV12 input!" )
super = MSuper(pel=pel, chroma=false)
vector = super.MAnalyse(pelsearch=pel, search=search, searchparam=searchparam, chroma=false)
global scMask = MSCDetection(vector, thSCD1=thSCD1, thSCD2=thSCD2).Crop(0,0,16,16)
global SC_mD = mDiff
global mean = Histogram(mode="Color").Crop(width+64, 64, 128, 128)
SCTrue = c.Subtitle("Scene change: true" )
SCFalse = c.Subtitle("Scene change: false")
info ? ConditionalFilter( last, SCTrue, SCFalse, "boolSC", "==", "true" )
\ : nop
FrameEvaluate( """global boolSC =
\ (
\ ( scMask.YPlaneMax == 255 ) &&
\ (
\ (mean.YDifferenceFromPrevious > SC_mD*3) ||
\ (
\ (mean.YDifferenceFromPrevious > SC_mD) &&
\ (mean.YDifferenceFromPrevious > (mean.YDifferenceToNext+mean.loop(0, 0, -1).YDifferenceToNext+mean.loop(0, 0, 1).YDifferenceToNext)/1.2)
\ )
\ )
\ )""" )
( scFile != "nul" ) ? WriteFileStart( scFile, """ "# Scene change frame list" """ ).WriteFileIf( scFile, "boolSC==true", "current_frame" ) : nop
return last
}
my changes
Function SCDetect(clip c, string "scFile", int "thSCD1", int "thSCD2", float "mDiff", int "pel", int "search", int "searchparam", bool "preblur", bool "info"){
scFile = Default(scFile, "scFile.log")
thSCD1 = Default(thSCD1, 360)
thSCD2 = Default(thSCD2, 120)
mDiff = Default(mDiff, 2.5)
pel = Default(pel, 1)
search = Default(search, 4)
searchparam = Default(searchparam, 2)
preblur = Default(preblur, true)
info = Default(info, false)
last = preblur ? c.RemoveGrain(20, 0) : c
Assert( IsYV12 , "SCDetect needs YV12 input!" )
super = MSuper(pel=pel, chroma=false)
vector = super.MAnalyse(pelsearch=pel, search=search, searchparam=searchparam, chroma=false)
scMask = MSCDetection(vector, thSCD1=thSCD1, thSCD2=thSCD2).Crop(0,0,16,16)
SC_mD = mDiff
mean = Histogram(mode="Color").Crop(width+64, 64, 128, 128)
SCTrue = c.Subtitle("Scene change: true" )
SCFalse = c.Subtitle("Scene change: false")
info ? ConditionalFilter( last, SCTrue, SCFalse, "boolSC", "==", "true" ) : nop
sss = """
global boolSC =
\ (
\ (scMask.YPlaneMax == 255 ) &&
\ (
\ (mean.YDifferenceFromPrevious > SC_mD*3) ||
\ (
\ (mean.YDifferenceFromPrevious > SC_mD) &&
\ (mean.YDifferenceFromPrevious > (mean.YDifferenceToNext+mean.loop(0, 0, -1).YDifferenceToNext+mean.loop(0, 0, 1).YDifferenceToNext)/1.2)
\ )
\ )
\ )
(scFile != "nul") ? WriteFileIf( scFile, "boolSC==True", "current_frame" ) : nop
return last
"""
return ScriptClip(sss, Args="scFile, scMask, SC_mD, mean, info")
}
Now I get an error with WriteFileIf. With Neo I don't get an error, but I have to declare all variables as global because Neo and Grunt are incompatible.
'Invalid argument to' WriteFileIf '
What am I doing wrong?
the original by 06_taro
Function SCDetect(clip c, string "scFile", int "thSCD1", int "thSCD2", float "mDiff", int "pel", int "search", int "searchparam", bool "preblur", bool "info"){
scFile = Default(scFile, "scFile.log")
thSCD1 = Default(thSCD1, 360)
thSCD2 = Default(thSCD2, 120)
mDiff = Default(mDiff, 2.5)
pel = Default(pel, 1)
search = Default(search, 4)
searchparam = Default(searchparam, 2)
preblur = Default(preblur, true)
info = Default(info, false)
last = preblur ? c.RemoveGrain(20, 0) : c
Assert( IsYV12 , "SCDetect needs YV12 input!" )
super = MSuper(pel=pel, chroma=false)
vector = super.MAnalyse(pelsearch=pel, search=search, searchparam=searchparam, chroma=false)
global scMask = MSCDetection(vector, thSCD1=thSCD1, thSCD2=thSCD2).Crop(0,0,16,16)
global SC_mD = mDiff
global mean = Histogram(mode="Color").Crop(width+64, 64, 128, 128)
SCTrue = c.Subtitle("Scene change: true" )
SCFalse = c.Subtitle("Scene change: false")
info ? ConditionalFilter( last, SCTrue, SCFalse, "boolSC", "==", "true" )
\ : nop
FrameEvaluate( """global boolSC =
\ (
\ ( scMask.YPlaneMax == 255 ) &&
\ (
\ (mean.YDifferenceFromPrevious > SC_mD*3) ||
\ (
\ (mean.YDifferenceFromPrevious > SC_mD) &&
\ (mean.YDifferenceFromPrevious > (mean.YDifferenceToNext+mean.loop(0, 0, -1).YDifferenceToNext+mean.loop(0, 0, 1).YDifferenceToNext)/1.2)
\ )
\ )
\ )""" )
( scFile != "nul" ) ? WriteFileStart( scFile, """ "# Scene change frame list" """ ).WriteFileIf( scFile, "boolSC==true", "current_frame" ) : nop
return last
}
my changes
Function SCDetect(clip c, string "scFile", int "thSCD1", int "thSCD2", float "mDiff", int "pel", int "search", int "searchparam", bool "preblur", bool "info"){
scFile = Default(scFile, "scFile.log")
thSCD1 = Default(thSCD1, 360)
thSCD2 = Default(thSCD2, 120)
mDiff = Default(mDiff, 2.5)
pel = Default(pel, 1)
search = Default(search, 4)
searchparam = Default(searchparam, 2)
preblur = Default(preblur, true)
info = Default(info, false)
last = preblur ? c.RemoveGrain(20, 0) : c
Assert( IsYV12 , "SCDetect needs YV12 input!" )
super = MSuper(pel=pel, chroma=false)
vector = super.MAnalyse(pelsearch=pel, search=search, searchparam=searchparam, chroma=false)
scMask = MSCDetection(vector, thSCD1=thSCD1, thSCD2=thSCD2).Crop(0,0,16,16)
SC_mD = mDiff
mean = Histogram(mode="Color").Crop(width+64, 64, 128, 128)
SCTrue = c.Subtitle("Scene change: true" )
SCFalse = c.Subtitle("Scene change: false")
info ? ConditionalFilter( last, SCTrue, SCFalse, "boolSC", "==", "true" ) : nop
sss = """
global boolSC =
\ (
\ (scMask.YPlaneMax == 255 ) &&
\ (
\ (mean.YDifferenceFromPrevious > SC_mD*3) ||
\ (
\ (mean.YDifferenceFromPrevious > SC_mD) &&
\ (mean.YDifferenceFromPrevious > (mean.YDifferenceToNext+mean.loop(0, 0, -1).YDifferenceToNext+mean.loop(0, 0, 1).YDifferenceToNext)/1.2)
\ )
\ )
\ )
(scFile != "nul") ? WriteFileIf( scFile, "boolSC==True", "current_frame" ) : nop
return last
"""
return ScriptClip(sss, Args="scFile, scMask, SC_mD, mean, info")
}