frank10
13th December 2005, 15:18
I am learning avisynth advanced scripting and I tried to write a script to
treat a clip with different settings at different scenes (dark-normal).
So I made a detect scene-change routine and then with a conditional filter I'm trying to switch the scene, based on the averageLuma of the frame that was just changed: dark scenes will get some filtering, normal one another one:
AviSource("D:\Temp\temp.avi").ConvertToYV12()
change = -1
b = last
# this reports to zero the variable after the scene change:
frameevaluate(" change = (change == -1) ? averageLuma(b) : change ")
# this should return a different filtered clip based on the average luma of the frame of the
# scene just changed:
scriptclip(""" (change == -1) && (avgL > 40) ? Tweak(0.0, 0.0,0.0,1.3).subtitle(display + "normal") : Tweak(0.0, 1.6,0.0,2.0).subtitle(display + "dark") """)
# this is only for test-display purpose:
frameevaluate( """ display = String(change) + " avg:" + String(avgL) """)
# this evaluates the averageLuma of current frame:
frameevaluate( " avgL = averageLuma(b) ")
#this detects scene change:
frameevaluate( "change = (YDifferenceToNext(b)-YDifferenceFromPrevious(b) < -7) ? -1 : change ")
It works all well, BUT I can change only the filtering of the *current frame* just changed.
How can I make *all frames* from a scene change to another one, change according to the luma measured on the scene change?
i.e:
sceneA - sceneB
measure luma on the first frame of sceneA (this works)
filter *all* frames from this to the new sceneB, according to the measured Luma (THIS doesn't work)
repeat for all scenes...
Thank you a lot for your suggestions
treat a clip with different settings at different scenes (dark-normal).
So I made a detect scene-change routine and then with a conditional filter I'm trying to switch the scene, based on the averageLuma of the frame that was just changed: dark scenes will get some filtering, normal one another one:
AviSource("D:\Temp\temp.avi").ConvertToYV12()
change = -1
b = last
# this reports to zero the variable after the scene change:
frameevaluate(" change = (change == -1) ? averageLuma(b) : change ")
# this should return a different filtered clip based on the average luma of the frame of the
# scene just changed:
scriptclip(""" (change == -1) && (avgL > 40) ? Tweak(0.0, 0.0,0.0,1.3).subtitle(display + "normal") : Tweak(0.0, 1.6,0.0,2.0).subtitle(display + "dark") """)
# this is only for test-display purpose:
frameevaluate( """ display = String(change) + " avg:" + String(avgL) """)
# this evaluates the averageLuma of current frame:
frameevaluate( " avgL = averageLuma(b) ")
#this detects scene change:
frameevaluate( "change = (YDifferenceToNext(b)-YDifferenceFromPrevious(b) < -7) ? -1 : change ")
It works all well, BUT I can change only the filtering of the *current frame* just changed.
How can I make *all frames* from a scene change to another one, change according to the luma measured on the scene change?
i.e:
sceneA - sceneB
measure luma on the first frame of sceneA (this works)
filter *all* frames from this to the new sceneB, according to the measured Luma (THIS doesn't work)
repeat for all scenes...
Thank you a lot for your suggestions