BobbingBob
30th January 2009, 18:33
I'm trying to make a script to generate a thumbnail sheet preview of a video. Now this is working very well with fixed frame numbers, but as with other preview generators you often get frames that are in the middle of a scene transition or other garbage. So I'd like to add scene change detection and use scene start frames to generate the thumbnails.
So my question is this: is there a way to loop on a series of frames to look for a scene change without the frames being requested by the calling application? Something like this seems to work fine in finding non solid scene change frames, but I can't figure out how to script this without playing the whole video... is it possible or was AviSynth simply not designed for that?
scene_end = BlankClip(last)
scene_begin = last
global_motion = BlankClip(last)
last_sc = 0
ScriptClip(last, "SCSelect(scene_begin, scene_end, global_motion, dfactor=4)")
FrameEvaluate(last, "last_sc = Crop(0, 0, last.Width/2, 0).AverageChromaU() == Crop(last.Width/2, 0, 0, 0).AverageChromaU() ? last_sc : current_frame")
ScriptClip(last, "SubTitle(last, String(last_sc), x=Round(0*last.Width), y=Round(0.1*last.Height), align=4, size=70)")
Otherwise I guess I could playback a script that writes scene start frames to a text file, run it with mplayer -vo null -speed 100 and then use that info in another script, but it doesn't sound like a very nice solution...
Any tips would be appreciated :thanks:
So my question is this: is there a way to loop on a series of frames to look for a scene change without the frames being requested by the calling application? Something like this seems to work fine in finding non solid scene change frames, but I can't figure out how to script this without playing the whole video... is it possible or was AviSynth simply not designed for that?
scene_end = BlankClip(last)
scene_begin = last
global_motion = BlankClip(last)
last_sc = 0
ScriptClip(last, "SCSelect(scene_begin, scene_end, global_motion, dfactor=4)")
FrameEvaluate(last, "last_sc = Crop(0, 0, last.Width/2, 0).AverageChromaU() == Crop(last.Width/2, 0, 0, 0).AverageChromaU() ? last_sc : current_frame")
ScriptClip(last, "SubTitle(last, String(last_sc), x=Round(0*last.Width), y=Round(0.1*last.Height), align=4, size=70)")
Otherwise I guess I could playback a script that writes scene start frames to a text file, run it with mplayer -vo null -speed 100 and then use that info in another script, but it doesn't sound like a very nice solution...
Any tips would be appreciated :thanks: