Sagittaire
9th May 2003, 15:59
It is a script which detecte the scenes of the slow type, mediane and rapid and which filters then according to the scene that it detecte. Afflicted for my pitiful English.
###################################################################################
# AviSynth 2.51 RC4 #
# Script Motion Detection Filter YV12 #
###################################################################################
#################################### Faq ...;-) ###################################
# MPEG2Dec3.dll #
# Convolution3DYV12.dll #
# FluxSmooth-2.5.dll #
# Source : Path projet .d2v of DVD2AVI 1.76 #
# CPU_type : you will choose 5 for Pentium IV and 2 for the other processors #
# Threshold : adjustment of the threshold of detection of the scenes #
# Top : Crop top of the image #
# Left : Crop left of the image #
# Right : Crop right of the image #
# Bottom : Crop bottom of the image #
# DimX : Width of the image #
# DimY : Height of the image #
# Start : Start Frame #
# End : End Frame #
#################################### Variables ####################################
Source = "C:\Stock\azerty.d2v"
CPU_type = 2
threshold_sm = 5
threshold_hm = 15
Top = 76
Left = 16
Right = 16
Bottom = 74
DimX = 640
DimY = 272
Start = 0
End = 0
################################# Script Principal ################################
clip = Mpeg2Source( Source, idct = CPU_type)
clip = Trim( clip, Start, End)
clip = Crop( clip, Left, Top, -Right, -Bottom)
clip = Filter_Motion( clip, DimX, DimY, threshold_sm, threshold_hm)
clip = FluxSmooth( clip, 5, 3)
Return clip
#################################### Fonctions ####################################
# Motion_Hight : function of filtering of fast scenes #
function Motion_Hight( clip Hight, float X, float Y)
{
Hight = Convolution3D( Hight, 0, 8, 12, 8, 12, 3, 0)
Hight = BicubicResize( Hight, X, Y, 0.33, 0.33)
Return Hight
}
# Motion_Medium : function of filtering of Mediums scenes #
function Motion_Medium( clip Medium, float X, float Y)
{
Medium = Convolution3D( Medium, 0, 4, 6, 4, 6, 2.75, 0)
Medium = BicubicResize( Medium, X, Y, 0, 0.5)
Return Medium
}
# Motion_Slow : function of filtering of Slow scenes #
function Motion_Slow( clip Slow, float X, float Y)
{
Slow = Convolution3D( Slow, 0, 2, 3, 2, 3, 2.5, 0)
Slow = BicubicResize( Slow, X, Y, 0, 0.7)
Return Slow
}
# Detect_Motion : function of detection of scenes slow, medium and rapid #
function Detect_Motion( clip detect, clip Slow, clip Medium, clip Hight, float threshold_sm, float threshold_hm)
{
global Courant_fr = detect
output1 = Conditionalfilter( Courant_fr, Slow, Medium, "diff_Previous", "<", "threshold_sm", false)
output2 = Conditionalfilter( Courant_fr, output1, Medium, "diff_Next", "<", "threshold_sm", false)
output3 = Conditionalfilter( Courant_fr, Hight, output2, "diff_Previous", ">", "threshold_hm", false)
output4 = Conditionalfilter( Courant_fr, output3, output2, "diff_Next", ">", "threshold_hm", false)
output4 = frameevaluate( output4, "diff_Previous = YDifferenceFromPrevious( Courant_fr) + UDifferenceFromPrevious( Courant_fr) + VDifferenceFromPrevious( Courant_fr)")
output4 = frameevaluate( output4, "diff_Next = YDifferenceToNext( Courant_fr) + UDifferenceToNext( Courant_fr) + VDifferenceToNext( Courant_fr)")
return output4
}
# Filter_Motion : function of filtage of scenes slow, medium and rapid #
function Filter_Motion( clip filter, float X, float Y, float threshold_sm, float threshold_hm)
{
Slow = Motion_Slow( filter, X, Y)
Medium = Motion_Medium( filter, X, Y)
Hight = Motion_Hight( filter, X, Y)
output = Detect_Motion( filter, Slow, Medium, Hight, threshold_sm, threshold_hm)
return output
}
###################################################################################
###################################################################################
# AviSynth 2.51 RC4 #
# Script Motion Detection Filter YV12 #
###################################################################################
#################################### Faq ...;-) ###################################
# MPEG2Dec3.dll #
# Convolution3DYV12.dll #
# FluxSmooth-2.5.dll #
# Source : Path projet .d2v of DVD2AVI 1.76 #
# CPU_type : you will choose 5 for Pentium IV and 2 for the other processors #
# Threshold : adjustment of the threshold of detection of the scenes #
# Top : Crop top of the image #
# Left : Crop left of the image #
# Right : Crop right of the image #
# Bottom : Crop bottom of the image #
# DimX : Width of the image #
# DimY : Height of the image #
# Start : Start Frame #
# End : End Frame #
#################################### Variables ####################################
Source = "C:\Stock\azerty.d2v"
CPU_type = 2
threshold_sm = 5
threshold_hm = 15
Top = 76
Left = 16
Right = 16
Bottom = 74
DimX = 640
DimY = 272
Start = 0
End = 0
################################# Script Principal ################################
clip = Mpeg2Source( Source, idct = CPU_type)
clip = Trim( clip, Start, End)
clip = Crop( clip, Left, Top, -Right, -Bottom)
clip = Filter_Motion( clip, DimX, DimY, threshold_sm, threshold_hm)
clip = FluxSmooth( clip, 5, 3)
Return clip
#################################### Fonctions ####################################
# Motion_Hight : function of filtering of fast scenes #
function Motion_Hight( clip Hight, float X, float Y)
{
Hight = Convolution3D( Hight, 0, 8, 12, 8, 12, 3, 0)
Hight = BicubicResize( Hight, X, Y, 0.33, 0.33)
Return Hight
}
# Motion_Medium : function of filtering of Mediums scenes #
function Motion_Medium( clip Medium, float X, float Y)
{
Medium = Convolution3D( Medium, 0, 4, 6, 4, 6, 2.75, 0)
Medium = BicubicResize( Medium, X, Y, 0, 0.5)
Return Medium
}
# Motion_Slow : function of filtering of Slow scenes #
function Motion_Slow( clip Slow, float X, float Y)
{
Slow = Convolution3D( Slow, 0, 2, 3, 2, 3, 2.5, 0)
Slow = BicubicResize( Slow, X, Y, 0, 0.7)
Return Slow
}
# Detect_Motion : function of detection of scenes slow, medium and rapid #
function Detect_Motion( clip detect, clip Slow, clip Medium, clip Hight, float threshold_sm, float threshold_hm)
{
global Courant_fr = detect
output1 = Conditionalfilter( Courant_fr, Slow, Medium, "diff_Previous", "<", "threshold_sm", false)
output2 = Conditionalfilter( Courant_fr, output1, Medium, "diff_Next", "<", "threshold_sm", false)
output3 = Conditionalfilter( Courant_fr, Hight, output2, "diff_Previous", ">", "threshold_hm", false)
output4 = Conditionalfilter( Courant_fr, output3, output2, "diff_Next", ">", "threshold_hm", false)
output4 = frameevaluate( output4, "diff_Previous = YDifferenceFromPrevious( Courant_fr) + UDifferenceFromPrevious( Courant_fr) + VDifferenceFromPrevious( Courant_fr)")
output4 = frameevaluate( output4, "diff_Next = YDifferenceToNext( Courant_fr) + UDifferenceToNext( Courant_fr) + VDifferenceToNext( Courant_fr)")
return output4
}
# Filter_Motion : function of filtage of scenes slow, medium and rapid #
function Filter_Motion( clip filter, float X, float Y, float threshold_sm, float threshold_hm)
{
Slow = Motion_Slow( filter, X, Y)
Medium = Motion_Medium( filter, X, Y)
Hight = Motion_Hight( filter, X, Y)
output = Detect_Motion( filter, Slow, Medium, Hight, threshold_sm, threshold_hm)
return output
}
###################################################################################