View Full Version : Avisynth+ 64bit two pass Deshaker script not working
goorawin
14th October 2016, 11:27
I have just started trying the latest Avisynth+ 64bit
and the following script which (thanks to StainlessS and his great RT_stats script) I have been using very well for sometime on Avisynth+ 32 bit:-
SetMemoryMax(1024)
SetFilterMTMode("DEFAULT_MT_MODE", 1)
LoadVirtualDubPlugin ("C:\Virtual Dub\plugins32\Deshaker.vdf", "deshaker", preroll=0)
Clip=("E:\Resolve Editing\09 Beechy\MTS\00162.MTS")
V1=LWLibavVideoSource(Clip,format ="YUV420P8")
A=LWLibavAudioSource(Clip)
V2=Stabalizer01(V1)
function Stabalizer01(clip Clip) {
ConvertToRGB32(clip, matrix="rec709")
SCRIPT1=Deshaker("19|1|30|4|1|0|1|0|640|480|1|2|1000|1000|1000|1000|4|1|4|2|8|30|300|4|D:\\Deshaker logs\\00232.log|0|0|0|0|0|0|0|0|0|0|0|0|0|1|8|8|3|8|0|0|30|30|0|0|1|0|1|1|0|10|1000|1|90|1|1|20|5000|100|20|1|0|ff00ff")
ForceProcess(SCRIPT1)
SCRIPT1 = 0
Deshaker("19|2|30|4|1|0|1|0|640|480|1|2|1000|1000|1000|1000|4|1|4|2|8|30|300|4|D:\\Deshaker logs\\00232.log|0|0|0|0|0|0|0|0|0|0|0|0|0|1|8|8|3|8|0|0|30|30|0|0|1|0|1|1|0|10|1000|1|90|1|1|20|5000|100|20|1|0|ff00ff")
ConvertToYV12(matrix="rec709")
FZ1000HDFinal05()
}
AudioDub(V2,A)
Assumefps(50.00)
Prefetch(2)
But it no longer works. I can get everything else to work including noise reduction, clip enhancement and other filters (included in the FZ1000HDFinal05 function) but not the two pass (Forceprocess). I'm sure this is because it is only written for 32bit.
Is there other any other way to force avisynth to process one part of a script before its starts the next process?
I do not want to have to use two separate scripts to do this process, as I would like to now use Avisynth+ 64bit, if possible.
Hope there is another solution to this.
StainlessS
15th October 2016, 05:22
Would that be RT_ForceProcess ?
(Yep only compiled for 32 bit, but you also have to use the correct name ie RT_.)
goorawin
15th October 2016, 23:59
Thank you StainlessS for your feedback.
Yes I also tried RT_ForceProcess with the same outcome (32Bit).
Because of the difference (64Bit v 32Bit) in processing speed, see below, I decided it was worth while in trying to get Deshaker to work in the 64Bit script as well.
Anyway after some playing around I have been able to do that with the following function.
Function MultiProcess(clip c) {
startFrame=0
endFrame=-1
if (endFrame < startFrame)
{temp = endFrame
endFrame = startFrame
startFrame = temp}
}
This is used in place of the ForceProcess /RT_ForceProcess function.
I don't know if it is the right way to do it or not, but it works very well. However I'm still to do some speed tests using all this in the one script.
The speed tests so far, on a 10 second clip (1920x1080x50P) using the following plugins:
KNLMeansCL
aWarpSharp
Autoadjust
Smoothlevels
SmoothTweak
AddGrainC
Results were : 64Bit = 109 seconds v 32Bit = 168 seconds
I think you would have to agree, that is a big difference and probably worth while chasing.
StainlessS
16th October 2016, 21:59
goorawin,
Function MultiProcess(clip c) {
startFrame=0
endFrame=-1
if (endFrame < startFrame) {
temp = endFrame
endFrame = startFrame
startFrame = temp
}
}
Dont know what you think above is doing, clip c is never accessed at all, and all you do is swap over startFrame and endFrame Int's once.
I'de actually forgotten that I'de done a script version of ForceProcess, it would have to be a lot slower than above function that basically dont do
anything useful, dont know why you say "it works very well", :confused:
EDIT: Oops, hit the post button instead of Advanced.
Goorawin, can I ask you to in future wrap your code in code tags (Select code, go to Advanced and click the # button).
It's horrible to read unformatted like that.
Anyways, been trying to get a 64bit function working for you, dont know if this will work or not, produces error
Error: At least one module has an unresolved import due to a missing export function in an implicitly dependent module.
Error: Modules with different CPU types were found.
in dependency walker, but then that might well be expected on a 32 bit XP with 64 bit dll (just guessing).
Here is the dll (~32KB, with full project files for VS2010):- LINK REMOVED
Test script
Colorbars.Trim(0,-100)
S="""
RT_DebugF("G_ForceProcess: %d Forcing",current_frame)
Return Last
"""
ScriptClip(S)
G_ForceProcess(debug=False) # Can instead remove scriptclip call and set debug=true
return Last
EDIT: Shows results in DebugView
StainlessS
17th October 2016, 10:29
Post 1 of 2, (too big, glue them back together)
Goorawin, something I've been playing with a little.
Probably could do with a bit more work and checking for errors.
Is slightly disappointing that DeShaker does not return the vector clips to Avisynth, only seems to work in GUI.
Also, VDub latest and also Shekh's VirtualDub deep color modification / VdFilterMod crash on using Deshaker, and VDMod plays it but then crashes on pause.
Little problem with Deshakeer on AVS in that we get Black video after Force Process, I think it may be doing something which prevents clip closure, so I've
added the same solution as in earlier script versions, ie kill the returned clip by setting it to 0.
Here tis.
EDIT: All args are as per Gunnar Thalin defaults.
LoadVirtualDubPlugin ("Deshaker.vdf", "deshaker", preroll=0)
FN="F:\V\CabaretUnCropped.avi"
AviSource(FN).ConvertToRGB32.Trim(10000,-500)
DUMMY=ShakeRattleAndRoll()
G_ForceProcess(DUMMY) ### As Compiled for Goorawin, 64 bit (But I'm using 32 bit version)
#RT_ForceProcess(DUMMY) ### 32 bit (Or ForceProcessAVI from TWriteAVI v2)
DUMMY=0 ### KILL Clip (Call Destructor, Deshaker seems to hold clip open for a time or something, black video unless kill DUMMY)
ShakeRattleAndRoll(Pass=2)
Return Last
Function ShakeRattleAndRoll(clip c,Int "Pass",Int "BlockSize",Int "DifferentialSearchRange",
\ Float "SourcePixelAspectValue",Int "SourcePixelAspectSelection",
\ Float "DestinationPixelAspectValue",Int "DestinationPixelAspectSelection",
\ Int "DestinationWidth",Int "DestinationHeight",Int "Scale",Int "UsePixels",
\ Int "MotionSmoothnessHorizontalPanning",Int "MotionSmoothnessVerticalPanning",Int "MotionSmoothnessRotation",
\ Int "MotionSmoothnessZoom",Float "DiscardMotionOfXBlocks",Int "VideoOutput",Int "EdgeCompensation",Int "Resampling",
\ Float "SkipFrameIfLessThanXPercentOfBlocksOk",Int "InitialSearchRange",
\ Float "DiscardMotionOfBlocksMatchingValueLessThanX",Float "DiscardMotionOfBlocksThatHave2ndBestMatchLargerThanBestMinusX",
\ String "LogFile",Bool "AppendToFile",
\ Bool "IgnorePixelsOutside",Int "IgnorePixelsOutsideLeft",Int "IgnorePixelsOutsideRight",Int "IgnorePixelsOutsideTop",
\ Int "IgnorePixelsOutsideBottom",
\ Bool "IgnorePixelsInside",Int "IgnorePixelsInsideLeft",Int "IgnorePixelsInsideRight",Int "IgnorePixelsInsideTop",
\ Int "IgnorePixelsInsideBottom",Bool "VideoTypeInterlaced",Bool "VideoTypeUpperFieldFirst",
\ Float "ExtraZoomFactor",Float "MaxCorrectionLimitsHorizontalPanning",Float "MaxCorrectionLimitsVerticalPanning",
\ Float "MaxCorrectionLimitsRotation",Float "MaxCorrectionLimitsZoom",
\ Bool "UsePreviousAndFutureFramesToFillInBordersPreviousFramesEnabled",Bool "UsePreviousAndFutureFramesToFillInBordersFutureFramesEnabled",
\ Int "UsePreviousAndFutureFramesToFillInBordersPreviousFrames",Int "UsePreviousAndFutureFramesToFillInBordersFutureFrames",
\ Bool "IgnorePixelsOutside_LetAreaFollowMotion",Int "DeepAnalysisIfLessThanXPercentOfVectorsAreOk",
\ Bool "CamcorderHasARollingShutter",Bool "GenerateInterlacedProgressiveVideo",Bool "SameDestinationPropertiesAsSource",
\ Bool "SoftBorders",Bool "ExtrapolateColorsIntoBorder",Int "SoftBorders_EdgeTransitionWidth",
\ Float "DiscardMotionOfBlocksThatMoveMoreThanXPixels",Bool "RememberDiscardedAreasToNextFrame",
\ Float "RollingShutterAmount",Bool "DetectRotation",Bool "DetectZoom",Float "DetectScenes_Threshold",
\ Float "AdaptiveZoomSmoothness",Float "AdaptiveZoomAmount",Int "DiscardMotionOfBlocksThatHaveMaximumPixelValueDifferenceLessThanX",
\ Bool "DetectScenes",Bool "UseColorMask",Int "MaskColorInHexRRGGBB",
\ Bool "Debug") {
myName="ShakeRattleAndRoll: "
c
DSVersion = 19 # Fixed by DeShaker.vdf, Need modify if new version of dll
Pass=Default(Pass,1)
Assert(Pass==1 || Pass==2, RT_String("%s Pass 1 or 2 Only(%d)",myName,Pass))
BlockSize=Default(BlockSize,30)
Assert(BlockSize>=1 && BlockSize<=100, RT_String("%s BlockSize 1 -> 100 Only(%d)",myName,BlockSize))
DifferentialSearchRange=Default(DifferentialSearchRange,4)
Assert(DifferentialSearchRange>=1, RT_String("%s 1 < DifferentialSearchRange(%d)",myName,DifferentialSearchRange))
SourcePixelAspectValue=Float(Default(SourcePixelAspectValue,1.0))
Assert(0.0 < SourcePixelAspectValue, RT_String("%s 0.0 < SourcePixelAspectValue(%f)",myName,SourcePixelAspectValue))
SourcePixelAspectSelection=Default(SourcePixelAspectSelection,0) ### GUI
Assert(-1 <= SourcePixelAspectSelection && SourcePixelAspectSelection <= 7, RT_String("%s -1 <= SourcePixelAspectSelection <= 7(%d)",
\ myName,SourcePixelAspectSelection))
DestinationPixelAspectValue=Float(Default(DestinationPixelAspectValue,1.0)) ### GUI
Assert(0.0 <= DestinationPixelAspectValue, RT_String("%s 0.0 <= DestinationPixelAspectValue(%f)",myName,DestinationPixelAspectValue))
DestinationPixelAspectSelection=Default(DestinationPixelAspectSelection,0)
Assert(-1 <= DestinationPixelAspectSelection && DestinationPixelAspectSelection <= 7,
\ RT_String("%s -1 <= DestinationPixelAspectSelection <= 7(%d)",myName,DestinationPixelAspectSelection))
DestinationWidth=Default(DestinationWidth,640)
Assert(DestinationWidth>=1, RT_String("%s 1 <= DestinationWidth(%d)",myName,DestinationWidth))
DestinationHeight=Default(DestinationHeight,480)
Assert(DestinationHeight>=1, RT_String("%s 1 <= DestinationHeight(%d)",myName,DestinationHeight))
Scale=Default(Scale,1)
Assert(0 <= Scale, RT_String("%s 0 <= Scale(%d)",myName,Scale))
UsePixels=Default(UsePixels,2)
Assert(1 <= UsePixels <=4, RT_String("%s 1 <= UsePixels <= 4(%d)",myName,UsePixels))
MotionSmoothnessHorizontalPanning=Default(MotionSmoothnessHorizontalPanning,1000)
Assert(1 <= MotionSmoothnessHorizontalPanning, RT_String("%s 1 <= MotionSmoothnessHorizontalPanning(%d)",
\ myName,MotionSmoothnessHorizontalPanning))
MotionSmoothnessVerticalPanning=Default(MotionSmoothnessVerticalPanning,1000)
Assert(1 <= MotionSmoothnessVerticalPanning, RT_String("%s 1 <= MotionSmoothnessVerticalPanning(%d)",myName,MotionSmoothnessVerticalPanning))
MotionSmoothnessRotation=Default(MotionSmoothnessRotation,1000)
Assert(1 <= MotionSmoothnessRotation, RT_String("%s 1 <= MotionSmoothnessRotation(%d)",myName,MotionSmoothnessRotation))
MotionSmoothnessZoom=Default(MotionSmoothnessZoom,1000)
Assert(1 <= MotionSmoothnessZoom, RT_String("%s 1 <= MotionSmoothnessZoom(%d)",myName,MotionSmoothnessZoom))
DiscardMotionOfXBlocks=Float(Default(DiscardMotionOfXBlocks,4.0))
Assert(0.0 < DiscardMotionOfXBlocks, RT_String("%s 0.0 <= DiscardMotionOfXBlocks(%f)",myName,DiscardMotionOfXBlocks))
VideoOutput=Default(VideoOutput,1)
Assert(0 <= VideoOutput <=3, RT_String("%s 0 <= VideoOutput <= 3(%d)",myName,VideoOutput))
EdgeCompensation=Default(EdgeCompensation,0)
Assert(EdgeCompensation==0||EdgeCompensation==1||EdgeCompensation==3||EdgeCompensation==4||EdgeCompensation==6,
\ RT_String("%s EdgeCompensation 0,1,3,4 or 6 only(%d)",myName,EdgeCompensation))
Resampling=Default(Resampling,2)
Assert(0 <= Resampling <= 2, RT_String("%s 0 <= Resampling <= 2(%d)",myName,Resampling))
SkipFrameIfLessThanXPercentOfBlocksOk=Float(Default(SkipFrameIfLessThanXPercentOfBlocksOk,8.0))
Assert(0.0 <= SkipFrameIfLessThanXPercentOfBlocksOk <= 100.0, RT_String("%s 0.0 <= SkipFrameIfLessThanXPercentOfBlocksOk <= 100.0(%f)",
\ myName,SkipFrameIfLessThanXPercentOfBlocksOk))
InitialSearchRange=Default(InitialSearchRange,30)
Assert(1 <= InitialSearchRange <= 99, RT_String("%s 1 <= InitialSearchRange <= 99(%d)",myName,InitialSearchRange))
DiscardMotionOfBlocksMatchingValueLessThanX=Float(Default(DiscardMotionOfBlocksMatchingValueLessThanX,300.0))
Assert(-1000.0 <= DiscardMotionOfBlocksMatchingValueLessThanX <= 1000.0,
\ RT_String("%s -1000.0 <= DiscardMotionOfBlocksMatchingValueLessThanX <= 1000.0(%f)",
\ myName,DiscardMotionOfBlocksMatchingValueLessThanX))
DiscardMotionOfBlocksThatHave2ndBestMatchLargerThanBestMinusX=Float(Default(DiscardMotionOfBlocksThatHave2ndBestMatchLargerThanBestMinusX,4.0))
Assert(0.0 <= DiscardMotionOfBlocksThatHave2ndBestMatchLargerThanBestMinusX,
\ RT_String("%s 0.0 <= DiscardMotionOfBlocksThatHave2ndBestMatchLargerThanBestMinusX(%f)",
\ myName,DiscardMotionOfBlocksThatHave2ndBestMatchLargerThanBestMinusX))
LogFile=Default(LogFile,"ShakeRattleAndRoll.Log")
Assert(LogFile!="",RT_String("%sLogfile Cannot be Empty string",myName))
LogFile=RT_GetFullPathName(LogFile)
Assert(Pass==1||Exist(LogFile),RT_String("%sPass 2 Logfile Does NOT Exist(%s)",myName,LogFile))
LogFile=RT_StrReplace(LogFile,"\","\\")
AppendToFile=Default(AppendToFile,False)
StainlessS
17th October 2016, 10:30
Post 2 of 2
IgnorePixelsOutside=Default(IgnorePixelsOutside,False)
IgnorePixelsOutsideLeft=Default(IgnorePixelsOutsideLeft,0)
IgnorePixelsOutsideRight=Default(IgnorePixelsOutsideRight,0)
IgnorePixelsOutsideTop=Default(IgnorePixelsOutsideTop,0)
IgnorePixelsOutsideBottom=Default(IgnorePixelsOutsideBottom,0)
IgnorePixelsInside=Default(IgnorePixelsInside,0)
Assert(0 <= IgnorePixelsInside && IgnorePixelsInside <= 1, RT_String("%s 0 <= IgnorePixelsInside <= 1(%d)",myName,IgnorePixelsInside))
IgnorePixelsInsideLeft=Default(IgnorePixelsInsideLeft,0)
IgnorePixelsInsideRight=Default(IgnorePixelsInsideRight,0)
IgnorePixelsInsideTop=Default(IgnorePixelsInsideTop,0)
IgnorePixelsInsideBottom=Default(IgnorePixelsInsideBottom,0)
VideoTypeInterlaced=Default(VideoTypeInterlaced,False)
VideoTypeUpperFieldFirst=Default(VideoTypeUpperFieldFirst,False)
ExtraZoomFactor=Float(Default(ExtraZoomFactor,1.0))
Assert(0.0 < ExtraZoomFactor, RT_String("%s 0.0 < ExtraZoomFactor(%f)",myName,ExtraZoomFactor))
MaxCorrectionLimitsHorizontalPanning=Float(Default(MaxCorrectionLimitsHorizontalPanning,15.0))
Assert(1.0 <= MaxCorrectionLimitsHorizontalPanning, RT_String("%s 1.0 <= MaxCorrectionLimitsHorizontalPanning(%f)",
\ myName,MaxCorrectionLimitsHorizontalPanning))
MaxCorrectionLimitsVerticalPanning=Float(Default(MaxCorrectionLimitsVerticalPanning,15.0))
Assert(1.0 <= MaxCorrectionLimitsVerticalPanning, RT_String("%s 1.0 <= MaxCorrectionLimitsVerticalPanning(%f)",
\ myName,MaxCorrectionLimitsVerticalPanning))
MaxCorrectionLimitsRotation=Float(Default(MaxCorrectionLimitsRotation,5.0))
Assert(1.0 <= MaxCorrectionLimitsRotation, RT_String("%s 1.0 <= MaxCorrectionLimitsRotation(%f)",myName,MaxCorrectionLimitsRotation))
MaxCorrectionLimitsZoom=Float(Default(MaxCorrectionLimitsZoom,15.0))
Assert(1.0 <= MaxCorrectionLimitsZoom, RT_String("%s 1.0 <= MaxCorrectionLimitsZoom(%f)",myName,MaxCorrectionLimitsZoom))
UsePreviousAndFutureFramesToFillInBordersPreviousFramesEnabled=Default(UsePreviousAndFutureFramesToFillInBordersPreviousFramesEnabled,False)
UsePreviousAndFutureFramesToFillInBordersFutureFramesEnabled=Default(UsePreviousAndFutureFramesToFillInBordersFutureFramesEnabled,False)
UsePreviousAndFutureFramesToFillInBordersPreviousFrames=Default(UsePreviousAndFutureFramesToFillInBordersPreviousFrames,30)
Assert(0 <= UsePreviousAndFutureFramesToFillInBordersPreviousFrames,
\ RT_String("%s 0 <= UsePreviousAndFutureFramesToFillInBordersPreviousFrames(%d)",
\ myName,UsePreviousAndFutureFramesToFillInBordersPreviousFrames))
UsePreviousAndFutureFramesToFillInBordersFutureFrames=Default(UsePreviousAndFutureFramesToFillInBordersFutureFrames,30)
Assert(0 <= UsePreviousAndFutureFramesToFillInBordersFutureFrames,
\ RT_String("%s 0 <= UsePreviousAndFutureFramesToFillInBordersFutureFrames(%d)",
\ myName,UsePreviousAndFutureFramesToFillInBordersFutureFrames))
IgnorePixelsOutside_LetAreaFollowMotion=Default(IgnorePixelsOutside_LetAreaFollowMotion,False)
DeepAnalysisIfLessThanXPercentOfVectorsAreOk=Default(DeepAnalysisIfLessThanXPercentOfVectorsAreOk,0)
Assert(0<=DeepAnalysisIfLessThanXPercentOfVectorsAreOk && DeepAnalysisIfLessThanXPercentOfVectorsAreOk<=100,
\ RT_String("%s 0 <= DeepAnalysisIfLessThanXPercentOfVectorsAreOk <= 100(%d)",myName,DeepAnalysisIfLessThanXPercentOfVectorsAreOk))
CamcorderHasARollingShutter=Default(CamcorderHasARollingShutter,false)
GenerateInterlacedProgressiveVideo=Default(GenerateInterlacedProgressiveVideo,false)
SameDestinationPropertiesAsSource=Default(SameDestinationPropertiesAsSource,true)
SoftBorders=Default(SoftBorders,false)
ExtrapolateColorsIntoBorder=Default(ExtrapolateColorsIntoBorder,false)
SoftBorders_EdgeTransitionWidth=Default(SoftBorders_EdgeTransitionWidth,10)
Assert(0<=SoftBorders_EdgeTransitionWidth, RT_String("%s 0 <= SoftBorders_EdgeTransitionWidth(%d)",myName,SoftBorders_EdgeTransitionWidth))
DiscardMotionOfBlocksThatMoveMoreThanXPixels=Float(Default(DiscardMotionOfBlocksThatMoveMoreThanXPixels,1000.0))
Assert(0.0<SoftBorders_EdgeTransitionWidth, RT_String("%s 0.0 < DiscardMotionOfBlocksThatMoveMoreThanXPixels(%f)",
\ myName,DiscardMotionOfBlocksThatMoveMoreThanXPixels))
RememberDiscardedAreasToNextFrame=Default(RememberDiscardedAreasToNextFrame,true)
RollingShutterAmount=Float(Default(RollingShutterAmount,99.0)) ##### Any Value ???
DetectRotation=Default(DetectRotation,true)
DetectZoom=Default(DetectZoom,true)
DetectScenes_Threshold=Float(Default(DetectScenes_Threshold,20.0))
Assert(0.0<=DetectScenes_Threshold && DetectScenes_Threshold <= 1000.0, RT_String("%s 0.0 <= DetectScenes_Threshold <= 1000.0(%f)",
\ myName,DetectScenes_Threshold))
AdaptiveZoomSmoothness=Float(Default(AdaptiveZoomSmoothness,5000.0))
Assert(0.0<AdaptiveZoomSmoothness, RT_String("%s 0.0 < DetectScenes_Threshold(%f)",myName,AdaptiveZoomSmoothness))
AdaptiveZoomAmount=Float(Default(AdaptiveZoomAmount,100.0)) ##### Any Value ???
DiscardMotionOfBlocksThatHaveMaximumPixelValueDifferenceLessThanX=Default(DiscardMotionOfBlocksThatHaveMaximumPixelValueDifferenceLessThanX,20)
Assert(0<=DiscardMotionOfBlocksThatHaveMaximumPixelValueDifferenceLessThanX&&DiscardMotionOfBlocksThatHaveMaximumPixelValueDifferenceLessThanX<=255,
\ RT_String("%s0 <= DiscardMotionOfBlocksThatHaveMaximumPixelValueDifferenceLessThanX <= 255(%d)",
\ myName,DiscardMotionOfBlocksThatHaveMaximumPixelValueDifferenceLessThanX))
DetectScenes=Default(DetectScenes,true)
UseColorMask=Default(UseColorMask,false)
MaskColorInHexRRGGBB=RT_BitAnd(Default(MaskColorInHexRRGGBB,$FF00FF),$FFFFFF)
Debug=Default(Debug,True)
Fmt="%d|%d|%d|%d|%f|%d|%f|%d|%d|%d|%d|%d|%d|%d|%d|%d|%f|%d|%d|%d|%f|%d|%f|%f|" +
\ "%s|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%f|%f|%f|%f|%f|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%f|%d|%f|%d|%d|%f|%f|%f|%d|%d|%d|%x"
S=RT_String(Fmt,
\ DSVersion,Pass,BlockSize,DifferentialSearchRange,
\ SourcePixelAspectValue,SourcePixelAspectSelection,
\ DestinationPixelAspectValue,DestinationPixelAspectSelection,
\ DestinationWidth,DestinationHeight,Scale,UsePixels,
\ MotionSmoothnessHorizontalPanning,MotionSmoothnessVerticalPanning,MotionSmoothnessRotation,MotionSmoothnessZoom,
\ DiscardMotionOfXBlocks,VideoOutput,EdgeCompensation,Resampling,
\ SkipFrameIfLessThanXPercentOfBlocksOk,InitialSearchRange,
\ DiscardMotionOfBlocksMatchingValueLessThanX,DiscardMotionOfBlocksThatHave2ndBestMatchLargerThanBestMinusX,
\ LogFile,AppendToFile?1:0,
\ IgnorePixelsOutside?1:0,IgnorePixelsOutsideLeft,IgnorePixelsOutsideRight,IgnorePixelsOutsideTop,IgnorePixelsOutsideBottom,
\ IgnorePixelsInside,IgnorePixelsInsideLeft,IgnorePixelsInsideRight,IgnorePixelsInsideTop,IgnorePixelsInsideBottom,
\ VideoTypeInterlaced?1:0,VideoTypeUpperFieldFirst?1:0,
\ ExtraZoomFactor,MaxCorrectionLimitsHorizontalPanning,MaxCorrectionLimitsVerticalPanning,
\ MaxCorrectionLimitsRotation,MaxCorrectionLimitsZoom,
\ UsePreviousAndFutureFramesToFillInBordersPreviousFramesEnabled?1:0,UsePreviousAndFutureFramesToFillInBordersFutureFramesEnabled?1:0,
\ UsePreviousAndFutureFramesToFillInBordersPreviousFrames,UsePreviousAndFutureFramesToFillInBordersFutureFrames,
\ IgnorePixelsOutside_LetAreaFollowMotion?1:0,DeepAnalysisIfLessThanXPercentOfVectorsAreOk,
\ CamcorderHasARollingShutter?1:0,GenerateInterlacedProgressiveVideo?1:0,SameDestinationPropertiesAsSource?1:0,
\ SoftBorders?1:0,ExtrapolateColorsIntoBorder?1:0,SoftBorders_EdgeTransitionWidth,
\ DiscardMotionOfBlocksThatMoveMoreThanXPixels,RememberDiscardedAreasToNextFrame?1:0,
\ RollingShutterAmount,DetectRotation?1:0,DetectZoom?1:0,DetectScenes_Threshold,
\ AdaptiveZoomSmoothness,AdaptiveZoomAmount,DiscardMotionOfBlocksThatHaveMaximumPixelValueDifferenceLessThanX,
\ DetectScenes?1:0,UseColorMask?1:0,MaskColorInHexRRGGBB
\ )
(Debug) ? RT_DebugF("%s",S,name=myName) : NOP
(Debug) ? RT_WriteFile("ShakeRattleAndRollDebug.txt","%s",S) : NOP
Deshaker(S)
}
Groucho2004
17th October 2016, 12:09
Stainless, your scripts make me dizzy. :)
StainlessS
17th October 2016, 22:48
Stainless, your scripts make me dizzy. :)
Me Too.
I thought you were gonna say that the 'Black clip' was due to log file not being closed until later (as constructor would not have been called until later). I forgot that I specifically close output AVI in TWriteAVI [EDIT: at end of clip and prior to destructor call] , else similar problem on trying lo load resultant Lossless. I guess I have to make a point of pointing that out in RT_ForceProcess and ForceProcessAVI docs, except when using it with TWriteAVI v2.0. (Also I was very tired when posting above).
I used almost exactly the titles of the various parameters used in Gunnar Thalin Docs for DeShaker ( http://www.guthspot.se/video/deshaker.htm ), near end of web page, named "Script Parameters". I thought it would be easier to figure out what the args were from nearly full description, Also, I hate having to think up names for args ('Fred' and 'Test' being two favorites).
If someone wanted to think up shorter names then copy/paste would achieve it quite quickly, but I dont wanna think up 65 names myself.
Anyway, it would not be the first time that someone said that Deshaker was tricky to use from AviSynth, perhaps posted script would make it easier, not too much trouble I hope to copy/paste arg names from function header and not have to remember or count positions in a weird format string where everything looks nearly the same.
EDIT: VideoOutput, is the arg that should select vector clips, but does not.
Of course, same method could be used to create 'ease of use' stubs for other VDub filters.
StainlessS
17th October 2016, 23:29
Reply to PM by InGoldie, also posted here:
Is it possible to stabilize shaky video automatically?
Hi StainlessS,
Also very important to me.
Do you have any idea about the thread in the following link?
http://forum.doom9.org/showthread.ph...53#post1782953
And do you think the following script is an automatic image stabilizer?
function Stabalizer01(clip Clip) {
ConvertToRGB32(clip, matrix="rec709")
SCRIPT1=Deshaker("19|1|30|4|1|0|1|0|640|480|1|2|1000|1000|1000|1000|4|1|4|2|8|30|300|4|D:\\Deshaker logs\\00232.log|0|0|0|0|0|0|0|0|0|0|0|0|0|1|8|8|3|8|0|0|30|30|0|0|1|0|1|1|0|10|1000|1|90|1|1|20|5000|100|20|1|0|ff00ff")
ForceProcess(SCRIPT1)
SCRIPT1 = 0
Deshaker("19|2|30|4|1|0|1|0|640|480|1|2|1000|1000|1000|1000|4|1|4|2|8|30|300|4|D:\\Deshaker logs\\00232.log|0|0|0|0|0|0|0|0|0|0|0|0|0|1|8|8|3|8|0|0|30|30|0|0|1|0|1|1|0|10|1000|1|90|1|1|20|5000|100|20|1|0|ff00ff")
ConvertToYV12(matrix="rec709")
FZ1000HDFinal05()
}
Everything necessary is in that same thread where you found that script, but only to automate the 2 passes in same script.
You would however have to provide all arguments specific to the clip in question.
I am no expert at deshaking, I just made it possible with provided script, something a little easier to use so that others
that are more expert in using deshaker, could provide additional scripts with maybe some named presets, so that
problems of specific 'types' could be auto fixed. (Leastwise, that was the purpose of my script function).
I have no idea what 'FZ1000HDFinal05()' is or what it does.
I'll also post this reply in that thread, perhaps may prompt someone to have a go.
StainlessS
17th October 2016, 23:36
Here, my notes gleaned from Gunnar Thalin docs, and used in creating script.
It's a bit wide I'm afraid, but have decided not to try to split, so will mess up post a bit.
Shaky="19|1|30|4|1|0|1|0|640|480|1|2|1000|1000|1000|1000|4|1|4|2|8|30|300|4|" +
\ "D:\\Deshaker logs\\00232.log" +
\ "|0|0|0|0|0|0|0|0|0|0|0|0|0|1|8|8|3|8|0|0|30|30|0|0|1|0|1|1|0|10|1000|1|90|1|1|20|5000|100|20|1|0|ff00ff"
########################
###
DSVersion = 19 # Parm 1, Int, 1 -> 19 (As for dll version) [Both pass 1 and 2 have to be correct version]
Pass = 1 # Parm 2, Int, 1 -> 2 [select Pass number 1 or 2]
###
BlockSize = 30 # Parm 3, Int, 1 - 100 [Pass 1]
DifferentialSearchRange = 4 # Parm 4, Int, 1 -> ??? [Pass 1]
SourcePixelAspectValue = 1.0 # Parm 5, Float, 0.0 < SourcePixelAspectValue [Pass 1 & 2] (1.0 IF SourcePixelAspectSelection == default 0)
SourcePixelAspectSelection = 0 # Parm 6, Int, GUI ONLY, Specified via SourcePixelAspectValue. [Pass Not Used, GUI ONLY]
# -1: A free source pixel aspect value
# 0: Square pixels / HD (1:1) = Value 1.0
# 1: Standard PAL (59:54) = Value 1.09259
# 2: Standard NTSC (10:11) = Value 0.909091
# 3: Anamorphic PAL (118:81) = Value 1.45679
# 4: Anamorphic NTSC (40:33) = Value 1.21212
# 5: SVCD PAL (59:36) = Value 1.63889
# 6: SVCD NTSC (15:11) = Value 1.36364
# 7: HDV 1440x1080 (4:3) = Value 1.33333
DestinationPixelAspectValue = 1.0 # Parm 7, Float, 0.0 < DestinationPixelAspectValue. [Pass 2] (Only used if SameDestinationPropertiesAsSource is set to 0.)
DestinationPixelAspectSelection = 0 # Parm 8, Int, GUI ONLY. Same as Source pixel aspect selection
DestinationWidth = 640 # Parm 9, Int, 1 -> ???. [Pass 2] (Only active if parameter SameDestinationPropertiesAsSource = 0.)
DestinationHeight = 480 # Parm 10, Int, 1 -> ???. [Pass 2] (Only active if parameter SameDestinationPropertiesAsSource = 0.)
Scale = 1 # Parm 11, Int, 0 -> 2. [Pass 1]
# 0: Full
# 1: Half
# 2: Quarter
UsePixels = 2 # Parm 12,int 1 -> 4. [Pass 1]
# 1: All
# 2: Every 4th
# 3: Every 9th
# 4: Every 16th
MotionSmoothnessHorizontalPanning = 1000 # Parm 13, Int -1 -> ??? [Pass 2]
MotionSmoothnessVerticalPanning = 1000 # Parm 14, Int -1 -> ??? [Pass 2]
MotionSmoothnessRotation = 1000 # Parm 15, Int -1 -> ??? [Pass 2]
MotionSmoothnessZoom = 1000 # Parm 16, Int -1 -> ??? [Pass 2]
DiscardMotionOfXBlocks = 4.0 # Parm 17, Float, 0.0 < DiscardMotionOfXBlocks. [Pass 1] (Discard motion of blocks that move more than X pixels in wrong direction)
VideoOutput = 1 # Parm 18, Int, 0 -> 3 [Pass 1]
# 0: None
# 1: Motion vectors
# 2: Motion vectors, extended 2x
# 3: Motion vectors, extended 5x
EdgeCompensation = 0 # Parm 19, Int, 0, 1, 3, 4, 6. [Pass 2]
# 0: None
# 1: Adaptive zoom average
# 3: Fixed zoom
# 4: Adaptive zoom average + fixed zoom
# 6: Adaptive zoom full
Resampling = 2 # Parm 20, Int, 0 -> 2. [Pass 2]
# 0: Nearest neighbor
# 1: Bilinear
# 2: Bicubic
SkipFrameIfLessThanXPercentOfBlocksOk=8.0 # Parm 21, Float, 0.0 -> 100.0. [Pass 1]
InitialSearchRange = 30 # Parm 22, Int, 1 -> 99. [Pass 1]
DiscardMotionOfBlocksMatchingValueLessThanX = 300.0 # Parm 23, Float, -1000.0 -> 1000.0. [Pass 1]
DiscardMotionOfBlocksThatHave2ndBestMatchLargerThanBestMinusX = 4.0 # Parm 24, Float, 0.0 -> ??? [Pass 1]
LogFile = depends # Parm 25, String FilePath. [Pass 1 & 2]
AppendToFile = 0 # Parm 26, Int, 0 -> 1 (0=No, 1=Yes) [Pass 1 & 2]
IgnorePixelsOutside. = 0 # Parm 27, Int, 0 -> 1 [Pass 1] (0=No, 1=Yes, Activates the following four parameters if set to 1.)
IgnorePixelsOutsideLeft = 0 # Parm 28, Int, Any Value [Pass 1]
IgnorePixelsOutsideRight = 0 # Parm 29, Int, Any Value [Pass 1]
IgnorePixelsOutsideTop = 0 # Parm 30, Int, Any Value [Pass 1]
IgnorePixelsOutsideBottom = 0 # Parm 31, Int, Any Value [Pass 1]
IgnorePixelsInside = 0 # Parm 32, Int, 0 -> 1 [Pass 1] (0=No, 1=Yes, Activates the following four parameters if set to 1.)
IgnorePixelsInsideLeft = 0 # Parm 33, Int, Any Value [Pass 1]
IgnorePixelsInsideRight = 0 # Parm 34, Int, Any Value [Pass 1]
IgnorePixelsInsideTop = 0 # Parm 35, Int, Any Value [Pass 1]
IgnorePixelsInsideBottom = 0 # Parm 36, Int, Any Value [Pass 1]
VideoTypeInterlaced = 0 # Parm 37, Int, 0 -> 1 (0=No, 1=Yes) [Pass 1 & 2]
VideoTypeUpperFieldFirst = 0 # Parm 38, Int, 0 -> 1 (0=No, 1=Yes), [Pass 1 & 2] (Only used if VideoTypeInterlaced is set to 1)
ExtraZoomFactor = 1.0 # Parm 39, Float, 0.0 < ExtraZoomFactor [Pass 2]
MaxCorrectionLimitsHorizontalPanning=15.0 # Parm 40, Float, 1.0 -> ??? [Pass 2]
MaxCorrectionLimitsVerticalPanning =15.0 # Parm 41, Float, 1.0 -> ??? [Pass 2]
MaxCorrectionLimitsRotation =5.0 # Parm 42, Float, 1.0 -> ??? [Pass 2]
MaxCorrectionLimitsZoom =15.0 # Parm 43, Float, 1.0 -> ??? [Pass 2]
UsePreviousAndFutureFramesToFillInBordersPreviousFramesEnabled = 0 # Parm 44, Int, 0 -> 1 (0=No, 1=Yes) [Pass 2]
UsePreviousAndFutureFramesToFillInBordersFutureFramesEnabled = 0 # Parm 45, Int, 0 -> 1 (0=No, 1=Yes) [Pass 2]
UsePreviousAndFutureFramesToFillInBordersPreviousFrames = 30 # Parm 46, Int, 0 -> ??? [Pass 2]
UsePreviousAndFutureFramesToFillInBordersFutureFrames = 30 # Parm 47, Int, 0 -> ??? [Pass 2]
IgnorePixelsOutside_LetAreaFollowMotion = 0 # Parm 48, Int, 0 -> 1 (0=No, 1=Yes) [Pass 1]
DeepAnalysisIfLessThanXPercentOfVectorsAreOk = 0 # Parm 49, Int, 0 -> 100. [Pass 1] (Only used if Camcorder has a rolling shutter is set to 0.)
CamcorderHasARollingShutter = 0 # Parm 50, Int, 0 -> 1 (0=No, 1=Yes) [Pass 1 & 2]
GenerateInterlacedProgressiveVideo = 0 # Parm 51, Int, 0 -> 1 (0=No, 1=Yes), [Pass=2] (Only valid for interlaced video)
SameDestinationPropertiesAsSource = 1 # Parm 52, Int, 0 -> 1 (0=No, 1=Yes) [Pass 2]
SoftBorders = 0 # Parm 53, Int, 0 -> 1 (0=No, 1=Yes) [Pass 2] (Only valid if using previous and future frames to fill in border.)
ExtrapolateColorsIntoBorder = 0 # Parm 54, Int, 0 -> 1 (0=No, 1=Yes) [Pass 2]
SoftBorders_EdgeTransitionWidth = 10 # Parm 55, Int, 0 -> ??? (Only valid if using Soft borders.) [Pass 2]
DiscardMotionOfBlocksThatMoveMoreThanXPixels = 1000.0 # Parm 56, Float, 0.0 < DiscardMotionOfBlocksThatMoveMoreThanXPixels. [Pass 1] (absolute motion)
RememberDiscardedAreasToNextFrame = 1 # Parm 57, Int, 0 -> 1 (0=No, 1=Yes) [Pass 1]
RollingShutterAmount = 88.0 # Parm 58, Float, Any Value. [Pass 1 & 2] (Only used if Camcorder has a rolling shutter is set to 1.)
DetectRotation = 1 # Parm 59, Int, 0 -> 1 (0=No, 1=Yes) [Pass 1]
DetectZoom = 1 # Parm 60, Int, 0 -> 1 (0=No, 1=Yes) [Pass 1]
DetectScenes_Threshold = 20.0 # Parm 61, Float, 0.0 -> 1000.0. [Pass 1] (Only used if Detect scenes is set to 1.)
AdaptiveZoomSmoothness = 5000.0 # Parm 62, Float, 0.0 < AdaptiveZoomSmoothness. [Pass 2] (Only used if Edge compensation is set to 1, 4 or 6.)
AdaptiveZoomAmount = 100.0 # Parm 63, Float, Any Value. [Pass 2] (Only used if Edge compensation is set to 1, 4 or 6.)
DiscardMotionOfBlocksThatHaveMaximumPixelValueDifferenceLessThanX=20 # Parm 64, Int, 0 -> 255. [Pass 1]
DetectScenes = 1 # Parm 65, Int, 0 -> 1 (0=No, 1=Yes) [Pass 1]
UseColorMask = 0 # Parm 66, Int, 0 -> 1 (0=No, 1=Yes) [Pass 1 & 2]
MaskColorInHexRRGGBB = FF00FF # Parm 67, Int, 000000 -> FFFFFF. [Pass 1 & 2] (e.g. black is 0, blue is ff, red is ff0000, grey is 808080)
EDIT: 'Parm' Parameters are 1 relative.
goorawin
17th October 2016, 23:58
Thank you for all the updates and going to so much trouble.
I did send the wrong script, sorry, and the one that I thought worked well was in fact was using the logs from previous test renders I had done, so of no use.
The ShakeRattleAndRoll script loads in the 32Bit version without problems.
However it is using the output from the first pass as the input for the second pass, which means the final output has low contrast and levels and it has the first pass black band at the bottom. The output is stabalized.
LoadVirtualDubPlugin ("C:\Virtual Dub\plugins32\Deshaker.vdf", "deshaker", preroll=0)
Clip=("E:\Resolve Editing\Tasmania 2016\Raw Video\P2420153.MP4")
V1=FFMS2(Clip)
#V1=LWLibavVideoSource(Clip,format ="YUV420P8")
A=FFAudioSource(Clip)
#A=LWLibavAudioSource(Clip)
AudioDub(V1,A).Trim(0,100).ConvertToRGB32()
#FN="F:\V\CabaretUnCropped.avi"
#AviSource(FN).ConvertToRGB32.Trim(10000,-500)
DUMMY=ShakeRattleAndRoll()
deshaker("19|1|30|4|1|0|1|0|640|480|1|2|-1|-1|-1|-1|4|1|3|2|8|30|300|4|D:\\Deshaker logs\\00157.log|0|0|0|0|0|0|0|0|0|0|0|0|0|1|1|1|1|1|0|0|30|30|0|0|1|0|1|1|0|10|1000|1|70|1|1|20|5000|100|20|1|0|ff00ff")
#G_ForceProcess(DUMMY) ### As Compiled for Goorawin, 64 bit (But I'm using 32 bit version)
RT_ForceProcess(DUMMY) ### 32 bit (Or ForceProcessAVI from TWriteAVI v2)
DUMMY=0 ### KILL Clip (Call Destructor, Deshaker seems to hold clip open for a time or something, black video unless kill DUMMY)
ShakeRattleAndRoll(Pass=2)
deshaker("19|2|30|4|1|0|1|0|640|480|1|2|-1|-1|-1|-1|4|1|3|2|8|30|300|4|D:\\Deshaker logs\\00157.log|0|0|0|0|0|0|0|0|0|0|0|0|0|1|1|1|1|1|0|0|30|30|0|0|1|0|1|1|0|10|1000|1|70|1|1|20|5000|100|20|1|0|ff00ff")
Return Last
In the 64Bit version it will not load RT_String (There is no function named 'RT_String'). Its probably because it still 32Bit.
The other ones that might be an issue are RT_BitAnd, RT_GetFullPathName, RT_StrReplace, RT_DebugF and RT_WriteFile.
Anyway thank you so much for your efforts
In answer to 'is it an automated script' Yes it is.
I have various profiles for deshaker that are applied to clips based on what is required. The FZ1000HDFinal05() contains the plugin I mentioned earlier in the speed test.
I batch encode maybe 200 to 300 clips at a time. It just save me a lot of time and give a very impressive output in the final production.
Because this number of clips does take time and now that Avisynth+ 64Bit seems to be stable and working well, it make sense to use 64Bit to cut rendering time by 30 to 40%.
StainlessS
18th October 2016, 00:18
G, can you confirm whether or not the G_ForceProcess worked ok on 64 bit.
If so I'll try to incorporate the other [EDIT: used] RT_ functions (forgot about 64 bit, was still doing it at about 09:00 this morinng (up all night)).
I will not bother with RT_BitAnd, and shall use v2.6 BitAnd instead.
Here mod of your failing script untested. [EDIT: you used deshaker(...), as well as ShakeRattleAndRoll(), which calls deshaker]
LoadVirtualDubPlugin ("C:\Virtual Dub\plugins32\Deshaker.vdf", "deshaker", preroll=0)
FN="E:\Resolve Editing\Tasmania 2016\Raw Video\P2420153.MP4" # FN is a filename, not a clip :)
FFMS2(FN)
A=FFAudioSource(FN)
DUMMY=ShakeRattleAndRoll() # Using Last as source (easier than assigning to V1)
G_ForceProcess(DUMMY) # As Compiled for Goorawin, 64 bit (But I'm using 32 bit version)
DUMMY=0 # KILL Clip (Call Destructor, Deshaker seems to hold clip open for a time or something, black video unless kill DUMMY)
ShakeRattleAndRoll(Pass=2) # Source is still original Last
AudioDub(A).Trim(0,100).ConvertToRGB32() # Video is result Last from ShakeRattleAndRoll(Pass=2)
Return Last
EDIT: Note, ShakeRattleAndRoll(), uses Deshaker defaults, you would need to supply named arg mods directly to it (ive just used SR&R defaults).
At this point I just want to know if it works, not too bothered about whether default SR&R() args work well for the clip.
goorawin
18th October 2016, 02:15
Sorry
Yes, G_ForceProcess loads and seems to work on 64 bit.
Your updated script works correctly on 32Bit. However I had to change G_ForceProcess to RT_ForceProcess for 32Bit
LoadVirtualDubPlugin ("C:\Virtual Dub\plugins32\Deshaker.vdf", "deshaker", preroll=0)
FN="E:\Resolve Editing\Tasmania 2016\Raw Video\P2420153.MP4" # FN is a filename, not a clip :)
FFMS2(FN).ConvertToRGB32()
A=FFAudioSource(FN)
DUMMY=ShakeRattleAndRoll() # Using Last as source (easier than assigning to V1)
RT_ForceProcess(DUMMY) # As Compiled for Goorawin, 64 bit (But I'm using 32 bit version)
DUMMY=0 # KILL Clip (Call Destructor, Deshaker seems to hold clip open for a time or something, black video unless kill DUMMY)
ShakeRattleAndRoll(Pass=2) # Source is still original Last
AudioDub(A).Trim(0,100).ConvertToRGB32() # Video is result Last from ShakeRattleAndRoll(Pass=2)
Return Last
I haven't looked for the deshaker log with your script but it seems to be analyzing the whole clip in the first pass, not just the trimmed part.
I'm sorry to hear that you had no sleep over this. I'm getting to old for that now.
Thanks again
StainlessS
18th October 2016, 02:31
Your updated script works correctly on 32Bit. However I had to change G_ForceProcess to RT_ForceProcess for 32Bit
Sorry, keep forgetting I'm using 32bit version of G_ForceProcess.
I haven't looked for the deshaker log with your script but it seems to be analyzing the whole clip in the first pass, not just the trimmed part.
Yes of course, you should trim at beginning of script (prior to deshake, and after audiodub, so both are same), I just copied your logic, was untested.
So like so, again untested
LoadVirtualDubPlugin ("C:\Virtual Dub\plugins32\Deshaker.vdf", "deshaker", preroll=0)
FN="E:\Resolve Editing\Tasmania 2016\Raw Video\P2420153.MP4" # FN is a filename, not a clip :)
FFMS2(FN).ConvertToRGB32()
A=FFAudioSource(FN)
AudioDub(A).Trim(0,100)
DUMMY=ShakeRattleAndRoll() # Using Last as source
RT_ForceProcess(DUMMY) #
DUMMY=0 # KILL Clip, allow reopen of log file for pass=2
ShakeRattleAndRoll(Pass=2) # Source is still original Last
Return Last
I'll update your plug with both 32 and 64 bit versions, + additional RT_ functions but maybe with G_ prefix..
EDIT: I'm getting to old for that now.
Yeh, me too.
goorawin
18th October 2016, 03:57
That works really well in 32Bit
goorawin
18th October 2016, 03:59
By the way I found the log file and its the correct length now
StainlessS
18th October 2016, 07:41
Post 1 of 3
OK, try this out, DS_Tools (DeShaker Tools) AVS v2.6 only, 32 & 64 bit (~70KB incl full VS10 source + project files):-
http://www.mediafire.com/file/01ui4mco52ljkca/DS_Tools_26dll_x32x64_v0.01_20101027.zip
EDIT: Req VS2010 Runtimes.
EDIT: Link updated to v0.01 DS_Tools.
DS_Tools, 32 and 64 bit, by StainlessS @ Doom9.org. Originally prompted by this thread:- http://forum.doom9.org/showthread.php?t=173953
***
***
***
DS_ForceProcess(clip, Bool "Debug"=True)
Useful where a clip outputs some kind of file for use in a second filter, this function would in such a case
forcibly read the clip, and therefore write the file, so that it may be available to other filters or to a second pass of the filter that
initially wrote the file.
Debug, default true. Write Progress to DebugView (Google).
Returns only after completed force reading of video frames (and audio samples if any).
Returns 0.
Example, Auto 2 Pass script:-
LoadVirtualDubPlugin ("Deshaker.vdf", "deshaker", preroll=0)
FN="F:\Shaky.avi"
AviSource(FN).ConvertToRGB32.Trim(10000,-500)
DUMMY=Some2PassFunc(Pass=1) # A script function that calls Deshaker to produce log file.
DS_ForceProcess(DUMMY) # Forcibly read all frames in clip and output deshaker.log.
DUMMY=0 # KILL DUMMY clip (Call Deshaker Destructor and close deshaker.log, so that can be reopened for pass 2)
Some2PassFunc(Pass=2) # Pass 2 deshaker function.
Return Last
***
***
***
DS_TimerHP()
Returns a high precision timer (If available on your system, otherwise uses lower rez timer).
DS_TimerHP is not defined to return anything in particular, the only thing that is meaningful
is the difference between returns from 2 calls to DS_TimerHP.
Usage:
s=DS_TimerHP() Test() e=DS_TimerHP()
Str=DS_String("Test Start=%.3f End=%.3f Time=%.6f secs",s,e,e-s)
SubTitle(str)
***
***
***
DS_FilenameSplit(string filename,int "get"=15)
Splits the un-named filename string into component parts selected by 'get' bit flags arg and returns the
parts joined together.
'Get' (default 15, 1 -> 15), If set, Bit 0=DRIVE, 1=Dir, 2=Name, 4=Extension.
Add 1 for Drive (bit 0), add 2 for Dir (bit 1), add 4 for Name (bit 2), add 8 for Extension (bit 3).
Some combinations do not make sense, eg Drive + Extension (1+8=9). Below sensible options.
1 = Drive (includes trailing ':')
2 = Dir (includes trailing '\')
3 = Drive + Dir
4 = Name
6 = Dir + Name
7 = Drive + Dir + Name
8 = Extension (includes leading '.')
12 = Name + Extension
14 = Dir + Name + Extension
15 = Drive + Dir + Name + Extension
Assuming a current working directory of eg "D:\avs\avi\", 'filename'="test.avi" and 'get'=15, returns "D:\avs\avi\test.avi",
so given a relative filename and default 'get'=15, is equivalent to DS_GetFullPathName(filename).
***
***
***
DS_GetFullPathName(string "name")
Creates an absolute or full path name for the specified relative path 'name'.
eg 'DS_GetFullPathName("test.avs")' might return "D:\avs\test.avs".
Throws and error if cannot return path.
***
***
***
DS_GetFileExtension(string s)
Returns filename extension from the supplied filename, including '.' prefix.
***
***
***
DS_StrReplace(string source,string find,string replace,bool "sig"=True) # Based on Algorithm by Vampiredom, Gavino, IanB, & Martin53.
String args 'source', 'find' and 'replace' unnamed and compulsory.
Takes a source string, searches for all occurences of find string and replaces the found strings with the replace string.
Can use "" in replace string (only in replace) to delete the found substrings from the source string.
Newlines are treated no differently to other characters, and could be replaced/deleted.
sig arg, default true is Case Significant. Set false for case insignificant find string.
***
***
***
DS_String(String format, dat1,...,datn,int "Esc"=1)
Returns a formatted string. The unnamed 'format' string and optional unnamed 'dat' args are used to construct the text string that is
returned, uses C/CPP printf() style formatting.
Format: compulsory string controlling format and describing the datn type args that are expected.
datn: Variable number of data args of any type (excluding clip).
Esc: Default 1, converts embedded escape sequences in format string, 2 convert escape sequences in both format and datn strings,
0 no escape sequence conversion done.
It is necessary to specify the "Esc" name if you wish to alter default, as Avisynth cannot tell when the variable number of data datn
args ends.
You might wish to turn off escape conversion if you want to send a multi-line string to Subtitle() without conversion of '\n' to Chr(10).
printf Format spec here:- http://msdn.microsoft.com/en-us/library/56e442dc%28v=vs.71%29.aspx
NOTE, the only support for printing Bool variables is %s as string, ie prints "True" or "False".
Formatting supported %[flags] [width] [.precision] type
flags, one of "-,+,0, ,#"
width, integer, "*" supported (width supplied via dat arg).
Precision, integer, "*" supported (precision supplied via dat arg).
type,
"c,C,d,i,o,u,x,X", Integer type, c,C=character, d,i=signed, o,u,x,X=unsigned (o=octal, x=Hex).
"e,E,f,g,G", Floating point type
"s,S", String type (also Bool).
Formatting Insertion point is marked with '%' character in the format string (as in Avisynth String function), if you wish to use
a percent character within the returned string, it should be inserted twice in the format string ie '%%' will produce a single '%'.
The data datn arg strings do not require a double '%' character.
A Backslash character '\' introduces escape sequences, to insert a backslash character itself, you must supply a double
backslash sequence ie '\\'.
When 'Esc' is non zero, converts embedded escape character sequences (Case Significant):-
'\\' Converted to '\' Single Backslash
'\n' Converted to Chr(10) NewLine
'\r' Converted to Chr(13) Carriage Return
'\t' Converted to Chr(9) Horizontal TAB
'\v' Converted to Chr(11) Vertical TAB
'\f' Converted to Chr(12) FormFeed
'\b' Converted to Chr(8) BackSpace
'\a' Converted to Chr(7) Bell
'\x', where x is ANY OTHER CHARACTER not included above, will be copied verbatim, ie '\x'.
eg
DS_String("Hello there %s and %s.\nGoodbye %d.","Fred","Ted",2013)
would return same as:- "Hello there Fred and Ted." + Chr(10) + "Goodbye 2013."
Be aware that when 'Esc'=2, the string is constructed via two passes, the 1st pass inserts the data args into the format string,
2nd pass converts escape sequences, so the escape sequences could also exist in the datn args. Also, beware of constructing strings
which when joined together, form an escape sequence.
Take care when handling filenames with path backslash, suggest using default 'Esc'=1 when data datn strings contain eg Filenames.
***
***
***
DS_DebugF(string format,dat1,...,datn,string "name"="DS_DebugF:",int "TabSz"=4)
Sends a formatted string to DebugView Window. The unnamed 'format' string and optional unnamed 'dat' args are used to construct the
text string that is sent to DebugView, uses C/CPP printf() style formatting.
Format: compulsory string controlling format and describing the datn type args that are expected.
datn: Variable number of data args of any type (excluding clip).
Name, Default "DS_DebugF:". Allows you to change the default name prepended to each line of text output to DebugView Window.
TabSz, Default 4 (1 ->32). TAB step setting used for Chr(9) tab ('\t') character.
To set either Name or TabSz, you must use the named form eg Name="NewName:" or TabSz=8 as Avisynth does not know where the data args
end.
printf Format spec here:- http://msdn.microsoft.com/en-us/library/56e442dc%28v=vs.71%29.aspx
NOTE, the only support for printing Bool variables is %s as string, ie prints "True" or "False".
Formatting supported %[flags] [width] [.precision] type
flags, one of "-,+,0, ,#"
width, integer, "*" supported (width supplied via dat arg).
Precision, integer, "*" supported (precision supplied via dat arg).
type,
"c,C,d,i,o,u,x,X", Integer type, c,C=character, d,i=signed, o,u,x,X=unsigned (o=octal, x=Hex).
"e,E,f,g,G", Floating point type
"s,S", String type (also Bool).
Formatting Insertion point is marked with '%' character in the format string (as in Avisynth String function), if you wish to use
a percent character within the output string, it should be inserted twice in the format string ie '%%' will produce a single '%'.
The data datn arg strings do not require a double '%' character.
A Backslash character '\' introduces escape sequences, to insert a backslash character itself, you must supply a double
backslash sequence ie '\\'.
Converts embedded escape character sequences (Case Significant):-
'\\' Converted to '\' Single Backslash
'\n' Converted to Chr(10) NewLine
'\r' [and Chr(13)] Converted to Chr(10) NewLine
'\t' [and Chr(9)] Converted to multiple SPACE's. Horizontal TAB (Tab positions relative to name + SPACE [if not ending in SPACE])
'\x', where x is ANY OTHER CHARACTER not included above, will be copied verbatim, ie '\x'.
Escape sequences are replaced only when occurring in the format string, if you need escapes in data string then use both DS_String and
DS_DebugF functions.
Example:
DS_DebugF("Hello there %s and %s.\nGoodbye %d.","Fred","Ted",2013)
would output same as:- "Hello there Fred and Ted." + Chr(10) + "Goodbye 2013."
***
***
***
DS_WriteFile(String FileName, string format,dat1,...,datn,bool "Append"=False)
Writes a formatted string to FileName file. The unnamed 'format' string and optional unnamed 'dat' args are used to construct the
text string that is written, uses C/CPP printf() style formatting.
Format: compulsory string controlling format and describing the datn type args that are expected.
datn: Variable number of data args of any type (excluding clip).
Append, Default False, optional and MUST be supplied with name (eg Append=True) as we do not know where optional data args end,
Appends to file if already exists, else opens new FileName.
printf Format spec here:- http://msdn.microsoft.com/en-us/library/56e442dc%28v=vs.71%29.aspx
NOTE, the only support for printing Bool variables is %s as string, ie prints "True" or "False".
Formatting supported %[flags] [width] [.precision] type
flags, one of "-,+,0, ,#"
width, integer, "*" supported (width supplied via dat arg).
Precision, integer, "*" supported (precision supplied via dat arg).
type,
"c,C,d,i,o,u,x,X", Integer type, c,C=character, d,i=signed, o,u,x,X=unsigned (o=octal, x=Hex).
"e,E,f,g,G", Floating point type
"s,S", String type (also Bool).
Formatting Insertion point is marked with '%' character in the format string (as in Avisynth String function), if you wish to use
a percent character within the output string, it should be inserted twice in the format string ie '%%' will produce a single '%'.
The data datn arg strings do not require a double '%' character.
A Backslash character '\' introduces escape sequences, to insert a backslash character itself, you must supply a double
backslash sequence ie '\\'.
Converts embedded escape character sequences (Case Significant):-
'\\' Converted to '\' Single Backslash
'\a' Converted to Chr(7)
'\b' Converted to Chr(8)
'\t' Converted to Chr(9)
'\n' Converted to Chr(10) NewLine
'\r' [and Chr(13)] Converted to Chr(10) NewLine
'\v' Converted to Chr(11)
'\f' Converted to Chr(12)
'\x', where x is ANY OTHER CHARACTER not included above, will be copied verbatim, ie '\x'.
Escape sequences are replaced only when occurring in the format string, if you need escapes in data string then use DS_String.
Example:
DS_WriteFile(FileName,"Hello there %s and %s.\nGoodbye %d.","Fred","Ted",2013,Append=False)
EDIT: Added
DS_Sleep(Float time)
time in seconds, 0.0 -> 60.0. Silently limited to that range. Accurate to about 0.001 seconds.
DS_Sleep(0.0) would not sleep for any specific time, it would just give opportunity to any waiting
tasks to do a bit of processing, before returning to the current task.
StainlessS
18th October 2016, 07:45
Post 2 of 3
Req DS_Tools as posted in previous post (no other requirement [EDIT: Except of course VDub DeShaker.vdf by Gunnar Thalin]).
Updated script [EDIT: Stub, As per your original Deshaker string]
LoadVirtualDubPlugin ("Deshaker.vdf", "deshaker", preroll=0)
FN="F:\V\CabaretUnCropped.avi"
AviSource(FN).ConvertToRGB32.Trim(10000,-500)
#LogFile=DS_FilenameSplit(FN,get=12)+".log" # 12 = Name.Ext.log (No Dir/Path, In Current script directory)
#LogFile=DS_FilenameSplit(FN,get=4)+".Log" # 4 = Name.log (No Dir/Path/Ext, In Current script directory)
LogFile=FN+".Log" # FullFilename+.log (in original clip directory if DIR/Path supplied)
GoorawinStub(LogFile=LogFile) # By default, Auto two pass
Return Last
###########
Function GoorawinStub(clip c,Int "Pass",String "LogFile",Bool "Auto",Bool "Debug") {
/*
EdgeCompensation =4 (p19, default 0, Pass 2, Adaptive zoom average + fixed zoom)
MaxCorrectionLimitsHorizontalPanning=8.0 (p40, default 15.0, Pass=2,
MaxCorrectionLimitsVerticalPanning =8.0 (p41, default 15.0, Pass=2,
MaxCorrectionLimitsRotation =3.0 (p42, default 5.0, Pass=2,
MaxCorrectionLimitsZoom =8.0 (p43, default 15.0, Pass=2,
CamcorderHasARollingShutter =True (p50, Default 0, Pass=1&2 (Func arg Bool)
RollingShutterAmount =90.0 (p58, Default 88.0 Pass 1&2
*/
ShakeRattleAndRoll(c,Pass,
\ EdgeCompensation=4,MaxCorrectionLimitsHorizontalPanning=8.0,MaxCorrectionLimitsVerticalPanning=8.0,
\ MaxCorrectionLimitsRotation=3.0,MaxCorrectionLimitsZoom=8.0,CamcorderHasARollingShutter=True,RollingShutterAmount=90.0,
\ LogFile=LogFile,Auto=Auto,Debug=Debug)
}
Function ShakeRattleAndRoll(clip c,Int "Pass",Int "BlockSize",Int "DifferentialSearchRange",
\ Float "SourcePixelAspectValue",Int "SourcePixelAspectSelection",
\ Float "DestinationPixelAspectValue",Int "DestinationPixelAspectSelection",
\ Int "DestinationWidth",Int "DestinationHeight",Int "Scale",Int "UsePixels",
\ Int "MotionSmoothnessHorizontalPanning",Int "MotionSmoothnessVerticalPanning",Int "MotionSmoothnessRotation",
\ Int "MotionSmoothnessZoom",Float "DiscardMotionOfXBlocks",Int "VideoOutput",Int "EdgeCompensation",Int "Resampling",
\ Float "SkipFrameIfLessThanXPercentOfBlocksOk",Int "InitialSearchRange",
\ Float "DiscardMotionOfBlocksMatchingValueLessThanX",Float "DiscardMotionOfBlocksThatHave2ndBestMatchLargerThanBestMinusX",
\ String "LogFile",Bool "AppendToFile",
\ Bool "IgnorePixelsOutside",Int "IgnorePixelsOutsideLeft",Int "IgnorePixelsOutsideRight",Int "IgnorePixelsOutsideTop",
\ Int "IgnorePixelsOutsideBottom",
\ Bool "IgnorePixelsInside",Int "IgnorePixelsInsideLeft",Int "IgnorePixelsInsideRight",Int "IgnorePixelsInsideTop",
\ Int "IgnorePixelsInsideBottom",Bool "VideoTypeInterlaced",Bool "VideoTypeUpperFieldFirst",
\ Float "ExtraZoomFactor",Float "MaxCorrectionLimitsHorizontalPanning",Float "MaxCorrectionLimitsVerticalPanning",
\ Float "MaxCorrectionLimitsRotation",Float "MaxCorrectionLimitsZoom",
\ Bool "UsePreviousAndFutureFramesToFillInBordersPreviousFramesEnabled",Bool "UsePreviousAndFutureFramesToFillInBordersFutureFramesEnabled",
\ Int "UsePreviousAndFutureFramesToFillInBordersPreviousFrames",Int "UsePreviousAndFutureFramesToFillInBordersFutureFrames",
\ Bool "IgnorePixelsOutside_LetAreaFollowMotion",Int "DeepAnalysisIfLessThanXPercentOfVectorsAreOk",
\ Bool "CamcorderHasARollingShutter",Bool "GenerateInterlacedProgressiveVideo",Bool "SameDestinationPropertiesAsSource",
\ Bool "SoftBorders",Bool "ExtrapolateColorsIntoBorder",Int "SoftBorders_EdgeTransitionWidth",
\ Float "DiscardMotionOfBlocksThatMoveMoreThanXPixels",Bool "RememberDiscardedAreasToNextFrame",
\ Float "RollingShutterAmount",Bool "DetectRotation",Bool "DetectZoom",Float "DetectScenes_Threshold",
\ Float "AdaptiveZoomSmoothness",Float "AdaptiveZoomAmount",Int "DiscardMotionOfBlocksThatHaveMaximumPixelValueDifferenceLessThanX",
\ Bool "DetectScenes",Bool "UseColorMask",Int "MaskColorInHexRRGGBB",
\ Bool "Auto", Bool "Debug") {
/*
Can set Aspect Ratios directly using eg SourcePixelAspectValue=1.333 or by GUI index SourcePixelAspectSelection[0->7]
*/
myName="ShakeRattleAndRoll: "
c
Assert(IsRGB,DS_string("%sClip Must be RGB",myName)) # Client MUST convert to RGB using whatever matrix and also Interlacing.
DSVersion = 19 # Fixed by DeShaker.vdf, Need modify if new version of dll
Pass=Default(Pass,1)
Assert(Pass==1 || Pass==2, DS_String("%s Pass 1 or 2 Only(%d)",myName,Pass))
BlockSize=Default(BlockSize,30)
Assert(BlockSize>=1 && BlockSize<=100, DS_String("%s BlockSize 1 -> 100 Only(%d)",myName,BlockSize))
DifferentialSearchRange=Default(DifferentialSearchRange,4)
Assert(DifferentialSearchRange>=1, DS_String("%s 1 < DifferentialSearchRange(%d)",myName,DifferentialSearchRange))
### GUI ### SourcePixelAspectValue OverRides GUI selection if given as arg, Otherwise uses GUI SourcePixelAspectSelection[0->7] default 0=1:1.
DefV=Defined(SourcePixelAspectValue)
SourcePixelAspectSelection = (DefV) ? -1 : Max(Default(SourcePixelAspectSelection,0),0)
Assert(-1 <= SourcePixelAspectSelection && SourcePixelAspectSelection <= 7, DS_String("%s -1 <= SourcePixelAspectSelection <= 7(%d)",
\ myName,SourcePixelAspectSelection))
SourcePixelAspectValue = (DefV) ? Float(SourcePixelAspectValue)
\ : Select(SourcePixelAspectSelection,1.0,1.09259,0.909091,1.45679,1.21212,1.63889,1.36364,1.33333)
Assert(0.0 < SourcePixelAspectValue, DS_String("%s 0.0 < SourcePixelAspectValue(%f)",myName,SourcePixelAspectValue))
### Param 52, MUST Process out-of-param-sequence
SameDestinationPropertiesAsSource=Default(SameDestinationPropertiesAsSource,true)
### GUI SameDestinationPropertiesAsSource OVERRIDES ALL, otherwise DestinationPixelAspectValue OverRides GUI selection if given as arg
DefV=Defined(DestinationPixelAspectValue)
DestinationPixelAspectSelection=(SameDestinationPropertiesAsSource)?SourcePixelAspectSelection:(DefV)?-1:Max(Default(DestinationPixelAspectSelection,0),0)
Assert(-1 <= DestinationPixelAspectSelection && DestinationPixelAspectSelection <= 7,
\ DS_String("%s -1 <= DestinationPixelAspectSelection <= 7(%d)",myName,DestinationPixelAspectSelection))
DestinationPixelAspectValue = (SameDestinationPropertiesAsSource) ? SourcePixelAspectValue : (DefV) ? Float(DestinationPixelAspectValue)
\ : Select(DestinationPixelAspectSelection,1.0,1.09259,0.909091,1.45679,1.21212,1.63889,1.36364,1.33333)
Assert(0.0 <= DestinationPixelAspectValue, DS_String("%s 0.0 <= DestinationPixelAspectValue(%f)",myName,DestinationPixelAspectValue))
###
DestinationWidth = (SameDestinationPropertiesAsSource) ? Width : Default(DestinationWidth, 640)
DestinationHeight = (SameDestinationPropertiesAsSource) ? Height : Default(DestinationHeight,480)
Assert(DestinationWidth>=1, DS_String("%s 1 <= DestinationWidth(%d)",myName,DestinationWidth))
Assert(DestinationHeight>=1, DS_String("%s 1 <= DestinationHeight(%d)",myName,DestinationHeight))
### End of Source/Dest Same as stuff
Scale=Default(Scale,1)
Assert(0 <= Scale, DS_String("%s 0 <= Scale(%d)",myName,Scale))
UsePixels=Default(UsePixels,2)
Assert(1 <= UsePixels <=4, DS_String("%s 1 <= UsePixels <= 4(%d)",myName,UsePixels))
MotionSmoothnessHorizontalPanning=Default(MotionSmoothnessHorizontalPanning,1000)
Assert(1 <= MotionSmoothnessHorizontalPanning, DS_String("%s 1 <= MotionSmoothnessHorizontalPanning(%d)",
\ myName,MotionSmoothnessHorizontalPanning))
MotionSmoothnessVerticalPanning=Default(MotionSmoothnessVerticalPanning,1000)
Assert(1 <= MotionSmoothnessVerticalPanning, DS_String("%s 1 <= MotionSmoothnessVerticalPanning(%d)",myName,MotionSmoothnessVerticalPanning))
MotionSmoothnessRotation=Default(MotionSmoothnessRotation,1000)
Assert(1 <= MotionSmoothnessRotation, DS_String("%s 1 <= MotionSmoothnessRotation(%d)",myName,MotionSmoothnessRotation))
MotionSmoothnessZoom=Default(MotionSmoothnessZoom,1000)
Assert(1 <= MotionSmoothnessZoom, DS_String("%s 1 <= MotionSmoothnessZoom(%d)",myName,MotionSmoothnessZoom))
DiscardMotionOfXBlocks=Float(Default(DiscardMotionOfXBlocks,4.0))
Assert(0.0 < DiscardMotionOfXBlocks, DS_String("%s 0.0 <= DiscardMotionOfXBlocks(%f)",myName,DiscardMotionOfXBlocks))
VideoOutput=Default(VideoOutput,1)
Assert(0 <= VideoOutput <=3, DS_String("%s 0 <= VideoOutput <= 3(%d)",myName,VideoOutput))
EdgeCompensation=Default(EdgeCompensation,0)
Assert(EdgeCompensation==0||EdgeCompensation==1||EdgeCompensation==3||EdgeCompensation==4||EdgeCompensation==6,
\ DS_String("%s EdgeCompensation 0,1,3,4 or 6 only(%d)",myName,EdgeCompensation))
Resampling=Default(Resampling,2)
Assert(0 <= Resampling <= 2, DS_String("%s 0 <= Resampling <= 2(%d)",myName,Resampling))
SkipFrameIfLessThanXPercentOfBlocksOk=Float(Default(SkipFrameIfLessThanXPercentOfBlocksOk,8.0))
Assert(0.0 <= SkipFrameIfLessThanXPercentOfBlocksOk <= 100.0, DS_String("%s 0.0 <= SkipFrameIfLessThanXPercentOfBlocksOk <= 100.0(%f)",
\ myName,SkipFrameIfLessThanXPercentOfBlocksOk))
InitialSearchRange=Default(InitialSearchRange,30)
Assert(1 <= InitialSearchRange <= 99, DS_String("%s 1 <= InitialSearchRange <= 99(%d)",myName,InitialSearchRange))
DiscardMotionOfBlocksMatchingValueLessThanX=Float(Default(DiscardMotionOfBlocksMatchingValueLessThanX,300.0))
Assert(-1000.0 <= DiscardMotionOfBlocksMatchingValueLessThanX <= 1000.0,
\ DS_String("%s -1000.0 <= DiscardMotionOfBlocksMatchingValueLessThanX <= 1000.0(%f)",
\ myName,DiscardMotionOfBlocksMatchingValueLessThanX))
DiscardMotionOfBlocksThatHave2ndBestMatchLargerThanBestMinusX=Float(Default(DiscardMotionOfBlocksThatHave2ndBestMatchLargerThanBestMinusX,4.0))
Assert(0.0 <= DiscardMotionOfBlocksThatHave2ndBestMatchLargerThanBestMinusX,
\ DS_String("%s 0.0 <= DiscardMotionOfBlocksThatHave2ndBestMatchLargerThanBestMinusX(%f)",
\ myName,DiscardMotionOfBlocksThatHave2ndBestMatchLargerThanBestMinusX))
LogFile=Default(LogFile,"ShakeRattleAndRoll.Log")
Assert(LogFile!="",DS_String("%sLogfile Cannot be Empty string",myName))
LogFile=DS_GetFullPathName(LogFile)
Assert(Pass==1||Exist(LogFile),DS_String("%sPass 2 Logfile Does NOT Exist(%s)",myName,LogFile))
LogFile=DS_StrReplace(LogFile,"\","\\")
AppendToFile=Default(AppendToFile,False)
Updated, Post #10 NOTES updated
StainlessS
18th October 2016, 07:45
post 3 of 3
IgnorePixelsOutside=Default(IgnorePixelsOutside,False)
IgnorePixelsOutsideLeft=Default(IgnorePixelsOutsideLeft,0)
IgnorePixelsOutsideRight=Default(IgnorePixelsOutsideRight,0)
IgnorePixelsOutsideTop=Default(IgnorePixelsOutsideTop,0)
IgnorePixelsOutsideBottom=Default(IgnorePixelsOutsideBottom,0)
IgnorePixelsInside=Default(IgnorePixelsInside,False)
IgnorePixelsInsideLeft=Default(IgnorePixelsInsideLeft,0)
IgnorePixelsInsideRight=Default(IgnorePixelsInsideRight,0)
IgnorePixelsInsideTop=Default(IgnorePixelsInsideTop,0)
IgnorePixelsInsideBottom=Default(IgnorePixelsInsideBottom,0)
VideoTypeInterlaced=Default(VideoTypeInterlaced,False)
VideoTypeUpperFieldFirst=Default(VideoTypeUpperFieldFirst,False)
ExtraZoomFactor=Float(Default(ExtraZoomFactor,1.0))
Assert(0.0 < ExtraZoomFactor, DS_String("%s 0.0 < ExtraZoomFactor(%f)",myName,ExtraZoomFactor))
MaxCorrectionLimitsHorizontalPanning=Float(Default(MaxCorrectionLimitsHorizontalPanning,15.0))
Assert(1.0 <= MaxCorrectionLimitsHorizontalPanning, DS_String("%s 1.0 <= MaxCorrectionLimitsHorizontalPanning(%f)",
\ myName,MaxCorrectionLimitsHorizontalPanning))
MaxCorrectionLimitsVerticalPanning=Float(Default(MaxCorrectionLimitsVerticalPanning,15.0))
Assert(1.0 <= MaxCorrectionLimitsVerticalPanning, DS_String("%s 1.0 <= MaxCorrectionLimitsVerticalPanning(%f)",
\ myName,MaxCorrectionLimitsVerticalPanning))
MaxCorrectionLimitsRotation=Float(Default(MaxCorrectionLimitsRotation,5.0))
Assert(1.0 <= MaxCorrectionLimitsRotation, DS_String("%s 1.0 <= MaxCorrectionLimitsRotation(%f)",myName,MaxCorrectionLimitsRotation))
MaxCorrectionLimitsZoom=Float(Default(MaxCorrectionLimitsZoom,15.0))
Assert(1.0 <= MaxCorrectionLimitsZoom, DS_String("%s 1.0 <= MaxCorrectionLimitsZoom(%f)",myName,MaxCorrectionLimitsZoom))
UsePreviousAndFutureFramesToFillInBordersPreviousFramesEnabled=Default(UsePreviousAndFutureFramesToFillInBordersPreviousFramesEnabled,False)
UsePreviousAndFutureFramesToFillInBordersFutureFramesEnabled=Default(UsePreviousAndFutureFramesToFillInBordersFutureFramesEnabled,False)
UsePreviousAndFutureFramesToFillInBordersPreviousFrames=Default(UsePreviousAndFutureFramesToFillInBordersPreviousFrames,30)
Assert(0 <= UsePreviousAndFutureFramesToFillInBordersPreviousFrames,
\ DS_String("%s 0 <= UsePreviousAndFutureFramesToFillInBordersPreviousFrames(%d)",
\ myName,UsePreviousAndFutureFramesToFillInBordersPreviousFrames))
UsePreviousAndFutureFramesToFillInBordersFutureFrames=Default(UsePreviousAndFutureFramesToFillInBordersFutureFrames,30)
Assert(0 <= UsePreviousAndFutureFramesToFillInBordersFutureFrames,
\ DS_String("%s 0 <= UsePreviousAndFutureFramesToFillInBordersFutureFrames(%d)",
\ myName,UsePreviousAndFutureFramesToFillInBordersFutureFrames))
IgnorePixelsOutside_LetAreaFollowMotion=Default(IgnorePixelsOutside_LetAreaFollowMotion,False)
DeepAnalysisIfLessThanXPercentOfVectorsAreOk=Default(DeepAnalysisIfLessThanXPercentOfVectorsAreOk,0)
Assert(0<=DeepAnalysisIfLessThanXPercentOfVectorsAreOk && DeepAnalysisIfLessThanXPercentOfVectorsAreOk<=100,
\ DS_String("%s 0 <= DeepAnalysisIfLessThanXPercentOfVectorsAreOk <= 100(%d)",myName,DeepAnalysisIfLessThanXPercentOfVectorsAreOk))
CamcorderHasARollingShutter=Default(CamcorderHasARollingShutter,false)
GenerateInterlacedProgressiveVideo=Default(GenerateInterlacedProgressiveVideo,false)
SoftBorders=Default(SoftBorders,false)
ExtrapolateColorsIntoBorder=Default(ExtrapolateColorsIntoBorder,false)
SoftBorders_EdgeTransitionWidth=Default(SoftBorders_EdgeTransitionWidth,10)
Assert(0<=SoftBorders_EdgeTransitionWidth, DS_String("%s 0 <= SoftBorders_EdgeTransitionWidth(%d)",myName,SoftBorders_EdgeTransitionWidth))
DiscardMotionOfBlocksThatMoveMoreThanXPixels=Float(Default(DiscardMotionOfBlocksThatMoveMoreThanXPixels,1000.0))
Assert(0.0<SoftBorders_EdgeTransitionWidth, DS_String("%s 0.0 < DiscardMotionOfBlocksThatMoveMoreThanXPixels(%f)",
\ myName,DiscardMotionOfBlocksThatMoveMoreThanXPixels))
RememberDiscardedAreasToNextFrame=Default(RememberDiscardedAreasToNextFrame,true)
RollingShutterAmount=Float(Default(RollingShutterAmount,88.0)) ##### Any Value ???
DetectRotation=Default(DetectRotation,true)
DetectZoom=Default(DetectZoom,true)
DetectScenes_Threshold=Float(Default(DetectScenes_Threshold,20.0))
Assert(0.0<=DetectScenes_Threshold && DetectScenes_Threshold <= 1000.0, DS_String("%s 0.0 <= DetectScenes_Threshold <= 1000.0(%f)",
\ myName,DetectScenes_Threshold))
AdaptiveZoomSmoothness=Float(Default(AdaptiveZoomSmoothness,5000.0))
Assert(0.0<AdaptiveZoomSmoothness, DS_String("%s 0.0 < DetectScenes_Threshold(%f)",myName,AdaptiveZoomSmoothness))
AdaptiveZoomAmount=Float(Default(AdaptiveZoomAmount,100.0)) ##### Any Value ???
DiscardMotionOfBlocksThatHaveMaximumPixelValueDifferenceLessThanX=Default(DiscardMotionOfBlocksThatHaveMaximumPixelValueDifferenceLessThanX,20)
Assert(0<=DiscardMotionOfBlocksThatHaveMaximumPixelValueDifferenceLessThanX&&DiscardMotionOfBlocksThatHaveMaximumPixelValueDifferenceLessThanX<=255,
\ DS_String("%s0 <= DiscardMotionOfBlocksThatHaveMaximumPixelValueDifferenceLessThanX <= 255(%d)",
\ myName,DiscardMotionOfBlocksThatHaveMaximumPixelValueDifferenceLessThanX))
DetectScenes=Default(DetectScenes,true)
UseColorMask=Default(UseColorMask,false)
MaskColorInHexRRGGBB=BitAnd(Default(MaskColorInHexRRGGBB,$FF00FF),$FFFFFF)
#########
Auto=Default(Auto,Pass==1) # Default True if Pass==1 or False if Pass==2
Assert(Pass==1 || !Auto,DS_String("%sCannot use Auto=True if Pass==2",myName))
Debug=Default(Debug,True)
#########
Fmt1="%d|%d"
Fmt2="|%d|%d|%f|%d|%f|%d|%d|%d|%d|%d|%d|%d|%d|%d|%f|%d|%d|%d|%f|%d|%f|%f|" +
\ "%s|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%f|%f|%f|%f|%f|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%f|%d|%f|%d|%d|%f|%f|%f|%d|%d|%d|%x"
S1=DS_String(Fmt1,DSVersion,Pass)
S2=DS_String(Fmt2,
\ BlockSize,DifferentialSearchRange,
\ SourcePixelAspectValue,SourcePixelAspectSelection,
\ DestinationPixelAspectValue,DestinationPixelAspectSelection,
\ DestinationWidth,DestinationHeight,Scale,UsePixels,
\ MotionSmoothnessHorizontalPanning,MotionSmoothnessVerticalPanning,MotionSmoothnessRotation,MotionSmoothnessZoom,
\ DiscardMotionOfXBlocks,VideoOutput,EdgeCompensation,Resampling,
\ SkipFrameIfLessThanXPercentOfBlocksOk,InitialSearchRange,
\ DiscardMotionOfBlocksMatchingValueLessThanX,DiscardMotionOfBlocksThatHave2ndBestMatchLargerThanBestMinusX,
\ LogFile,AppendToFile?1:0,
\ IgnorePixelsOutside?1:0,IgnorePixelsOutsideLeft,IgnorePixelsOutsideRight,IgnorePixelsOutsideTop,IgnorePixelsOutsideBottom,
\ IgnorePixelsInside?1:0,IgnorePixelsInsideLeft,IgnorePixelsInsideRight,IgnorePixelsInsideTop,IgnorePixelsInsideBottom,
\ VideoTypeInterlaced?1:0,VideoTypeUpperFieldFirst?1:0,
\ ExtraZoomFactor,MaxCorrectionLimitsHorizontalPanning,MaxCorrectionLimitsVerticalPanning,
\ MaxCorrectionLimitsRotation,MaxCorrectionLimitsZoom,
\ UsePreviousAndFutureFramesToFillInBordersPreviousFramesEnabled?1:0,UsePreviousAndFutureFramesToFillInBordersFutureFramesEnabled?1:0,
\ UsePreviousAndFutureFramesToFillInBordersPreviousFrames,UsePreviousAndFutureFramesToFillInBordersFutureFrames,
\ IgnorePixelsOutside_LetAreaFollowMotion?1:0,DeepAnalysisIfLessThanXPercentOfVectorsAreOk,
\ CamcorderHasARollingShutter?1:0,GenerateInterlacedProgressiveVideo?1:0,SameDestinationPropertiesAsSource?1:0,
\ SoftBorders?1:0,ExtrapolateColorsIntoBorder?1:0,SoftBorders_EdgeTransitionWidth,
\ DiscardMotionOfBlocksThatMoveMoreThanXPixels,RememberDiscardedAreasToNextFrame?1:0,
\ RollingShutterAmount,DetectRotation?1:0,DetectZoom?1:0,DetectScenes_Threshold,
\ AdaptiveZoomSmoothness,AdaptiveZoomAmount,DiscardMotionOfBlocksThatHaveMaximumPixelValueDifferenceLessThanX,
\ DetectScenes?1:0,UseColorMask?1:0,MaskColorInHexRRGGBB
\ )
DBUG = FALSE # Used during debugging
S=S1+S2
Fn=DS_String("ShakeRattleAndRoll_Debug_%d.txt",Pass)
(Debug) ? DS_DebugF("%s",S,name=myName) : NOP
(Debug&&DBUG) ? DS_WriteFile(Fn,"%s",S) : NOP
Tmp=Deshaker(S)
(Auto) ? DS_ForceProcess(Tmp) : NOP
(Auto) ? Last : Tmp # If NOT Auto, then we return result of previous DeShaker(Pass=Whatever).
Tmp = 0 # If Auto, Force closure of tmp, allow reopen of log file for pass=2.
Fn=(Auto) ? "ShakeRattleAndRoll_Debug_2.txt" : Fn
S =(Auto) ? DS_String(Fmt1,DSVersion,2)+S2 : S
(Auto&&Debug) ? DS_DebugF("%s",S,name=myName) : NOP
(Auto&&Debug&&DBUG) ? DS_WriteFile(Fn,"%s",S) : NOP
(Auto) ? Deshaker(S) : NOP
Return Last
}
Updated, post 10 notes updated.
StainlessS
18th October 2016, 11:12
Posts 10, 18 and 19 updated.
goorawin
18th October 2016, 11:23
Both are now working.
The 64Bit came up with an error at first, but after replacing about four RT_String with DS_String all was well.
Now I have to get my head around an easy way to put in the deshaker preset.
Once I do that I will do some serious testing and see if my prediction of a 30 to 40% gain is achievable.
Anyway thank you so much for all your efforts. It would be great if I could give you something for all your work, just let me know.
StainlessS
18th October 2016, 11:30
Oops, sorry, updated.
And I thought fags were a hard habit to break.
[EDIT: For our USA colony, In English, 'fag'=Finely ground tobacco wrapped in paper; for smoking]
give you something for all your work
Nope, Enjoy :)
EDIT: Are there any other RT_ funcs that you would like included in DS_
(dont say all of them, and not counting eg RT_AverageLuma or other raster functions, nor DBase/Array funcs).
Maybe File delete, copy, rename, or some others ?
StainlessS
19th October 2016, 05:34
Post #1 of 3.
Now I have to get my head around an easy way to put in the deshaker preset.
Allow me to save you the bother (well some of it).
ShakeRattleAndRoll() update, Part 1,
Function ShakeRattleAndRoll(clip c,Int "Pass",Int "BlockSize",Int "DifferentialSearchRange",
\ Float "SourcePixelAspectValue",Int "SourcePixelAspectSelection",
\ Float "DestinationPixelAspectValue",Int "DestinationPixelAspectSelection",
\ Int "DestinationWidth",Int "DestinationHeight",Int "Scale",Int "UsePixels",
\ Int "MotionSmoothnessHorizontalPanning",Int "MotionSmoothnessVerticalPanning",Int "MotionSmoothnessRotation",
\ Int "MotionSmoothnessZoom",Float "DiscardMotionOfXBlocks",Int "VideoOutput",Int "EdgeCompensation",Int "Resampling",
\ Float "SkipFrameIfLessThanXPercentOfBlocksOk",Int "InitialSearchRange",
\ Float "DiscardMotionOfBlocksMatchingValueLessThanX",Float "DiscardMotionOfBlocksThatHave2ndBestMatchLargerThanBestMinusX",
\ String "LogFile",Bool "AppendToFile",
\ Bool "IgnorePixelsOutside",Int "IgnorePixelsOutsideLeft",Int "IgnorePixelsOutsideRight",Int "IgnorePixelsOutsideTop",
\ Int "IgnorePixelsOutsideBottom",
\ Bool "IgnorePixelsInside",Int "IgnorePixelsInsideLeft",Int "IgnorePixelsInsideRight",Int "IgnorePixelsInsideTop",
\ Int "IgnorePixelsInsideBottom",Bool "VideoTypeInterlaced",Bool "VideoTypeUpperFieldFirst",
\ Float "ExtraZoomFactor",Float "MaxCorrectionLimitsHorizontalPanning",Float "MaxCorrectionLimitsVerticalPanning",
\ Float "MaxCorrectionLimitsRotation",Float "MaxCorrectionLimitsZoom",
\ Bool "UsePreviousAndFutureFramesToFillInBordersPreviousFramesEnabled",Bool "UsePreviousAndFutureFramesToFillInBordersFutureFramesEnabled",
\ Int "UsePreviousAndFutureFramesToFillInBordersPreviousFrames",Int "UsePreviousAndFutureFramesToFillInBordersFutureFrames",
\ Bool "IgnorePixelsOutside_LetAreaFollowMotion",Int "DeepAnalysisIfLessThanXPercentOfVectorsAreOk",
\ Bool "CamcorderHasARollingShutter",Bool "GenerateInterlacedProgressiveVideo",Bool "SameDestinationPropertiesAsSource",
\ Bool "SoftBorders",Bool "ExtrapolateColorsIntoBorder",Int "SoftBorders_EdgeTransitionWidth",
\ Float "DiscardMotionOfBlocksThatMoveMoreThanXPixels",Bool "RememberDiscardedAreasToNextFrame",
\ Float "RollingShutterAmount",Bool "DetectRotation",Bool "DetectZoom",Float "DetectScenes_Threshold",
\ Float "AdaptiveZoomSmoothness",Float "AdaptiveZoomAmount",Int "DiscardMotionOfBlocksThatHaveMaximumPixelValueDifferenceLessThanX",
\ Bool "DetectScenes",Bool "UseColorMask",Int "MaskColorInHexRRGGBB",
\ Bool "Auto", Bool "Debug") {
/*
Can set Aspect Ratios directly using eg SourcePixelAspectValue=1.333 or by GUI index SourcePixelAspectSelection[0->7]
*/
Function f2ip(Float f) {return (int(f)==f) ? 0 : 6}
myName="ShakeRattleAndRoll: "
c
Assert(IsRGB32,DS_string("%sClip Must be RGB32",myName)) # Client MUST convert to RGB32 using whatever matrix and also Interlacing.
DSVersion = 19 # Fixed by DeShaker.vdf, Need modify if new version of dll
Pass=Default(Pass,1)
Assert(1<=Pass<=2, DS_String("%sPass 1 or 2 Only(%d)",myName,Pass))
BlockSize=Default(BlockSize,30)
Assert(1<=BlockSize<=100, DS_String("%s1 <= BlockSize <= 100 Only(%d)",myName,BlockSize))
DifferentialSearchRange=Default(DifferentialSearchRange,4)
Assert(1<=DifferentialSearchRange, DS_String("%s1 <= DifferentialSearchRange(%d)",myName,DifferentialSearchRange))
### GUI ### SourcePixelAspectValue OverRides GUI selection if given as arg, Otherwise uses GUI SourcePixelAspectSelection[0->7] default 0=1:1.
DefV=Defined(SourcePixelAspectValue)
SourcePixelAspectSelection = (DefV) ? -1 : Max(Default(SourcePixelAspectSelection,0),0)
Assert(-1<=SourcePixelAspectSelection<=7, DS_String("%s-1 <= SourcePixelAspectSelection <= 7(%d)", myName,SourcePixelAspectSelection))
SourcePixelAspectValue = (DefV) ? Float(SourcePixelAspectValue)
\ : Select(SourcePixelAspectSelection,1.0,1.09259,0.909091,1.45679,1.21212,1.63889,1.36364,1.33333)
Assert(0.0<SourcePixelAspectValue,DS_String("%s0.0 < SourcePixelAspectValue(%f)",myName,SourcePixelAspectValue))
### Param 52, MUST Process out-of-param-sequence
SameDestinationPropertiesAsSource=Default(SameDestinationPropertiesAsSource,true)
### GUI SameDestinationPropertiesAsSource OVERRIDES ALL, otherwise DestinationPixelAspectValue OverRides GUI selection if given as arg
DefV=Defined(DestinationPixelAspectValue)
DestinationPixelAspectSelection=(SameDestinationPropertiesAsSource)?SourcePixelAspectSelection:(DefV)?-1:Max(Default(DestinationPixelAspectSelection,0),0)
Assert(-1<=DestinationPixelAspectSelection<=7,
\ DS_String("%s-1 <= DestinationPixelAspectSelection <= 7(%d)",myName,DestinationPixelAspectSelection))
DestinationPixelAspectValue = (SameDestinationPropertiesAsSource) ? SourcePixelAspectValue : (DefV) ? Float(DestinationPixelAspectValue)
\ : Select(DestinationPixelAspectSelection,1.0,1.09259,0.909091,1.45679,1.21212,1.63889,1.36364,1.33333)
Assert(0.0<DestinationPixelAspectValue, DS_String("%s0.0 < DestinationPixelAspectValue(%f)",myName,DestinationPixelAspectValue))
###
DestinationWidth = (SameDestinationPropertiesAsSource) ? Width : Default(DestinationWidth, 640)
DestinationHeight = (SameDestinationPropertiesAsSource) ? Height : Default(DestinationHeight,480)
Assert(1<=DestinationWidth, DS_String("%s1 <= DestinationWidth(%d)",myName,DestinationWidth))
Assert(1<=DestinationHeight,DS_String("%s1 <= DestinationHeight(%d)",myName,DestinationHeight))
### End of Source/Dest Same as stuff
Scale=Default(Scale,1)
Assert(0<=Scale<=2, DS_String("%s0 <= Scale <=2(%d)",myName,Scale))
UsePixels=Default(UsePixels,2)
Assert(1<=UsePixels<=4, DS_String("%s1 <= UsePixels <= 4(%d)",myName,UsePixels))
MotionSmoothnessHorizontalPanning=Default(MotionSmoothnessHorizontalPanning,1000)
Assert(-1<=MotionSmoothnessHorizontalPanning, DS_String("%s-1 <= MotionSmoothnessHorizontalPanning(%d)",myName,MotionSmoothnessHorizontalPanning))
MotionSmoothnessVerticalPanning=Default(MotionSmoothnessVerticalPanning,1000)
Assert(-1<=MotionSmoothnessVerticalPanning, DS_String("%s-1 <= MotionSmoothnessVerticalPanning(%d)",myName,MotionSmoothnessVerticalPanning))
MotionSmoothnessRotation=Default(MotionSmoothnessRotation,1000)
Assert(-1<=MotionSmoothnessRotation,DS_String("%s-1 <= MotionSmoothnessRotation(%d)",myName,MotionSmoothnessRotation))
MotionSmoothnessZoom=Default(MotionSmoothnessZoom,1000)
Assert(-1<=MotionSmoothnessZoom, DS_String("%s-1 <= MotionSmoothnessZoom(%d)",myName,MotionSmoothnessZoom))
DiscardMotionOfXBlocks=Float(Default(DiscardMotionOfXBlocks,4.0))
Assert(0.0<DiscardMotionOfXBlocks,DS_String("%s0.0 < DiscardMotionOfXBlocks(%f)",myName,DiscardMotionOfXBlocks))
VideoOutput=Default(VideoOutput,1)
Assert(0<=VideoOutput<=3, DS_String("%s0 <= VideoOutput <= 3(%d)",myName,VideoOutput))
EdgeCompensation=Default(EdgeCompensation,0)
Assert(EdgeCompensation==0||EdgeCompensation==1||EdgeCompensation==3||EdgeCompensation==4||EdgeCompensation==6,
\ DS_String("%sEdgeCompensation 0,1,3,4 or 6 only(%d)",myName,EdgeCompensation))
Resampling=Default(Resampling,2)
Assert(0<=Resampling<=2,DS_String("%s0 <= Resampling <= 2(%d)",myName,Resampling))
SkipFrameIfLessThanXPercentOfBlocksOk=Float(Default(SkipFrameIfLessThanXPercentOfBlocksOk,8.0))
Assert(0.0<=SkipFrameIfLessThanXPercentOfBlocksOk<=100.0,DS_String("%s0.0 <= SkipFrameIfLessThanXPercentOfBlocksOk <= 100.0(%f)",
\ myName,SkipFrameIfLessThanXPercentOfBlocksOk))
InitialSearchRange=Default(InitialSearchRange,30)
Assert(1<=InitialSearchRange<=99, DS_String("%s1 <= InitialSearchRange <= 99(%d)",myName,InitialSearchRange))
DiscardMotionOfBlocksMatchingValueLessThanX=Float(Default(DiscardMotionOfBlocksMatchingValueLessThanX,300.0))
Assert(-1000.0<=DiscardMotionOfBlocksMatchingValueLessThanX<=1000.0,
\ DS_String("%s-1000.0 <= DiscardMotionOfBlocksMatchingValueLessThanX <= 1000.0(%f)",
\ myName,DiscardMotionOfBlocksMatchingValueLessThanX))
DiscardMotionOfBlocksThatHave2ndBestMatchLargerThanBestMinusX=Float(Default(DiscardMotionOfBlocksThatHave2ndBestMatchLargerThanBestMinusX,4.0))
Assert(0.0<=DiscardMotionOfBlocksThatHave2ndBestMatchLargerThanBestMinusX,
\ DS_String("%s0.0 <= DiscardMotionOfBlocksThatHave2ndBestMatchLargerThanBestMinusX(%f)",
\ myName,DiscardMotionOfBlocksThatHave2ndBestMatchLargerThanBestMinusX))
LogFile=Default(LogFile,"ShakeRattleAndRoll.Log")
Assert(LogFile!="",DS_String("%sLogfile Cannot be Empty string",myName))
LogFile=DS_GetFullPathName(LogFile)
Assert(Pass==1||Exist(LogFile),DS_String("%sPass 2 Logfile Does NOT Exist(%s)",myName,LogFile))
LogFile=DS_StrReplace(LogFile,"\","\\")
AppendToFile=Default(AppendToFile,False)
StainlessS
19th October 2016, 05:35
Post #2 of 3.
ShakeRattleAndRoll() update, Part 2,
IgnorePixelsOutside=Default(IgnorePixelsOutside,False)
IgnorePixelsOutsideLeft=Default(IgnorePixelsOutsideLeft,0)
IgnorePixelsOutsideRight=Default(IgnorePixelsOutsideRight,0)
IgnorePixelsOutsideTop=Default(IgnorePixelsOutsideTop,0)
IgnorePixelsOutsideBottom=Default(IgnorePixelsOutsideBottom,0)
IgnorePixelsInside=Default(IgnorePixelsInside,False)
IgnorePixelsInsideLeft=Default(IgnorePixelsInsideLeft,0)
IgnorePixelsInsideRight=Default(IgnorePixelsInsideRight,0)
IgnorePixelsInsideTop=Default(IgnorePixelsInsideTop,0)
IgnorePixelsInsideBottom=Default(IgnorePixelsInsideBottom,0)
VideoTypeInterlaced=Default(VideoTypeInterlaced,False)
VideoTypeUpperFieldFirst=Default(VideoTypeUpperFieldFirst,False)
ExtraZoomFactor=Float(Default(ExtraZoomFactor,1.0))
Assert(0.0<ExtraZoomFactor,DS_String("%s0.0 < ExtraZoomFactor(%f)",myName,ExtraZoomFactor))
MaxCorrectionLimitsHorizontalPanning=Float(Default(MaxCorrectionLimitsHorizontalPanning,15.0))
Assert(1.0<=MaxCorrectionLimitsHorizontalPanning,DS_String("%s1.0 <= MaxCorrectionLimitsHorizontalPanning(%f)",
\ myName,MaxCorrectionLimitsHorizontalPanning))
MaxCorrectionLimitsVerticalPanning=Float(Default(MaxCorrectionLimitsVerticalPanning,15.0))
Assert(1.0<=MaxCorrectionLimitsVerticalPanning,DS_String("%s1.0 <= MaxCorrectionLimitsVerticalPanning(%f)",
\ myName,MaxCorrectionLimitsVerticalPanning))
MaxCorrectionLimitsRotation=Float(Default(MaxCorrectionLimitsRotation,5.0))
Assert(1.0<=MaxCorrectionLimitsRotation,DS_String("%s1.0 <= MaxCorrectionLimitsRotation(%f)",myName,MaxCorrectionLimitsRotation))
MaxCorrectionLimitsZoom=Float(Default(MaxCorrectionLimitsZoom,15.0))
Assert(1.0<=MaxCorrectionLimitsZoom,DS_String("%s1.0 <= MaxCorrectionLimitsZoom(%f)",myName,MaxCorrectionLimitsZoom))
UsePreviousAndFutureFramesToFillInBordersPreviousFramesEnabled=Default(UsePreviousAndFutureFramesToFillInBordersPreviousFramesEnabled,False)
UsePreviousAndFutureFramesToFillInBordersFutureFramesEnabled=Default(UsePreviousAndFutureFramesToFillInBordersFutureFramesEnabled,False)
UsePreviousAndFutureFramesToFillInBordersPreviousFrames=Default(UsePreviousAndFutureFramesToFillInBordersPreviousFrames,30)
Assert(0<=UsePreviousAndFutureFramesToFillInBordersPreviousFrames,
\ DS_String("%s0 <= UsePreviousAndFutureFramesToFillInBordersPreviousFrames(%d)",
\ myName,UsePreviousAndFutureFramesToFillInBordersPreviousFrames))
UsePreviousAndFutureFramesToFillInBordersFutureFrames=Default(UsePreviousAndFutureFramesToFillInBordersFutureFrames,30)
Assert(0<=UsePreviousAndFutureFramesToFillInBordersFutureFrames,
\ DS_String("%s0 <= UsePreviousAndFutureFramesToFillInBordersFutureFrames(%d)",
\ myName,UsePreviousAndFutureFramesToFillInBordersFutureFrames))
IgnorePixelsOutside_LetAreaFollowMotion=Default(IgnorePixelsOutside_LetAreaFollowMotion,False)
DeepAnalysisIfLessThanXPercentOfVectorsAreOk=Default(DeepAnalysisIfLessThanXPercentOfVectorsAreOk,0)
Assert(0<=DeepAnalysisIfLessThanXPercentOfVectorsAreOk<=100,
\ DS_String("%s 0 <= DeepAnalysisIfLessThanXPercentOfVectorsAreOk <= 100(%d)",myName,DeepAnalysisIfLessThanXPercentOfVectorsAreOk))
CamcorderHasARollingShutter=Default(CamcorderHasARollingShutter,false)
GenerateInterlacedProgressiveVideo=Default(GenerateInterlacedProgressiveVideo,false)
SoftBorders=Default(SoftBorders,false)
ExtrapolateColorsIntoBorder=Default(ExtrapolateColorsIntoBorder,false)
SoftBorders_EdgeTransitionWidth=Default(SoftBorders_EdgeTransitionWidth,10)
Assert(0<=SoftBorders_EdgeTransitionWidth,DS_String("%s0 <= SoftBorders_EdgeTransitionWidth(%d)",myName,SoftBorders_EdgeTransitionWidth))
DiscardMotionOfBlocksThatMoveMoreThanXPixels=Float(Default(DiscardMotionOfBlocksThatMoveMoreThanXPixels,1000.0))
Assert(0.0<DiscardMotionOfBlocksThatMoveMoreThanXPixels, DS_String("%s0.0 < DiscardMotionOfBlocksThatMoveMoreThanXPixels(%f)",
\ myName,DiscardMotionOfBlocksThatMoveMoreThanXPixels))
RememberDiscardedAreasToNextFrame=Default(RememberDiscardedAreasToNextFrame,true)
RollingShutterAmount=Float(Default(RollingShutterAmount,88.0)) ##### Any Value ???
DetectRotation=Default(DetectRotation,true)
DetectZoom=Default(DetectZoom,true)
DetectScenes_Threshold=Float(Default(DetectScenes_Threshold,20.0))
Assert(0.0<=DetectScenes_Threshold<=1000.0, DS_String("%s0.0 <= DetectScenes_Threshold <= 1000.0(%f)",
\ myName,DetectScenes_Threshold))
AdaptiveZoomSmoothness=Float(Default(AdaptiveZoomSmoothness,5000.0))
Assert(0.0<AdaptiveZoomSmoothness,DS_String("%s0.0 < AdaptiveZoomSmoothness(%f)",myName,AdaptiveZoomSmoothness))
AdaptiveZoomAmount=Float(Default(AdaptiveZoomAmount,100.0)) ##### Any Value ???
DiscardMotionOfBlocksThatHaveMaximumPixelValueDifferenceLessThanX=Default(DiscardMotionOfBlocksThatHaveMaximumPixelValueDifferenceLessThanX,20)
Assert(0<=DiscardMotionOfBlocksThatHaveMaximumPixelValueDifferenceLessThanX<=255,
\ DS_String("%s0 <= DiscardMotionOfBlocksThatHaveMaximumPixelValueDifferenceLessThanX <= 255(%d)",
\ myName,DiscardMotionOfBlocksThatHaveMaximumPixelValueDifferenceLessThanX))
DetectScenes=Default(DetectScenes,true)
UseColorMask=Default(UseColorMask,false)
MaskColorInHexRRGGBB=BitAnd(Default(MaskColorInHexRRGGBB,$FF00FF),$FFFFFF)
#########
Auto=Default(Auto,Pass==1) # Default True if Pass==1 or False if Pass==2
Assert(Pass==1 || !Auto,DS_String("%sCannot use Auto=True if Pass==2",myName))
Debug=Default(Debug,True)
#########
Fmt1="%d|%d"
Fmt2="|%d|%d|%.*f|%d|%.*f|%d|%d|%d|%d|%d|%d|%d|%d|%d|%.*f|%d|%d|%d|%.*f|%d|%.*f|%.*f|" +
\ "%s|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%.*f|%.*f|%.*f|%.*f|%.*f|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%.*f|%d|%.*f|%d|%d|%.*f|%.*f|%.*f|%d|%d|%d|%x"
S1=DS_String(Fmt1,DSVersion,Pass)
S2=DS_String(Fmt2,
\ BlockSize,DifferentialSearchRange,
\ f2ip(SourcePixelAspectValue),SourcePixelAspectValue,SourcePixelAspectSelection,
\ f2ip(DestinationPixelAspectValue),DestinationPixelAspectValue,DestinationPixelAspectSelection,
\ DestinationWidth,DestinationHeight,Scale,UsePixels,
\ MotionSmoothnessHorizontalPanning,MotionSmoothnessVerticalPanning,MotionSmoothnessRotation,MotionSmoothnessZoom,
\ f2ip(DiscardMotionOfXBlocks),DiscardMotionOfXBlocks,VideoOutput,EdgeCompensation,Resampling,
\ f2ip(SkipFrameIfLessThanXPercentOfBlocksOk),SkipFrameIfLessThanXPercentOfBlocksOk,InitialSearchRange,
\ f2ip(DiscardMotionOfBlocksMatchingValueLessThanX),DiscardMotionOfBlocksMatchingValueLessThanX,
\ f2ip(DiscardMotionOfBlocksThatHave2ndBestMatchLargerThanBestMinusX),DiscardMotionOfBlocksThatHave2ndBestMatchLargerThanBestMinusX,
\ LogFile,AppendToFile?1:0,
\ IgnorePixelsOutside?1:0,IgnorePixelsOutsideLeft,IgnorePixelsOutsideRight,IgnorePixelsOutsideTop,IgnorePixelsOutsideBottom,
\ IgnorePixelsInside?1:0,IgnorePixelsInsideLeft,IgnorePixelsInsideRight,IgnorePixelsInsideTop,IgnorePixelsInsideBottom,
\ VideoTypeInterlaced?1:0,VideoTypeUpperFieldFirst?1:0,
\ f2ip(ExtraZoomFactor),ExtraZoomFactor,
\ f2ip(MaxCorrectionLimitsHorizontalPanning),MaxCorrectionLimitsHorizontalPanning,
\ f2ip(MaxCorrectionLimitsVerticalPanning),MaxCorrectionLimitsVerticalPanning,
\ f2ip(MaxCorrectionLimitsRotation),MaxCorrectionLimitsRotation,
\ f2ip(MaxCorrectionLimitsZoom),MaxCorrectionLimitsZoom,
\ UsePreviousAndFutureFramesToFillInBordersPreviousFramesEnabled?1:0,UsePreviousAndFutureFramesToFillInBordersFutureFramesEnabled?1:0,
\ UsePreviousAndFutureFramesToFillInBordersPreviousFrames,UsePreviousAndFutureFramesToFillInBordersFutureFrames,
\ IgnorePixelsOutside_LetAreaFollowMotion?1:0,DeepAnalysisIfLessThanXPercentOfVectorsAreOk,
\ CamcorderHasARollingShutter?1:0,GenerateInterlacedProgressiveVideo?1:0,SameDestinationPropertiesAsSource?1:0,
\ SoftBorders?1:0,ExtrapolateColorsIntoBorder?1:0,SoftBorders_EdgeTransitionWidth,
\ f2ip(DiscardMotionOfBlocksThatMoveMoreThanXPixels),DiscardMotionOfBlocksThatMoveMoreThanXPixels,
\ RememberDiscardedAreasToNextFrame?1:0,
\ f2ip(RollingShutterAmount),RollingShutterAmount,
\ DetectRotation?1:0,DetectZoom?1:0,f2ip(DetectScenes_Threshold),DetectScenes_Threshold,
\ f2ip(AdaptiveZoomSmoothness),AdaptiveZoomSmoothness,
\ f2ip(AdaptiveZoomAmount),AdaptiveZoomAmount,
\ DiscardMotionOfBlocksThatHaveMaximumPixelValueDifferenceLessThanX,
\ DetectScenes?1:0,UseColorMask?1:0,MaskColorInHexRRGGBB
\ )
DBUG = False # Used during debugging
S=S1+S2
Fn=DS_String("ShakeRattleAndRoll_Debug_%d.txt",Pass)
(Debug) ? DS_DebugF("%s",S,name=myName) : NOP
(Debug&&DBUG) ? DS_WriteFile(Fn,"%s",S) : NOP
Tmp=Deshaker(S)
(Auto) ? DS_ForceProcess(Tmp) : NOP
(Auto) ? Last : Tmp # If NOT Auto, then we return result of previous DeShaker(Pass=Whatever).
Tmp = 0 # If Auto, Force closure of tmp, allow reopen of log file for pass=2.
Fn=(Auto) ? "ShakeRattleAndRoll_Debug_2.txt" : Fn
S =(Auto) ? DS_String(Fmt1,DSVersion,2)+S2 : S
(Auto&&Debug) ? DS_DebugF("%s",S,name=myName) : NOP
(Auto&&Debug&&DBUG) ? DS_WriteFile(Fn,"%s",S) : NOP
(Auto) ? Deshaker(S) : NOP
Return Last
}
StainlessS
19th October 2016, 05:37
Post #3 of 3.
ShakeRattleAndRoll() Client fixed Stub and Preset Stub script functions.
LoadVirtualDubPlugin ("Deshaker.vdf", "deshaker", preroll=0)
FN="F:\V\CabaretUnCropped.avi"
AviSource(FN).ConvertToRGB32.Trim(10000,-500)
#LogFile=UNDEFINED # Use Default ShakeRattleAndRoll.Log in current script directory.
#LogFile=DS_FilenameSplit(FN,get=12)+".log" # 12+.Log = Name.Ext.log (No Dir/Path, In Current script directory)
#LogFile=DS_FilenameSplit(FN,get=4)+".Log" # 4+.Log = Name.log (No Dir/Path/Ext, In Current script directory)
#LogFile=DS_FilenameSplit(FN,get=7)+".Log" # 7+.Log = Drv:\Path\Name.log (in original clip directory if Drv:\Path\ supplied)
LogFile=FN+".Log" # Drv:\Path\Name.Ext.log (in original clip directory if Drv:\Path\ supplied)
# Avoids probs if 2 similar source names differing only in extension (at least for Deshaker).
###########
#Return GoorawinStub(LogFile=LogFile) # Specific fixed settings stub, by default, Auto two pass.
###########
DS_DEFAULT =0
DS_GUD =1
DS_BETA =2
DS_SUPA =3
DS_DUPA =4
DS_FANDABBYDOZY=5
###
Preset=UNDEFINED # Unused (as DS_DEFAULT but not err if Preset not set to something when calling with Preset=Preset)
Preset=DS_DEFAULT # 0->5, 0=DeShaker defaults
###########
oMxCorLimHPan=UNDEFINED # Unused
#oMxCorLimHPan=10.0 # Sets MaxCorrectionLimitsHorizontalPanning Overide (1.0 -> ???)
oMxCorLimVPan=UNDEFINED # Unused
#oMxCorLimVPan=10.0 # Sets MaxCorrectionLimitsVerticalPanning Overide (1.0 -> ???)
Return GoorawinPresetStub(LogFile=LogFile,Preset=Preset,oMxCorLimHPan=oMxCorLimHPan,oMxCorLimVPan=oMxCorLimVPan) # by default, Auto two pass.
###########
Function GoorawinStub(clip c,Int "Pass",String "LogFile",Bool "Auto",Bool "Debug") { # Specific fixed settings.
ShakeRattleAndRoll(c,Pass,
\ EdgeCompensation=4,MaxCorrectionLimitsHorizontalPanning=8.0,MaxCorrectionLimitsVerticalPanning=8.0,
\ MaxCorrectionLimitsRotation=3.0,MaxCorrectionLimitsZoom=8.0,CamcorderHasARollingShutter=True,RollingShutterAmount=90.0,
\ LogFile=LogFile,Auto=Auto,Debug=Debug)
}
Function GoorawinPresetStub(clip c,Int "Pass",String "LogFile",Int "Preset",Float "oMxCorLimHPan",Float "oMxCorLimVPan",Bool "Auto",Bool "Debug") {
/*
###
Stub Allowing some variation via preset and possible overrides via oMxCorLimHPan and oMxCorLimVPan.
None of below is intended to do anything at all useful as far as deshaking is concerned, just demo Preset How-To script.
### Below, True/False are ShakeRattleAndRoll() args, will be converted F=0,T=1 for DeShaker.
### The p19 type items are Deshaker parameter indexes relative 1, See Gunnar Thalin docs here:- http://www.guthspot.se/video/deshaker.htm
### Or see here for notes used to prepare this script:- http://forum.doom9.org/showthread.php?p=1783072#post1783072
EdgeCompensation = 4 (p19, default 0, [Int, 0,1,3,4,6 ] Pass=2, : [4 = Adaptive zoom average + fixed zoom]
MaxCorrectionLimitsHorizontalPanning= 8.0 (p40, default 15.0, [Float 1.0->??? ] Pass=2,
MaxCorrectionLimitsVerticalPanning = 8.0 (p41, default 15.0, [Float 1.0->??? ] Pass=2,
MaxCorrectionLimitsRotation = 3.0 (p42, default 5.0, [Float 1.0->??? ] Pass=2,
MaxCorrectionLimitsZoom = 8.0 (p43, default 15.0, [Float 1.0->??? ] Pass=2,
CamcorderHasARollingShutter =True (p50, default False,[Bool F/T (F=0)] Pass=1&2 (ShakeRattleAndRoll Bools converted to int for DS)
RollingShutterAmount =90.0 (p58, default 88.0 [Float Any Value] Pass 1&2
*/
myName="GoorawinPresetStub: " F=False T=True U=Undefined # U will use ShakeRattleAndRoll Defaults, except if eg oMxCorLimHPan overrides.
Preset=Default(Preset,0) Assert(0 <= Preset <= 5,RT_String("%s0 <= Preset <= 5(%d)",myName,Preset))
# Presets,
# 0) ShakeRattleAndRoll/DeShaker defaults [And GoorawinPresetStub() default].
# 1) RollShutter=ON, RollingShutterAmount=90.0, Rest default.
# 2) RollShutter=ON, RollingShutterAmount=90.0, EdgeCompensation=Adaptive zoom average + fixed zoom, Rest default.
# 3) As per your original DeShaker string.
# 4) As per your original DeShaker string but with default RollingShutterAmount 0f 88.0.
# 5) As per your original DeShaker string but with EdgeCompensation of 6,(Adaptive zoom full).
# Preset:- 0 1 2 3 4 5
p19 = Select(Preset, U, U, 4, 4, 4, 6) # EdgeCompensation
p40 = Select(Preset, U, U, U, 8.0, 8.0, 8.0) # MaxCorrectionLimitsHorizontalPanning
p41 = Select(Preset, U, U, U, 8.0, 8.0, 8.0) # MaxCorrectionLimitsVerticalPanning
p42 = Select(Preset, U, U, U, 3.0, 3.0, 3.0) # MaxCorrectionLimitsRotation
p43 = Select(Preset, U, U, U, 8.0, 3.0, 3.0) # MaxCorrectionLimitsZoom
p50 = Select(Preset, U, T, T, T, T, T) # CamcorderHasARollingShutter
p58 = Select(Preset, U, 90.0, 90.0, 90.0, U, 90.0) # RollingShutterAmount
### User Variable Preset Override args
p40 = Default(oMxCorLimHPan,p40)
p41 = Default(oMxCorLimVPan,p41)
###
ShakeRattleAndRoll(c,Pass,
\ EdgeCompensation=p19, MaxCorrectionLimitsHorizontalPanning=p40, MaxCorrectionLimitsVerticalPanning=p41,
\ MaxCorrectionLimitsRotation=p42, MaxCorrectionLimitsZoom=p43, CamcorderHasARollingShutter=p50, RollingShutterAmount=p58,
\ LogFile=LogFile,Auto=Auto,Debug=Debug)
}
EDIT: I've only used the non default values in your original deshaker string, you can add more as you wish, should be relatively easy
to extend, can also add as many override args to the preset stub as you like, hard bit is thinking of short names for them (maybe eg oP19
but not very memorable).
goorawin
19th October 2016, 06:02
I haven't check out your latest version yet.
However I have discovered a number of things:
I would really like the log file to default to the file name.
The four Motion smoothness settings should allow for -1 setting which is a fixed camera stabalization.
MotionSmoothnessHorizontalPanning=Default(MotionSmoothnessHorizontalPanning,1000)
Assert(-1 <= MotionSmoothnessHorizontalPanning, DS_String("%s 1 <= MotionSmoothnessHorizontalPanning(%d)",
\ myName,MotionSmoothnessHorizontalPanning))
MotionSmoothnessVerticalPanning=Default(MotionSmoothnessVerticalPanning,1000)
Assert(-1 <= MotionSmoothnessVerticalPanning, DS_String("%s 1 <= MotionSmoothnessVerticalPanning(%d)",myName,MotionSmoothnessVerticalPanning))
MotionSmoothnessRotation=Default(MotionSmoothnessRotation,1000)
Assert(-1 <= MotionSmoothnessRotation, DS_String("%s 1 <= MotionSmoothnessRotation(%d)",myName,MotionSmoothnessRotation))
MotionSmoothnessZoom=Default(MotionSmoothnessZoom,1000)
Assert(-1 <= MotionSmoothnessZoom, DS_String("%s 1 <= MotionSmoothnessZoom(%d)",myName,MotionSmoothnessZoom))
These now work OK
The IgnorePixelsOutside works as True or False but if we want to conform to the deshakers format maybe it should be 0 or 1.
While IgnorePixelsInside does not seem to work at all.
I certainly have not checked everything out, but what I have looks really great.
Personally I think this is a much quicker way to check out various settings, than using VDub.
StainlessS
19th October 2016, 06:44
I think everything you mentioned is already fixed (some of them I think in last version, not sure).
The True/False are converted to 1/0, when setting the string, (but IgnorePixelsInside was indeed broken, fixed above already).
I would really like the log file to default to the file name.
See the client script, in what way does it not do that ? (if you want it to error if LogFile not supplied then remove the LogFile=UNDEFINED bit and
when calling script with GoorwinStub(LogFile=LogFile) Avisynth will throw an error until you give it a name string.
I presume that you means default to filename+".log" or something.
See current script, there are plenty of options there.
EDIT: Have Commented out LogFile=UNDEFINED so will error if not given a filename.
The Bools in script functions are intended to avoid having to check whether the args are 0->1, ie Avisynth will not allow
eg int to be used for a bool arg, so we know that the arg is not eg 12345 and only Yes/No (1,0), and when converting to string use something
like (BoolVar)?1:0, ie true=1,false=0. Avoids a lot more Assert() checks.
StainlessS
19th October 2016, 07:12
Oops sorry, your are correct, my Notes were wrong and without the '-' hyphen, will correct in a moment.
goorawin
19th October 2016, 07:12
Sorry, I should have checked the new script before sending the results of the old one. The new one was not there when I started.
Regarding the log file name currently it default to ShakeRattleAndRoll.Log.
Is there anyway to have that default be 'filename'.log. In your case it would be CabaretUnCropped.log
Thanks will start checking out the new script.
StainlessS
19th October 2016, 09:18
LogFile=Default(LogFile,"ShakeRattleAndRoll.Log")
Assert(LogFile!="",DS_String("%sLogfile Cannot be Empty string",myName))
I set initially LogFile=UNDEFINED, so that Avisynth will not error if you call with eg GoorawinStub(LogFile=Logfile) when Logfile has never been set to anything at all.
[EDIT: ie use default behaviour, use ShakeRattleAndRoll.log in current directory]
Same with eg, oMxCorLimHPan, GooraWinPresetStub(oMxCorLimHPan=oMxCorLimHPan) would error if oMxCorLimHPan never set to anything at all, if you dont like the
default behaviour then set the particular arg to something else or remove it from the function call [EDIT: where you would also get default behaviour :( ].
If you always want it to error if not supplied with a real logfilename, then comment out the first line in above code block above, and it will always error
on the Assert line. I dont think its a good idea to remove that line in general (it might suit you but others may find it decidedly un-amenable).
Anyway, I've went a bit crossed eyed cross checking Gunnar Thalin page, my notes and script, fixed two more minor problems.
Script updated, try as updated (notes post also updated).
PS, you could also Precede the first line in code block above with something like
Assert(Defined(LogFile),RT_String("%sLogFile NOT supplied",myName))
And so it would give some kind of controlled message rather than just halting with error (when LogFile not given).
Anyways give it another bash and if trouble post the first few lines of script as used, stopping before functions.
EDIT:
Is there anyway to have that default be 'filename'.log.
Thats what the lines below do, in the client script.
LogFile=FN+".Log" # Drv:\Path\Name.Ext.log (in original clip directory if Drv:\Path\ supplied)
# Avoids probs if 2 similar source names differing only in extension (at least for Deshaker).
EDIT: The multiple assignments to various variables at head of script are intended to be commented/uncommented as required,
easier than doing a lot of adding and deleting stuff.
The UNDEFINED thing set first, just does default behaviour if nothing else is substituted later.
If not set with anything at all and function called with eg func(LogFile=Logfile) and Logfile does not exist, then Avisynth would complain
about non-existing variable, [EDIT: Cant remember exact message, maybe something like "I dont know what Logfile is"].
Assigning UNDEFINED instantiates the variable so that it does exist, but is not defined to be anything in particular, so Avisynth
does not complain, and inside the function the optional arg is interpreted as not having been supplied and so default behaviour ensues.
goorawin
19th October 2016, 11:14
Yes, I did the following which works correctly from my point of view.
GoorawinStub(LogFile=DS_FilenameSplit(FN,get=4)+".Log")
When I did batch encoding with the original script I used Avisynth Batcher to set this log file at the same time I created batch scripts.
Having a different log file also means a number of scripts can be processed/encoded at the same time.
From what you are saying, to set this as a default could create other issues?
I haven't started playing around with the presets yet, but I like the idea. However I think 4 additional value should be added. They are:
P13
P14
P15 &
P16
These govern how smooth the stabilization is and thus have a big effect on the final output.
It's all working well but have yet to try the new script on 32Bit, but I'm sure it will be fine.
Anyway again thank you.
StainlessS
19th October 2016, 12:46
OK, I think I understand what it is that you are trying to do, think maybe you are going about it a bit wrongly.
I use Avisynthsizer_Mod in Batch mode, http://forum.doom9.org/showthread.php?t=166820&highlight=avisynthesizer_mod
I added Batch mode to it some time ago.
Here a template that I've just knocked up, works fine. (I guess if you rearrange your batcher template it could do similar).
EDIT: I've never used Avisynth Batcher.
BATCH_GoorawinStub.avst
#ASYNTHER BATCH-GoorawinStub
# Above name shown in Avsynthesizer_Mod template selector as "BATCH-GoorawinStub".
###
#
# ShakeRattleAndRoll.avsi should live in plugins (avoid every batch script having to have a copy).
# Also, Final versions of eg GoorawinStub and GoorwinPresetStub should also live in plugins.
# But for now can just embed GoorawinStub in this file.
# Only have the above functions in plugins, ie NOT any client scripting that calls the functions (probably crash).
#
### Some prep work here, load Deshaker.vdf from known location, or could have avsi script to autoload Deshaker.vdf in plugins
#
LoadVirtualDubPlugin ("D:\Deshaker.vdf", "deshaker", preroll=0)
#
###
#
# Below 'FILE' enclosed in 3 Underscore either side, not further enclosed in square brackets,
# so is Non-Repeating ie Batch Mode Avisynthesizer_Mod template, multiple AVS files generated, one for each source file.
#
###
#
FN = "___FILE___" # Full filepath and name (Filename is inserted by Avisynthesiser_Mod)
LogFile=FN+".Log" # Same Drv:\Path\Name.Ext+'.Log'
AviSource(FN) # Open clip, (or some other source filter, if same filename, can audio dub or whatever below).
### Sundry demo
# Audio=DS_FilenameSplit(FN,get=7)+".WAV" # Drv:\Path\Name.WAV Same name as source AVI but with WAV extension.
# AudioDub(Audio)
###
# Anything else you want to do before calling GoorawinStub, do it below.
ConvertToRGB32.Trim(10000,-500)
### Deshaker
GoorawinStub(LogFile=LogFile) # Auto two pass (debug enabled by default, DebugView Shows Progress)
###
# Do something else as well
###
ConvertToYV12
Subtitle("That was easy",align=5)
###
# End
###
Return last
###
Function GoorawinStub(clip c,Int "Pass",String "LogFile",Bool "Auto",Bool "Debug") { # Specific fixed settings.
ShakeRattleAndRoll(c,Pass,
\ EdgeCompensation=4,MaxCorrectionLimitsHorizontalPanning=8.0,MaxCorrectionLimitsVerticalPanning=8.0,
\ MaxCorrectionLimitsRotation=3.0,MaxCorrectionLimitsZoom=8.0,CamcorderHasARollingShutter=True,RollingShutterAmount=90.0,
\ LogFile=LogFile,Auto=Auto,Debug=Debug)
}
goorawin
24th October 2016, 23:35
It seem that DS_ForceProcess and ShakeRattleAndRoll do not allow negative numbers for a fixed camera setting. Deshaker("19|1|30|4|1|0|1|0|640|480|1|2|-1|-1|-1|-1|4|1|3|2|8|30|300|4|D:\\Deshaker logs\\00147.log|0|0|0|0|0|0|0|0|0|0|0|0|0|1|1|1|1|1|0|0|30|30|0|0|1|0|1|1|0|10|1000|1|70|1|1|20|5000|100|20|1|0|ff00ff")
# A fixed camera script
Sometimes this work fine but others an access error occurs.
It is interest that ShakeRattleAndRoll debug log file has many decimal places. While the Virtual dub deshaker log file does not.19|2|30|4|1.000000|0|1.000000|0|1920|1080|1|2|1000|1000|1000|1000|4.000000|1|0|2|8.000000|30|300.000000|4.000000|D:\\Avisynth Testing\\32Bit V 64Bit\\P2420287.Log|0|0|0|0|0|0|0|0|0|0|0|0|0|1.000000|8.000000|8.000000|3.000000|8.000000|0|0|30|30|0|0|1|0|1|0|0|10|1000.000000|1|90.000000|1|1|20.000000|5000.000000|100.000000|20|1|0|ff00ff
ShakeRattleAndRoll log
Deshaker("19|1|30|4|1|0|1|0|640|480|1|2|1000|1000|1000|1000|4|1|3|2|8|30|300|4|D:\\Deshaker logs\\00027.log|0|0|0|0|0|0|0|0|0|0|0|0|0|1|3|3|3|3|0|0|30|30|0|0|1|0|1|1|0|10|1000|1|70|1|1|20|5000|100|20|1|0|ff00ff") Deshaker log
Using just DS_ForceProcess on your old two pass script work well except with negative numbers.Stabalizer01()
function Stabalizer01(clip Clip) {
ConvertToRGB32(clip, matrix="rec709")
SCRIPT1=Deshaker("19|1|30|4|1|0|1|0|640|480|1|2|5000|5000|5000|5000|4|1|3|2|8|30|300|4|D:\\Deshaker logs\\00408.log|0|0|0|0|0|0|0|0|0|0|0|0|0|1|15|15|5|0.0005|0|0|30|30|0|0|1|0|1|1|0|10|1000|1|70|1|1|20|5000|100|20|1|0|ff00ff")
DS_ForceProcess(SCRIPT1)
SCRIPT1 = 0
Deshaker("19|2|30|4|1|0|1|0|640|480|1|2|5000|5000|5000|5000|4|1|3|2|8|30|300|4|D:\\Deshaker logs\\00408.log|0|0|0|0|0|0|0|0|0|0|0|0|0|1|15|15|5|0.0005|0|0|30|30|0|0|1|0|1|1|0|10|1000|1|70|1|1|20|5000|100|20|1|0|ff00ff")
}
Any suggestions StainlessS?
StainlessS
25th October 2016, 23:30
Posts #23 and 24 updated.
It seem that DS_ForceProcess and ShakeRattleAndRoll do not allow negative numbers for a fixed camera setting.
I think you must be using an older version again, works fine here. [EDIT: Only -1 allowed as per docs]
It is interest that ShakeRattleAndRoll debug log file has many decimal places. While the Virtual dub deshaker log file does not.
Not really important, however I guess less text to look at is an improvement (you are such a demanding task master :) )
Decimal places disappeared, except when specified as fractional.
19|1|30|4|1|0|1|0|720|576|1|2|-1|-1|-1|-1|4|1|0|2|8|30|300|4|D:\\ShakeRattleAndRoll.Log
|0|0|0|0|0|0|0|0|0|0|0|0|0|1|15|15|5|15|0|0|30|30|0|0|0|0|1|0|0|10|1000|1|88|1|1|20|5000|100|20|1|0|ff00ff
EDIT: Specified AdaptiveZoomAmount=PI
19|1|30|4|1|0|1|0|720|576|1|2|-1|-1|-1|-1|4|1|0|2|8|30|300|4|D:\\ShakeRattleAndRoll.Log
|0|0|0|0|0|0|0|0|0|0|0|0|0|1|15|15|5|15|0|0|30|30|0|0|0|0|1|0|0|10|1000|1|88|1|1|20|5000|3.141593|20|1|0|ff00ff
EDIT: Did you get the batcher thing working OK ?
goorawin
26th October 2016, 05:12
I'm Sorry
Thank you for the updated script. The log files are easy to compare now which helps with setting up and trying with what I know works.
The latest update is mostly working in 32Bit, however using it with 64Bit, it is not. As a matter of interest I have been having increasing errors with the older version as well, for some reason. I have been trying to narrow down why for sometime. I have observed that it is more likely to occur if non default parameters are used.
The first pass seems fine and when that's complete a brief image appears before it freezes AvsPmod.
Debugging the error sometimes refers to the line;
\ LogFile=LogFile,Auto=Auto,Debug=Debug)
But errors always refer to
(Auto) ? Deshaker(S) : NOP
One time this error came up.
Traceback (most recent call last):
File "avsp.pyo", line 4767, in _OnMouseMotion
TypeError: unsupported operand type(s) for -: 'int' and 'NoneType'
I have only just noticed that when the error occurs, the log file is different to the normal one.
1 0.02 -0.75 0.005 1.00018 # 0.02 61.28
2 -0.33 0.33 -0.001 0.99989 # 0.05 61.81
Error log
1 -0.14 -1.14 0.012 0.99994 -0.60 -2.34 0.015 1.00008 # 0.02 61.28
2 -0.38 0.31 0.004 0.99968 -0.49 0.36 0.013 0.99914 # 0.05 61.81
Normal log
This old script seems to work fine in 64Bit using a number of different clips and settings..
V2=Stabalizer01(V1)
function Stabalizer01(clip Clip) {
ConvertToRGB32(clip, matrix="rec709")
SCRIPT1=Deshaker("19|1|30|4|1|0|1|0|640|480|1|2|1000|1000|1000|1000|4|1|4|2|8|30|300|4|D:\\Deshaker logs\\00184.log|0|0|0|0|0|0|0|0|0|0|0|0|0|1|8|8|3|8|0|0|30|30|0|0|1|0|1|1|0|10|1000|1|90|1|1|20|5000|100|20|1|0|ff00ff")
DS_ForceProcess(SCRIPT1)
SCRIPT1 = 0
Deshaker("19|2|30|4|1|0|1|0|640|480|1|2|1000|1000|1000|1000|4|1|4|2|8|30|300|4|D:\\Deshaker logs\\00184.log|0|0|0|0|0|0|0|0|0|0|0|0|0|1|8|8|3|8|0|0|30|30|0|0|1|0|1|1|0|10|1000|1|90|1|1|20|5000|100|20|1|0|ff00ff")
ConvertToYV12(matrix="rec709")
}
Any thoughts?
StainlessS
27th October 2016, 19:52
Debugging the error sometimes refers to the line;
\ LogFile=LogFile,Auto=Auto,Debug=Debug)
But errors always refer to
(Auto) ? Deshaker(S) : NOP
The reference to the first line is just saying that that was the line that called the function where the problem was.
The Auto line is the one with the apparent problem.
All the Auto line does is, If(Auto==True) Then let Last=DeShaker(S) Else Do_Nothing # Leave Last as it was.
Why AvsPMod should be complaining about that, I dont know.
EDIT:
But errors always refer to
What do those errors say ?
One Time this error came up
Traceback (most recent call last):
File "avsp.pyo", line 4767, in _OnMouseMotion
TypeError: unsupported operand type(s) for -: 'int' and 'NoneType'
No idea what that AVSPMod line means, looks like it may be a problem with AVSPMod, would help if you said it also had a problem using MPC
or VDub, anything but AvsPMod. [EDIT: Maybe vdcrim would like to comment (not online since Sept 24).]
The first pass seems fine and when that's complete a brief image appears before it freezes AvsPmod.
Yep, I was curious about that little window flashing up, I had to take a video of it so I could see what it said,
it said in title bar "DeShaker", and message was "DeShaking", so nothing wrong there.
[EDIT: Probably put up that message window because it did not have a VirtualDub window available]
All I can suggest is that you change this line to True (near end of script, it outputs the Deshaker argument strings)
DBUG = False # Used during debugging
And compare results with the good Deshaker lines, if same then string construction is not the problem. (dont use AvsPMod).
Also compare results 32bit and 64 bit, all should be same, if they all are the same then has got to be something different (perhaps broken) in 64 bit Deshaker,
(maybe 64 bit AvsPMod was interfering somehow).
The 64 bit DS_ tools, I think will either work or it will not, the filename stuff [EDIT: and string stuff] is clearly working.
DS_ForceProcess is also doing what it is supposed to, ie just requesting all frames consecutively, or the Deshaker logs would not be produced.
My chief suspects are problem 64 bit stuff, DeShaker or perhaps even AvsPMod (or both).
EDIT: Dont use any kind of MT, no idea what effect that would have on DS_ForceProcess and Deshaker plugin.
EDIT: Perhaps MT stuff could be attempting to mess with frame request ordering, but does not interfere with
ordering when using the scripted version of ForceProcess which requests frames 1 at a time from the RT_YankChain plug function.
Maybe seemingly random ordered requests will mess up DeShaker.
EDIT: Above is wrong, you say older 64 bit using DS_ForceProcess works ok.
EDIT: Give me a rock solid example with identical Deshaker arg strings which cause different output in 32 and 64 bit when using
some Media Player other than AvsPMod. Also post any error messages and entire Deshaker arg strings and result logs for both.
You might also want to have DebugView open and capturing the Debug output, and see if any discrepancies.
StainlessS
27th October 2016, 21:57
Post #17 updated link to DS_tools v0.01, or here:- http://www.mediafire.com/file/01ui4mco52ljkca/DS_Tools_26dll_x32x64_v0.01_20101027.zip
Added
DS_Sleep(Float time)
time in seconds, 0.0 -> 60.0. Silently limited to that range. Accurate to about 0.001 seconds.
DS_Sleep(0.0) would not sleep for any specific time, it would just give opportunity to any waiting
tasks to do a bit of processing, before returning to the current task.
Perhaps Add a call to DS_Sleep(1.0) # 1 second pause to ensure DeShaker has fully closed before calling again,
maybe it helps ???
Put in something like
(Auto) ? DS_Sleep(1.0) : NOP
Just before second call the Deshaker. [maybe we are clutching at straws :) ]
EDIT: If that DONT work, try adding another Sleep just before this line (only if above sleep fails)
Tmp = 0 # If Auto, Force closure of tmp, allow reopen of log file for pass=2.
goorawin
25th November 2018, 05:37
Hi StainlessS
I have used a version of your deshaker script "ShakeRattleAndRoll" many times and its been great.
Laterly however the following error occurs when it finishes the first pass.
If I do each pass seperately by changing pass1 to pass2 it works fine. It just will not start pass2 because of this error.
The Error is
VirtualdubFilterProxy:No FilterDefinition structure!
This relates to line 227 in the avsi script. This line is
(Auto) ? Deshaker(S) : NOP
in a part of the script. See below
DBUG = False # Used during debugging
S=S1+S2
Fn=DS_String("DeshakerStabilizing05_Debug_%d.txt",Pass)
(Debug) ? DS_DebugF("%s",S,name=myName) : NOP
(Debug&&DBUG) ? DS_WriteFile(Fn,"%s",S) : NOP
Tmp=Deshaker(S)
(Auto) ? DS_ForceProcess(Tmp) : NOP
(Auto) ? Last : Tmp # If NOT Auto, then we return result of previous DeShaker(Pass=Whatever).
(Auto) ? DS_Sleep(1.0) : NOP
Tmp = 0 # If Auto, Force closure of tmp, allow reopen of log file for pass=2.
Fn=(Auto) ? "DeshakerStabilizing05_Debug_2.txt" : Fn
S =(Auto) ? DS_String(Fmt1,DSVersion,2)+S2 : S
(Auto&&Debug) ? DS_DebugF("%s",S,name=myName) : NOP
(Auto&&Debug&&DBUG) ? DS_WriteFile(Fn,"%s",S) : NOP
(Auto) ? DS_Sleep(1.0) : NOP
(Auto) ? Deshaker(S) : NOP
Return Last
}
I have tried many things including installing different versions of the VDubFilter.dll.
An ideas would be very much appreciated
StainlessS
25th November 2018, 09:17
The Error is
VirtualdubFilterProxy:No FilterDefinition structure!
I've no idea what that means (or where is originates).
But, as I am now on 64 bit, and RT_Stats v2.00 Beta 11 [EDIT: Beta 12, see below] is available in 64 bit, can you try that (just so we can be on same page).
Do a rename of all "DS_" to "RT_" in scripts.
EDIT: Thought that I'de posted RT_ v2.00 Beta 12, but seems that I had not, now posted in RT_Stats thread, via first post.
https://forum.doom9.org/showthread.php?t=165479&highlight=RT_Stats
I'll try install Avs+ x64 and take a peek.
EDIT: I may have posted Beta 12 as an attachment somewhere, but forgot where.
EDIT: Also ensure using VirtualDub2.
goorawin
25th November 2018, 23:47
I installed RT_Stats v2.00 Beta 12 and did the script changes but the same issue occurs.
Yes I am using VD 2 the latest version. For a moment I thought that may have been the problem so reverted back to a much earlier version of VD, but that did not help. I can not think what else may have been updated, other than Avisynth plus to the current version and of course Windows 10, that could be causing the issue.
Anyway thanks for your help
StainlessS
26th November 2018, 00:35
Hi, give me a little time, I'm busy trying to set up x64 Avs, got gazillions of plugins to sort out.
goorawin
26th November 2018, 01:09
Not a problem.
Thanks for all your great work on progressing Avisynth further
StainlessS
1st December 2018, 12:31
With this
LoadVirtualDubPlugin ("D:\ShakeRattleAndRoll\Deshaker.vdf", "deshaker", preroll=0)
FN="D:\G.avi"
AviSource(FN).ConvertToRGB32.Trim(10000,-500)
ShakeRattleAndRoll(MotionSmoothnessHorizontalPanning=-1,MotionSmoothnessVerticalPanning=-1,MotionSmoothnessRotation=-1,MotionSmoothnessZoom=-1)
return Last
I'm also getting this
https://i.postimg.cc/rzgXf4Sr/Shaker.jpg (https://postimg.cc/rzgXf4Sr)
No idea to the cause.
Probably not around till tomorrow (unless mobile).
Current Avs+, and also current VD2.
EDIT: I dont seem to be able to find any reference to VD2 in registry, and so am wondering how Deshaker plugin is supposed to find it.
EDIT: Arg to deshaker =
19|1|30|4|1|0|1|0|854|480|1|2|-1|-1|-1|-1|4|1|0|2|8|30|300|4|D:\\ShakeRattleAndRoll
\\ShakeRattleAndRoll.Log|0|0|0|0|0|0|0|0|0|0|0|0|0|1|15|15|5|15|0|0|30|30|0|0|0|0|1|
0|0|10|1000|1|88|1|1|20|5000|100|20|1|0|ff00ff
EDIT: OK, there is HKEY_CLASSES_ROOT\Applications\VirtualDub.Exe\
and VirtualDub64.Exe
pinterf
1st December 2018, 12:41
To use a vd/vd2 plugin in AviSynth you don't need to have a real VirtualDub.
And as for the 'no filterdefinition structure' - it's LoadVirtualDubPlugin filter in vdubfilter.dll who is unable to load Deshaker.vdf for some reason and displays the message.
pinterf
1st December 2018, 13:23
The plugin instances are reference counted. When the reference count becomes zero, the resource is freed up.
The script is killing the clip variable by an explicite Tmp=0 which unloads the deshaker plugin:
end of ShakeRattleAndRoll.avsi:
Tmp=Deshaker(S)
[...]
Tmp = 0 #closure of tmp, allow reopen of log file for pass=2.
For the next usage, some lines later (2nd pass) the filter is not available anymore, we get a no Filterdefinition structure message.
For an instant solution I recommend that you
1.) make a copy of Deshaker.VFD to a different file name.
2.) Modify your script to load both plugins under different avisynth name
e.g.
LoadVirtualDubPlugin ("C:\virtualdub\plugins64\Deshaker_64.vdf", "Deshaker", preroll=0)
LoadVirtualDubPlugin ("C:\virtualdub\plugins64\Deshaker_64_b.vdf", "Deshaker2", preroll=0)
3.) Change ShakeRattleAndRoll.avsi to use the new name "Deshaker2" for the 2nd pass.
(Auto) ? Deshaker2(S) : NOP
Return Last
goorawin
1st December 2018, 23:13
The plugin instances are reference counted. When the reference count becomes zero, the resource is freed up.
The script is killing the clip variable by an explicite Tmp=0 which unloads the deshaker plugin:
end of ShakeRattleAndRoll.avsi:
Tmp=Deshaker(S)
[...]
Tmp = 0 #closure of tmp, allow reopen of log file for pass=2.
For the next usage, some lines later (2nd pass) the filter is not available anymore, we get a no Filterdefinition structure message.
For an instant solution I recommend that you
1.) make a copy of Deshaker.VFD to a different file name.
2.) Modify your script to load both plugins under different avisynth name
e.g.
LoadVirtualDubPlugin ("C:\virtualdub\plugins64\Deshaker_64.vdf", "Deshaker", preroll=0)
LoadVirtualDubPlugin ("C:\virtualdub\plugins64\Deshaker_64_b.vdf", "Deshaker2", preroll=0)
3.) Change ShakeRattleAndRoll.avsi to use the new name "Deshaker2" for the 2nd pass.
(Auto) ? Deshaker2(S) : NOP
Return Last
Thanks Pinterf
That certainly works, but why did the previous script stop working?
I have used it countless times with no problems. But probably have not done so on this new computer. or on an older computer for the last 12 months. Both have Windows 10 pro (current version). Very strange!!!!!
goorawin
1st December 2018, 23:50
I must be going crazy Pinterf.
Your method work three times with no problems, after that it comes up with the same error as before. Even if I change pass1 in the deshaker script (after it has created a log file and then the error) to pass2, it now has the same error for pass2 using your suggestions.
I haven't as yet rebooted the computer to see if it reverts back to working but I very much doubt it.
StainlessS
2nd December 2018, 21:10
Post 1 of 2.
Using current temp script,
#return Version
FN="D:\G.avi"
AviSource(FN).ConvertToRGB32.Trim(0,-500) # 500 frames only
#ShakeRattleAndRoll(MotionSmoothnessHorizontalPanning=-1,MotionSmoothnessVerticalPanning=-1,MotionSmoothnessRotation=-1,MotionSmoothnessZoom=-1)
ShakeRattleAndRoll()
return Last
Function ShakeRattleAndRoll(clip c,Int "Pass",Int "BlockSize",Int "DifferentialSearchRange",
\ Float "SourcePixelAspectValue",Int "SourcePixelAspectSelection",
\ Float "DestinationPixelAspectValue",Int "DestinationPixelAspectSelection",
\ Int "DestinationWidth",Int "DestinationHeight",Int "Scale",Int "UsePixels",
\ Int "MotionSmoothnessHorizontalPanning",Int "MotionSmoothnessVerticalPanning",Int "MotionSmoothnessRotation",
\ Int "MotionSmoothnessZoom",Float "DiscardMotionOfXBlocks",Int "VideoOutput",Int "EdgeCompensation",Int "Resampling",
\ Float "SkipFrameIfLessThanXPercentOfBlocksOk",Int "InitialSearchRange",
\ Float "DiscardMotionOfBlocksMatchingValueLessThanX",Float "DiscardMotionOfBlocksThatHave2ndBestMatchLargerThanBestMinusX",
\ String "LogFile",Bool "AppendToFile",
\ Bool "IgnorePixelsOutside",Int "IgnorePixelsOutsideLeft",Int "IgnorePixelsOutsideRight",Int "IgnorePixelsOutsideTop",
\ Int "IgnorePixelsOutsideBottom",
\ Bool "IgnorePixelsInside",Int "IgnorePixelsInsideLeft",Int "IgnorePixelsInsideRight",Int "IgnorePixelsInsideTop",
\ Int "IgnorePixelsInsideBottom",Bool "VideoTypeInterlaced",Bool "VideoTypeUpperFieldFirst",
\ Float "ExtraZoomFactor",Float "MaxCorrectionLimitsHorizontalPanning",Float "MaxCorrectionLimitsVerticalPanning",
\ Float "MaxCorrectionLimitsRotation",Float "MaxCorrectionLimitsZoom",
\ Bool "UsePreviousAndFutureFramesToFillInBordersPreviousFramesEnabled",Bool "UsePreviousAndFutureFramesToFillInBordersFutureFramesEnabled",
\ Int "UsePreviousAndFutureFramesToFillInBordersPreviousFrames",Int "UsePreviousAndFutureFramesToFillInBordersFutureFrames",
\ Bool "IgnorePixelsOutside_LetAreaFollowMotion",Int "DeepAnalysisIfLessThanXPercentOfVectorsAreOk",
\ Bool "CamcorderHasARollingShutter",Bool "GenerateInterlacedProgressiveVideo",Bool "SameDestinationPropertiesAsSource",
\ Bool "SoftBorders",Bool "ExtrapolateColorsIntoBorder",Int "SoftBorders_EdgeTransitionWidth",
\ Float "DiscardMotionOfBlocksThatMoveMoreThanXPixels",Bool "RememberDiscardedAreasToNextFrame",
\ Float "RollingShutterAmount",Bool "DetectRotation",Bool "DetectZoom",Float "DetectScenes_Threshold",
\ Float "AdaptiveZoomSmoothness",Float "AdaptiveZoomAmount",Int "DiscardMotionOfBlocksThatHaveMaximumPixelValueDifferenceLessThanX",
\ Bool "DetectScenes",Bool "UseColorMask",Int "MaskColorInHexRRGGBB",
\ Bool "Auto", Bool "Debug",
\ String "DeShakerPlugName",Int "PreRoll") {
/*
Can set Aspect Ratios directly using eg SourcePixelAspectValue=1.333 or by GUI index SourcePixelAspectSelection[0->7]
*/
Function f2ip(Float f) {return (int(f)==f) ? 0 : 6}
myName="ShakeRattleAndRoll: "
c
Assert(IsRGB32,RT_string("%sClip Must be RGB32",myName)) # Client MUST convert to RGB32 using whatever matrix and also Interlacing.
DSVersion = 19 # Fixed by DeShaker.vdf, Need modify if new version of dll
Pass=Default(Pass,1)
Assert(1<=Pass<=2, RT_String("%sPass 1 or 2 Only(%d)",myName,Pass))
BlockSize=Default(BlockSize,30)
Assert(1<=BlockSize<=100, RT_String("%s1 <= BlockSize <= 100 Only(%d)",myName,BlockSize))
DifferentialSearchRange=Default(DifferentialSearchRange,4)
Assert(1<=DifferentialSearchRange, RT_String("%s1 <= DifferentialSearchRange(%d)",myName,DifferentialSearchRange))
### GUI ### SourcePixelAspectValue OverRides GUI selection if given as arg, Otherwise uses GUI SourcePixelAspectSelection[0->7] default 0=1:1.
DefV=Defined(SourcePixelAspectValue)
SourcePixelAspectSelection = (DefV) ? -1 : Max(Default(SourcePixelAspectSelection,0),0)
Assert(-1<=SourcePixelAspectSelection<=7, RT_String("%s-1 <= SourcePixelAspectSelection <= 7(%d)", myName,SourcePixelAspectSelection))
SourcePixelAspectValue = (DefV) ? Float(SourcePixelAspectValue)
\ : Select(SourcePixelAspectSelection,1.0,1.09259,0.909091,1.45679,1.21212,1.63889,1.36364,1.33333)
Assert(0.0<SourcePixelAspectValue,RT_String("%s0.0 < SourcePixelAspectValue(%f)",myName,SourcePixelAspectValue))
### Param 52, MUST Process out-of-param-sequence
SameDestinationPropertiesAsSource=Default(SameDestinationPropertiesAsSource,true)
### GUI SameDestinationPropertiesAsSource OVERRIDES ALL, otherwise DestinationPixelAspectValue OverRides GUI selection if given as arg
DefV=Defined(DestinationPixelAspectValue)
DestinationPixelAspectSelection=(SameDestinationPropertiesAsSource)?SourcePixelAspectSelection:(DefV)?-1:Max(Default(DestinationPixelAspectSelection,0),0)
Assert(-1<=DestinationPixelAspectSelection<=7,
\ RT_String("%s-1 <= DestinationPixelAspectSelection <= 7(%d)",myName,DestinationPixelAspectSelection))
DestinationPixelAspectValue = (SameDestinationPropertiesAsSource) ? SourcePixelAspectValue : (DefV) ? Float(DestinationPixelAspectValue)
\ : Select(DestinationPixelAspectSelection,1.0,1.09259,0.909091,1.45679,1.21212,1.63889,1.36364,1.33333)
Assert(0.0<DestinationPixelAspectValue, RT_String("%s0.0 < DestinationPixelAspectValue(%f)",myName,DestinationPixelAspectValue))
###
DestinationWidth = (SameDestinationPropertiesAsSource) ? Width : Default(DestinationWidth, 640)
DestinationHeight = (SameDestinationPropertiesAsSource) ? Height : Default(DestinationHeight,480)
Assert(1<=DestinationWidth, RT_String("%s1 <= DestinationWidth(%d)",myName,DestinationWidth))
Assert(1<=DestinationHeight,RT_String("%s1 <= DestinationHeight(%d)",myName,DestinationHeight))
### End of Source/Dest Same as stuff
Scale=Default(Scale,1)
Assert(0<=Scale<=2, RT_String("%s0 <= Scale <=2(%d)",myName,Scale))
UsePixels=Default(UsePixels,2)
Assert(1<=UsePixels<=4, RT_String("%s1 <= UsePixels <= 4(%d)",myName,UsePixels))
MotionSmoothnessHorizontalPanning=Default(MotionSmoothnessHorizontalPanning,1000)
Assert(-1<=MotionSmoothnessHorizontalPanning, RT_String("%s-1 <= MotionSmoothnessHorizontalPanning(%d)",myName,MotionSmoothnessHorizontalPanning))
MotionSmoothnessVerticalPanning=Default(MotionSmoothnessVerticalPanning,1000)
Assert(-1<=MotionSmoothnessVerticalPanning, RT_String("%s-1 <= MotionSmoothnessVerticalPanning(%d)",myName,MotionSmoothnessVerticalPanning))
MotionSmoothnessRotation=Default(MotionSmoothnessRotation,1000)
Assert(-1<=MotionSmoothnessRotation,RT_String("%s-1 <= MotionSmoothnessRotation(%d)",myName,MotionSmoothnessRotation))
MotionSmoothnessZoom=Default(MotionSmoothnessZoom,1000)
Assert(-1<=MotionSmoothnessZoom, RT_String("%s-1 <= MotionSmoothnessZoom(%d)",myName,MotionSmoothnessZoom))
DiscardMotionOfXBlocks=Float(Default(DiscardMotionOfXBlocks,4.0))
Assert(0.0<DiscardMotionOfXBlocks,RT_String("%s0.0 < DiscardMotionOfXBlocks(%f)",myName,DiscardMotionOfXBlocks))
VideoOutput=Default(VideoOutput,1)
Assert(0<=VideoOutput<=3, RT_String("%s0 <= VideoOutput <= 3(%d)",myName,VideoOutput))
EdgeCompensation=Default(EdgeCompensation,0)
Assert(EdgeCompensation==0||EdgeCompensation==1||EdgeCompensation==3||EdgeCompensation==4||EdgeCompensation==6,
\ RT_String("%sEdgeCompensation 0,1,3,4 or 6 only(%d)",myName,EdgeCompensation))
Resampling=Default(Resampling,2)
Assert(0<=Resampling<=2,RT_String("%s0 <= Resampling <= 2(%d)",myName,Resampling))
SkipFrameIfLessThanXPercentOfBlocksOk=Float(Default(SkipFrameIfLessThanXPercentOfBlocksOk,8.0))
Assert(0.0<=SkipFrameIfLessThanXPercentOfBlocksOk<=100.0,RT_String("%s0.0 <= SkipFrameIfLessThanXPercentOfBlocksOk <= 100.0(%f)",
\ myName,SkipFrameIfLessThanXPercentOfBlocksOk))
InitialSearchRange=Default(InitialSearchRange,30)
Assert(1<=InitialSearchRange<=99, RT_String("%s1 <= InitialSearchRange <= 99(%d)",myName,InitialSearchRange))
DiscardMotionOfBlocksMatchingValueLessThanX=Float(Default(DiscardMotionOfBlocksMatchingValueLessThanX,300.0))
Assert(-1000.0<=DiscardMotionOfBlocksMatchingValueLessThanX<=1000.0,
\ RT_String("%s-1000.0 <= DiscardMotionOfBlocksMatchingValueLessThanX <= 1000.0(%f)",
\ myName,DiscardMotionOfBlocksMatchingValueLessThanX))
DiscardMotionOfBlocksThatHave2ndBestMatchLargerThanBestMinusX=Float(Default(DiscardMotionOfBlocksThatHave2ndBestMatchLargerThanBestMinusX,4.0))
Assert(0.0<=DiscardMotionOfBlocksThatHave2ndBestMatchLargerThanBestMinusX,
\ RT_String("%s0.0 <= DiscardMotionOfBlocksThatHave2ndBestMatchLargerThanBestMinusX(%f)",
\ myName,DiscardMotionOfBlocksThatHave2ndBestMatchLargerThanBestMinusX))
LogFile=Default(LogFile,"ShakeRattleAndRoll.Log")
Assert(LogFile!="",RT_String("%sLogfile Cannot be Empty string",myName))
LogFile=RT_GetFullPathName(LogFile)
Assert(Pass==1||Exist(LogFile),RT_String("%sPass 2 Logfile Does NOT Exist(%s)",myName,LogFile))
LogFile=RT_StrReplace(LogFile,"\","\\")
AppendToFile=Default(AppendToFile,False)
StainlessS
2nd December 2018, 21:11
Post 2 of 2.
IgnorePixelsOutside=Default(IgnorePixelsOutside,False)
IgnorePixelsOutsideLeft=Default(IgnorePixelsOutsideLeft,0)
IgnorePixelsOutsideRight=Default(IgnorePixelsOutsideRight,0)
IgnorePixelsOutsideTop=Default(IgnorePixelsOutsideTop,0)
IgnorePixelsOutsideBottom=Default(IgnorePixelsOutsideBottom,0)
IgnorePixelsInside=Default(IgnorePixelsInside,False)
IgnorePixelsInsideLeft=Default(IgnorePixelsInsideLeft,0)
IgnorePixelsInsideRight=Default(IgnorePixelsInsideRight,0)
IgnorePixelsInsideTop=Default(IgnorePixelsInsideTop,0)
IgnorePixelsInsideBottom=Default(IgnorePixelsInsideBottom,0)
VideoTypeInterlaced=Default(VideoTypeInterlaced,False)
VideoTypeUpperFieldFirst=Default(VideoTypeUpperFieldFirst,False)
ExtraZoomFactor=Float(Default(ExtraZoomFactor,1.0))
Assert(0.0<ExtraZoomFactor,RT_String("%s0.0 < ExtraZoomFactor(%f)",myName,ExtraZoomFactor))
MaxCorrectionLimitsHorizontalPanning=Float(Default(MaxCorrectionLimitsHorizontalPanning,15.0))
Assert(1.0<=MaxCorrectionLimitsHorizontalPanning,RT_String("%s1.0 <= MaxCorrectionLimitsHorizontalPanning(%f)",
\ myName,MaxCorrectionLimitsHorizontalPanning))
MaxCorrectionLimitsVerticalPanning=Float(Default(MaxCorrectionLimitsVerticalPanning,15.0))
Assert(1.0<=MaxCorrectionLimitsVerticalPanning,RT_String("%s1.0 <= MaxCorrectionLimitsVerticalPanning(%f)",
\ myName,MaxCorrectionLimitsVerticalPanning))
MaxCorrectionLimitsRotation=Float(Default(MaxCorrectionLimitsRotation,5.0))
Assert(1.0<=MaxCorrectionLimitsRotation,RT_String("%s1.0 <= MaxCorrectionLimitsRotation(%f)",myName,MaxCorrectionLimitsRotation))
MaxCorrectionLimitsZoom=Float(Default(MaxCorrectionLimitsZoom,15.0))
Assert(1.0<=MaxCorrectionLimitsZoom,RT_String("%s1.0 <= MaxCorrectionLimitsZoom(%f)",myName,MaxCorrectionLimitsZoom))
UsePreviousAndFutureFramesToFillInBordersPreviousFramesEnabled=Default(UsePreviousAndFutureFramesToFillInBordersPreviousFramesEnabled,False)
UsePreviousAndFutureFramesToFillInBordersFutureFramesEnabled=Default(UsePreviousAndFutureFramesToFillInBordersFutureFramesEnabled,False)
UsePreviousAndFutureFramesToFillInBordersPreviousFrames=Default(UsePreviousAndFutureFramesToFillInBordersPreviousFrames,30)
Assert(0<=UsePreviousAndFutureFramesToFillInBordersPreviousFrames,
\ RT_String("%s0 <= UsePreviousAndFutureFramesToFillInBordersPreviousFrames(%d)",
\ myName,UsePreviousAndFutureFramesToFillInBordersPreviousFrames))
UsePreviousAndFutureFramesToFillInBordersFutureFrames=Default(UsePreviousAndFutureFramesToFillInBordersFutureFrames,30)
Assert(0<=UsePreviousAndFutureFramesToFillInBordersFutureFrames,
\ RT_String("%s0 <= UsePreviousAndFutureFramesToFillInBordersFutureFrames(%d)",
\ myName,UsePreviousAndFutureFramesToFillInBordersFutureFrames))
IgnorePixelsOutside_LetAreaFollowMotion=Default(IgnorePixelsOutside_LetAreaFollowMotion,False)
DeepAnalysisIfLessThanXPercentOfVectorsAreOk=Default(DeepAnalysisIfLessThanXPercentOfVectorsAreOk,0)
Assert(0<=DeepAnalysisIfLessThanXPercentOfVectorsAreOk<=100,
\ RT_String("%s 0 <= DeepAnalysisIfLessThanXPercentOfVectorsAreOk <= 100(%d)",myName,DeepAnalysisIfLessThanXPercentOfVectorsAreOk))
CamcorderHasARollingShutter=Default(CamcorderHasARollingShutter,false)
GenerateInterlacedProgressiveVideo=Default(GenerateInterlacedProgressiveVideo,false)
SoftBorders=Default(SoftBorders,false)
ExtrapolateColorsIntoBorder=Default(ExtrapolateColorsIntoBorder,false)
SoftBorders_EdgeTransitionWidth=Default(SoftBorders_EdgeTransitionWidth,10)
Assert(0<=SoftBorders_EdgeTransitionWidth,RT_String("%s0 <= SoftBorders_EdgeTransitionWidth(%d)",myName,SoftBorders_EdgeTransitionWidth))
DiscardMotionOfBlocksThatMoveMoreThanXPixels=Float(Default(DiscardMotionOfBlocksThatMoveMoreThanXPixels,1000.0))
Assert(0.0<DiscardMotionOfBlocksThatMoveMoreThanXPixels, RT_String("%s0.0 < DiscardMotionOfBlocksThatMoveMoreThanXPixels(%f)",
\ myName,DiscardMotionOfBlocksThatMoveMoreThanXPixels))
RememberDiscardedAreasToNextFrame=Default(RememberDiscardedAreasToNextFrame,true)
RollingShutterAmount=Float(Default(RollingShutterAmount,88.0)) ##### Any Value ???
DetectRotation=Default(DetectRotation,true)
DetectZoom=Default(DetectZoom,true)
DetectScenes_Threshold=Float(Default(DetectScenes_Threshold,20.0))
Assert(0.0<=DetectScenes_Threshold<=1000.0, RT_String("%s0.0 <= DetectScenes_Threshold <= 1000.0(%f)",
\ myName,DetectScenes_Threshold))
AdaptiveZoomSmoothness=Float(Default(AdaptiveZoomSmoothness,5000.0))
Assert(0.0<AdaptiveZoomSmoothness,RT_String("%s0.0 < AdaptiveZoomSmoothness(%f)",myName,AdaptiveZoomSmoothness))
AdaptiveZoomAmount=Float(Default(AdaptiveZoomAmount,100.0)) ##### Any Value ???
DiscardMotionOfBlocksThatHaveMaximumPixelValueDifferenceLessThanX=Default(DiscardMotionOfBlocksThatHaveMaximumPixelValueDifferenceLessThanX,20)
Assert(0<=DiscardMotionOfBlocksThatHaveMaximumPixelValueDifferenceLessThanX<=255,
\ RT_String("%s0 <= DiscardMotionOfBlocksThatHaveMaximumPixelValueDifferenceLessThanX <= 255(%d)",
\ myName,DiscardMotionOfBlocksThatHaveMaximumPixelValueDifferenceLessThanX))
DetectScenes=Default(DetectScenes,true)
UseColorMask=Default(UseColorMask,false)
MaskColorInHexRRGGBB=BitAnd(Default(MaskColorInHexRRGGBB,$FF00FF),$FFFFFF)
#########
Auto=Default(Auto,Pass==1) # Default True if Pass==1 or False if Pass==2
Assert(Pass==1 || !Auto,RT_String("%sCannot use Auto=True if Pass==2",myName))
Debug=Default(Debug,True)
DeShakerPlugName=Default(DeShakerPlugName,"Deshaker.vdf")
Assert(DeshakerPlugName!="",RT_string("%sRequires DeShakerPlugName",myName))
DeShakerPlugName=RT_GetFullPathName(DeShakerPlugName)
(Debug) ? RT_DebugF("DeShakerPlugName = '%s'",DeShakerPlugName,name=myName) : NOP
PreRoll = Max(Default(PreRoll,0),0)
#########
Fmt1="%d|%d"
Fmt2="|%d|%d|%.*f|%d|%.*f|%d|%d|%d|%d|%d|%d|%d|%d|%d|%.*f|%d|%d|%d|%.*f|%d|%.*f|%.*f|" +
\ "%s|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%.*f|%.*f|%.*f|%.*f|%.*f|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%.*f|%d|%.*f|%d|%d|%.*f|%.*f|%.*f|%d|%d|%d|%x"
S1=RT_String(Fmt1,DSVersion,Pass)
S2=RT_String(Fmt2,
\ BlockSize,DifferentialSearchRange,
\ f2ip(SourcePixelAspectValue),SourcePixelAspectValue,SourcePixelAspectSelection,
\ f2ip(DestinationPixelAspectValue),DestinationPixelAspectValue,DestinationPixelAspectSelection,
\ DestinationWidth,DestinationHeight,Scale,UsePixels,
\ MotionSmoothnessHorizontalPanning,MotionSmoothnessVerticalPanning,MotionSmoothnessRotation,MotionSmoothnessZoom,
\ f2ip(DiscardMotionOfXBlocks),DiscardMotionOfXBlocks,VideoOutput,EdgeCompensation,Resampling,
\ f2ip(SkipFrameIfLessThanXPercentOfBlocksOk),SkipFrameIfLessThanXPercentOfBlocksOk,InitialSearchRange,
\ f2ip(DiscardMotionOfBlocksMatchingValueLessThanX),DiscardMotionOfBlocksMatchingValueLessThanX,
\ f2ip(DiscardMotionOfBlocksThatHave2ndBestMatchLargerThanBestMinusX),DiscardMotionOfBlocksThatHave2ndBestMatchLargerThanBestMinusX,
\ LogFile,AppendToFile?1:0,
\ IgnorePixelsOutside?1:0,IgnorePixelsOutsideLeft,IgnorePixelsOutsideRight,IgnorePixelsOutsideTop,IgnorePixelsOutsideBottom,
\ IgnorePixelsInside?1:0,IgnorePixelsInsideLeft,IgnorePixelsInsideRight,IgnorePixelsInsideTop,IgnorePixelsInsideBottom,
\ VideoTypeInterlaced?1:0,VideoTypeUpperFieldFirst?1:0,
\ f2ip(ExtraZoomFactor),ExtraZoomFactor,
\ f2ip(MaxCorrectionLimitsHorizontalPanning),MaxCorrectionLimitsHorizontalPanning,
\ f2ip(MaxCorrectionLimitsVerticalPanning),MaxCorrectionLimitsVerticalPanning,
\ f2ip(MaxCorrectionLimitsRotation),MaxCorrectionLimitsRotation,
\ f2ip(MaxCorrectionLimitsZoom),MaxCorrectionLimitsZoom,
\ UsePreviousAndFutureFramesToFillInBordersPreviousFramesEnabled?1:0,UsePreviousAndFutureFramesToFillInBordersFutureFramesEnabled?1:0,
\ UsePreviousAndFutureFramesToFillInBordersPreviousFrames,UsePreviousAndFutureFramesToFillInBordersFutureFrames,
\ IgnorePixelsOutside_LetAreaFollowMotion?1:0,DeepAnalysisIfLessThanXPercentOfVectorsAreOk,
\ CamcorderHasARollingShutter?1:0,GenerateInterlacedProgressiveVideo?1:0,SameDestinationPropertiesAsSource?1:0,
\ SoftBorders?1:0,ExtrapolateColorsIntoBorder?1:0,SoftBorders_EdgeTransitionWidth,
\ f2ip(DiscardMotionOfBlocksThatMoveMoreThanXPixels),DiscardMotionOfBlocksThatMoveMoreThanXPixels,
\ RememberDiscardedAreasToNextFrame?1:0,
\ f2ip(RollingShutterAmount),RollingShutterAmount,
\ DetectRotation?1:0,DetectZoom?1:0,f2ip(DetectScenes_Threshold),DetectScenes_Threshold,
\ f2ip(AdaptiveZoomSmoothness),AdaptiveZoomSmoothness,
\ f2ip(AdaptiveZoomAmount),AdaptiveZoomAmount,
\ DiscardMotionOfBlocksThatHaveMaximumPixelValueDifferenceLessThanX,
\ DetectScenes?1:0,UseColorMask?1:0,MaskColorInHexRRGGBB
\ )
DBUG = true # Used during debugging
S=S1+S2
Fn=RT_String("ShakeRattleAndRoll_Debug_%d.txt",Pass)
(Debug) ? RT_DebugF("%s",S,name=myName) : NOP
(Debug&&DBUG) ? RT_WriteFile(Fn,"%s",S) : NOP
(Debug) ? RT_DebugF("Loading VDPlug='%s' As '%s', PreRoll=%d",DeShakerPlugName, "Deshaker_1",PreRoll) : NOP
LoadVirtualDubPlugin (DeShakerPlugName, "Deshaker_1", preroll=PreRoll)
Tmp=Deshaker_1(S)
(Auto) ? RT_ForceProcess(Tmp) : NOP
(Auto) ? Last : Tmp # If NOT Auto, then we return result of previous DeShaker(Pass=Whatever).
Tmp = 0 # If Auto, Force closure of tmp, allow reopen of log file for pass=2.
Fn=(Auto) ? "ShakeRattleAndRoll_Debug_2.txt" : Fn
S =(Auto) ? RT_String(Fmt1,DSVersion,2)+S2 : S
(Auto&&Debug) ? RT_DebugF("%s",S,name=myName) : NOP
(Auto&&Debug&&DBUG) ? RT_WriteFile(Fn,"%s",S) : NOP
(Auto) ? RT_Sleep(1.0) : NOP
DeShakerPlugName2=RT_FilenameSplit(DeShakerPlugName,7) + "2" + RT_FilenameSplit(DeShakerPlugName,8)
(Debug&&Auto) ? RT_DebugF("Loading VDPlug='%s' As '%s', PreRoll=%d",DeShakerPlugName2, "Deshaker_2",PreRoll) : NOP
(Auto) ? LoadVirtualDubPlugin (DeShakerPlugName2, "Deshaker_2", preroll=PreRoll) : NOP
(Debug&&Auto) ? RT_DebugF("Calling Dehaker_2(S)") : NOP
(Auto) ? Deshaker_2(S) : NOP
Return Last
}
With Deshaker.vdf and identical Deshaker2.vdf in current directory,
x86, Avs v2.60 standard, Works ok as expected. [EDIT: No it dont, sometimes also has Access Violation, but seems not as often as below]
x86, Avs+ v2.60, Sometimes works ok, sometimes Access Violation, at line
(Auto) ? LoadVirtualDubPlugin (DeShakerPlugName2, "Deshaker_2", preroll=PreRoll) : NOP
x64, Avs+ v2.60, (x64 Deshaker.vdf and identical Deshaker2.vdf in current directory) Sometimes Access Violation, at line
(Auto) ? LoadVirtualDubPlugin (DeShakerPlugName2, "Deshaker_2", preroll=PreRoll) : NOP
Sometimes "There is no function named Deshaker_2" at line
(Auto) ? Deshaker_2(S) : NOP
EDIT: Output for x64 avs+ where "There is no function named Deshaker_2" (Loading avs script into Vdub2 x64)
00000001 0.00000000 ShakeRattleAndRoll: DeShakerPlugName = 'D:\ShakeRattleAndRoll\Deshaker.vdf'
00000002 0.00067426 ShakeRattleAndRoll: 19|1|30|4|1|0|1|0|854|480|1|2|1000|1000|1000|1000|4|1|0|2|8|30|300|4|
D:\\ShakeRattleAndRoll\\ShakeRattleAndRoll.Log|0|0|0|0|0|0|0|0|0|0|0|0|0|1|15|15|5|15|0|0|30|30|0|0|0|0|1|0|0|10|1000|1|88|
1|1|20|5000|100|20|1|0|ff00ff
00000003 0.00112824 RT_DebugF: Loading VDPlug='D:\ShakeRattleAndRoll\Deshaker.vdf' As 'Deshaker_1', PreRoll=0
00000004 0.01150922 RT_ForceProcess: Commencing Forced process
00000005 0.75406694 RT_ForceProcess: 24] 5.00% nFrms=25 T=0.749sec : 33.38FpS 0.029960SpF
...
00000024 16.02638054 RT_ForceProcess: 499] 100.00% nFrms=25 T=0.842sec : 29.69FpS 0.033680SpF
00000025 16.02643585 RT_ForceProcess: Time=16.021secs (0.267mins) : Avg 31.209FpS 0.032042SpF
00000026 16.02957344 ShakeRattleAndRoll: 19|2|30|4|1|0|1|0|854|480|1|2|1000|1000|1000|1000|4|1|0|2|8|30|300|4|
D:\\ShakeRattleAndRoll\\ShakeRattleAndRoll.Log|0|0|0|0|0|0|0|0|0|0|0|0|0|1|15|15|5|15|0|0|30|30|0|0|0|0|1|0|0|10|1000|1|88|
1|1|20|5000|100|20|1|0|ff00ff
00000027 17.03472900 RT_DebugF: Loading VDPlug='D:\ShakeRattleAndRoll\Deshaker2.vdf' As 'Deshaker_2', PreRoll=0
00000028 17.03999710 RT_DebugF: Calling Dehaker_2(S)
https://i.postimg.cc/hhjXCBw9/Problem.jpg (https://postimg.cc/hhjXCBw9)
StainlessS
3rd December 2018, 04:08
Post #1 of 2
OK, this works with Avs+, x86 and x64, but produces black clip for avs 2.60 standard.
(On 2nd pass of auto, avs+ shows 1st frame black, but flashes up a "Deshaking" window for 1 frame, and then clip is displayed,
avs 2.60 standard shows no "Deshaking" window, only black clip). [EDIT: See EDIT in red at end of next post]
With VD plugins in current dir, Deshaker_x86.vdf, and Deshaker_x64.vdf.
FN="D:\G.avi"
AviSource(FN).ConvertToRGB32
trim(0,-500) # 500 frames Only
x64=False # False = x86, True=x64, Default if NOT loading into VDub
PreRoll=0
###
ProcessName = RT_GetProcessName() # Process loading avs script
RT_DebugF("ProcessName=%s",ProcessName)
x64=(ProcessName=="Virtualdub.Exe")?False:(ProcessName=="Virtualdub64.Exe")?True:x64 # Override Plugin if loading into VDub, x86 or x64
Plugin=(x64) ? "Deshaker_x64.vdf" : "Deshaker_x86.vdf" # Plugin name in current directory
ShakeRattleAndRoll(plugin=Plugin,preroll=PreRoll)
return Last
Function ShakeRattleAndRoll(clip c,Int "Pass",Int "BlockSize",Int "DifferentialSearchRange",
\ Float "SourcePixelAspectValue",Int "SourcePixelAspectSelection",
\ Float "DestinationPixelAspectValue",Int "DestinationPixelAspectSelection",
\ Int "DestinationWidth",Int "DestinationHeight",Int "Scale",Int "UsePixels",
\ Int "MotionSmoothnessHorizontalPanning",Int "MotionSmoothnessVerticalPanning",Int "MotionSmoothnessRotation",
\ Int "MotionSmoothnessZoom",Float "DiscardMotionOfXBlocks",Int "VideoOutput",Int "EdgeCompensation",Int "Resampling",
\ Float "SkipFrameIfLessThanXPercentOfBlocksOk",Int "InitialSearchRange",
\ Float "DiscardMotionOfBlocksMatchingValueLessThanX",Float "DiscardMotionOfBlocksThatHave2ndBestMatchLargerThanBestMinusX",
\ String "LogFile",Bool "AppendToFile",
\ Bool "IgnorePixelsOutside",Int "IgnorePixelsOutsideLeft",Int "IgnorePixelsOutsideRight",Int "IgnorePixelsOutsideTop",
\ Int "IgnorePixelsOutsideBottom",
\ Bool "IgnorePixelsInside",Int "IgnorePixelsInsideLeft",Int "IgnorePixelsInsideRight",Int "IgnorePixelsInsideTop",
\ Int "IgnorePixelsInsideBottom",Bool "VideoTypeInterlaced",Bool "VideoTypeUpperFieldFirst",
\ Float "ExtraZoomFactor",Float "MaxCorrectionLimitsHorizontalPanning",Float "MaxCorrectionLimitsVerticalPanning",
\ Float "MaxCorrectionLimitsRotation",Float "MaxCorrectionLimitsZoom",
\ Bool "UsePreviousAndFutureFramesToFillInBordersPreviousFramesEnabled",Bool "UsePreviousAndFutureFramesToFillInBordersFutureFramesEnabled",
\ Int "UsePreviousAndFutureFramesToFillInBordersPreviousFrames",Int "UsePreviousAndFutureFramesToFillInBordersFutureFrames",
\ Bool "IgnorePixelsOutside_LetAreaFollowMotion",Int "DeepAnalysisIfLessThanXPercentOfVectorsAreOk",
\ Bool "CamcorderHasARollingShutter",Bool "GenerateInterlacedProgressiveVideo",Bool "SameDestinationPropertiesAsSource",
\ Bool "SoftBorders",Bool "ExtrapolateColorsIntoBorder",Int "SoftBorders_EdgeTransitionWidth",
\ Float "DiscardMotionOfBlocksThatMoveMoreThanXPixels",Bool "RememberDiscardedAreasToNextFrame",
\ Float "RollingShutterAmount",Bool "DetectRotation",Bool "DetectZoom",Float "DetectScenes_Threshold",
\ Float "AdaptiveZoomSmoothness",Float "AdaptiveZoomAmount",Int "DiscardMotionOfBlocksThatHaveMaximumPixelValueDifferenceLessThanX",
\ Bool "DetectScenes",Bool "UseColorMask",Int "MaskColorInHexRRGGBB",
\ Bool "Auto", Bool "Debug",
\ String "Plugin",Int "PreRoll") {
/*
Can set Aspect Ratios directly using eg SourcePixelAspectValue=1.333 or by GUI index SourcePixelAspectSelection[0->7]
*/
Function f2ip(Float f) {return (int(f)==f) ? 0 : 6}
myName="ShakeRattleAndRoll: "
c
Assert(IsRGB32,RT_string("%sClip Must be RGB32",myName)) # Client MUST convert to RGB32 using whatever matrix and also Interlacing.
DSVersion = 19 # Fixed by DeShaker.vdf, Need modify if new version of dll
Pass=Default(Pass,1)
Assert(1<=Pass<=2, RT_String("%sPass 1 or 2 Only(%d)",myName,Pass))
BlockSize=Default(BlockSize,30)
Assert(1<=BlockSize<=100, RT_String("%s1 <= BlockSize <= 100 Only(%d)",myName,BlockSize))
DifferentialSearchRange=Default(DifferentialSearchRange,4)
Assert(1<=DifferentialSearchRange, RT_String("%s1 <= DifferentialSearchRange(%d)",myName,DifferentialSearchRange))
### GUI ### SourcePixelAspectValue OverRides GUI selection if given as arg, Otherwise uses GUI SourcePixelAspectSelection[0->7] default 0=1:1.
DefV=Defined(SourcePixelAspectValue)
SourcePixelAspectSelection = (DefV) ? -1 : Max(Default(SourcePixelAspectSelection,0),0)
Assert(-1<=SourcePixelAspectSelection<=7, RT_String("%s-1 <= SourcePixelAspectSelection <= 7(%d)", myName,SourcePixelAspectSelection))
SourcePixelAspectValue = (DefV) ? Float(SourcePixelAspectValue)
\ : Select(SourcePixelAspectSelection,1.0,1.09259,0.909091,1.45679,1.21212,1.63889,1.36364,1.33333)
Assert(0.0<SourcePixelAspectValue,RT_String("%s0.0 < SourcePixelAspectValue(%f)",myName,SourcePixelAspectValue))
### Param 52, MUST Process out-of-param-sequence
SameDestinationPropertiesAsSource=Default(SameDestinationPropertiesAsSource,true)
### GUI SameDestinationPropertiesAsSource OVERRIDES ALL, otherwise DestinationPixelAspectValue OverRides GUI selection if given as arg
DefV=Defined(DestinationPixelAspectValue)
DestinationPixelAspectSelection=(SameDestinationPropertiesAsSource)?SourcePixelAspectSelection:(DefV)?-1:Max(Default(DestinationPixelAspectSelection,0),0)
Assert(-1<=DestinationPixelAspectSelection<=7,
\ RT_String("%s-1 <= DestinationPixelAspectSelection <= 7(%d)",myName,DestinationPixelAspectSelection))
DestinationPixelAspectValue = (SameDestinationPropertiesAsSource) ? SourcePixelAspectValue : (DefV) ? Float(DestinationPixelAspectValue)
\ : Select(DestinationPixelAspectSelection,1.0,1.09259,0.909091,1.45679,1.21212,1.63889,1.36364,1.33333)
Assert(0.0<DestinationPixelAspectValue, RT_String("%s0.0 < DestinationPixelAspectValue(%f)",myName,DestinationPixelAspectValue))
###
DestinationWidth = (SameDestinationPropertiesAsSource) ? Width : Default(DestinationWidth, 640)
DestinationHeight = (SameDestinationPropertiesAsSource) ? Height : Default(DestinationHeight,480)
Assert(1<=DestinationWidth, RT_String("%s1 <= DestinationWidth(%d)",myName,DestinationWidth))
Assert(1<=DestinationHeight,RT_String("%s1 <= DestinationHeight(%d)",myName,DestinationHeight))
### End of Source/Dest Same as stuff
Scale=Default(Scale,1)
Assert(0<=Scale<=2, RT_String("%s0 <= Scale <=2(%d)",myName,Scale))
UsePixels=Default(UsePixels,2)
Assert(1<=UsePixels<=4, RT_String("%s1 <= UsePixels <= 4(%d)",myName,UsePixels))
MotionSmoothnessHorizontalPanning=Default(MotionSmoothnessHorizontalPanning,1000)
Assert(-1<=MotionSmoothnessHorizontalPanning, RT_String("%s-1 <= MotionSmoothnessHorizontalPanning(%d)",myName,MotionSmoothnessHorizontalPanning))
MotionSmoothnessVerticalPanning=Default(MotionSmoothnessVerticalPanning,1000)
Assert(-1<=MotionSmoothnessVerticalPanning, RT_String("%s-1 <= MotionSmoothnessVerticalPanning(%d)",myName,MotionSmoothnessVerticalPanning))
MotionSmoothnessRotation=Default(MotionSmoothnessRotation,1000)
Assert(-1<=MotionSmoothnessRotation,RT_String("%s-1 <= MotionSmoothnessRotation(%d)",myName,MotionSmoothnessRotation))
MotionSmoothnessZoom=Default(MotionSmoothnessZoom,1000)
Assert(-1<=MotionSmoothnessZoom, RT_String("%s-1 <= MotionSmoothnessZoom(%d)",myName,MotionSmoothnessZoom))
DiscardMotionOfXBlocks=Float(Default(DiscardMotionOfXBlocks,4.0))
Assert(0.0<DiscardMotionOfXBlocks,RT_String("%s0.0 < DiscardMotionOfXBlocks(%f)",myName,DiscardMotionOfXBlocks))
VideoOutput=Default(VideoOutput,1)
Assert(0<=VideoOutput<=3, RT_String("%s0 <= VideoOutput <= 3(%d)",myName,VideoOutput))
EdgeCompensation=Default(EdgeCompensation,0)
Assert(EdgeCompensation==0||EdgeCompensation==1||EdgeCompensation==3||EdgeCompensation==4||EdgeCompensation==6,
\ RT_String("%sEdgeCompensation 0,1,3,4 or 6 only(%d)",myName,EdgeCompensation))
Resampling=Default(Resampling,2)
Assert(0<=Resampling<=2,RT_String("%s0 <= Resampling <= 2(%d)",myName,Resampling))
SkipFrameIfLessThanXPercentOfBlocksOk=Float(Default(SkipFrameIfLessThanXPercentOfBlocksOk,8.0))
Assert(0.0<=SkipFrameIfLessThanXPercentOfBlocksOk<=100.0,RT_String("%s0.0 <= SkipFrameIfLessThanXPercentOfBlocksOk <= 100.0(%f)",
\ myName,SkipFrameIfLessThanXPercentOfBlocksOk))
InitialSearchRange=Default(InitialSearchRange,30)
Assert(1<=InitialSearchRange<=99, RT_String("%s1 <= InitialSearchRange <= 99(%d)",myName,InitialSearchRange))
DiscardMotionOfBlocksMatchingValueLessThanX=Float(Default(DiscardMotionOfBlocksMatchingValueLessThanX,300.0))
Assert(-1000.0<=DiscardMotionOfBlocksMatchingValueLessThanX<=1000.0,
\ RT_String("%s-1000.0 <= DiscardMotionOfBlocksMatchingValueLessThanX <= 1000.0(%f)",
\ myName,DiscardMotionOfBlocksMatchingValueLessThanX))
DiscardMotionOfBlocksThatHave2ndBestMatchLargerThanBestMinusX=Float(Default(DiscardMotionOfBlocksThatHave2ndBestMatchLargerThanBestMinusX,4.0))
Assert(0.0<=DiscardMotionOfBlocksThatHave2ndBestMatchLargerThanBestMinusX,
\ RT_String("%s0.0 <= DiscardMotionOfBlocksThatHave2ndBestMatchLargerThanBestMinusX(%f)",
\ myName,DiscardMotionOfBlocksThatHave2ndBestMatchLargerThanBestMinusX))
LogFile=Default(LogFile,"ShakeRattleAndRoll.Log")
Assert(LogFile!="",RT_String("%sLogfile Cannot be Empty string",myName))
LogFile=RT_GetFullPathName(LogFile)
Assert(Pass==1||Exist(LogFile),RT_String("%sPass 2 Logfile Does NOT Exist(%s)",myName,LogFile))
LogFile=RT_StrReplace(LogFile,"\","\\")
AppendToFile=Default(AppendToFile,False)
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.