# AVSLib :: sample script # Copyright (c) 2007 George Zarkadas (gzarkadas@users.sourceforge.net) # This program is free software; you can redistribute it and/or modify it under the terms of # the GNU General Public License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; # without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR # PURPOSE. See the GNU General Public License for more details. # You should have received a copy of the GNU General Public License along with this program; # if not, write to the "Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, # MA 02111-1307 USA" LoadModule("avslib", "array", "properties") LoadModule("avslib", "filters", "frames") Function ExportFrames(clip clp, string frames, string "path", string "type", bool "info") { # frames export runtime script; needs array::properties module FF_EXPORT = """ expframes = %q file = %q type = LCase(%q) info = %b # Overlay is used to avoid colorspace conversion if type != ebmp expframes.ArrayContains(current_frame) ? ( \ type == "ebmp" ? \ ImageWriter(last, file, current_frame, current_frame + 1, type, info) \ : \ Overlay(last, ImageWriter(last.ConvertToRGB24, file, current_frame, current_frame + 1, \ type, info), opacity=0, ignore_conditional=true) \ ) : last """ path = Default(path, "frame") type = Default(type, "ebmp") info = Default(info, false) return FrameFilter(clp, FF_EXPORT, frames, path, type, info) } expframes = "5,23,35,55,99" # export these frames only clp = AVISource("story.avi").ConvertToYUY2 ExportFrames(clp, expframes, "selected", "jpg") Compare(last, clp) # verify that clp is passed through ExportFrames untouched