# 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" # load required modules LoadModule("avslib", "base", "core") LoadModule("avslib", "array", "core") LoadModule("avslib", "array", "operators") LoadModule("avslib", "array", "slices") LoadModule("avslib", "filters", "stack") # Function to load sequentially numbered (.avi) clips Function ClipSource(string path, int start, int end, int "pad") { Assert(start >= 0, "ClipSource: 'start' must be >= 0") Assert(end >= 0, "ClipSource: 'end' must be >= 0") pad = Max2(0, Default(pad, 0)) # values <= 0 result in no padding fmt = "%0" + String(pad) + ".0f" fname = path + String(start, fmt) + ".avi" return start <= end \ ? ArrayJoin( ArrayCreate(AVISource(fname)), ClipSource(path, start + 1, end, pad) ) \ : "" } vids = ClipSource("file", 1, 6, 3) # calculate appropriate rows and columns (as the StackToFit filter does) vlen = vids.ArrayLen rows = Round(Sqrt(vlen)) cols = Ceil(Sqrt(vlen)) # reduce size to avoid making the final clip too wide / tall vids = vids.ArrayOpFunc("ReduceBy2") # stack them in a rows x cols table return Stack(vids, rows, cols)