EditingFunctions
From Avisynth wiki
Here are some functions I made and added to my plugins directory because I was sick of typing them so much. Hope you find them useful.
# inserts the clip 'inclip' into 'old' at index 'frame'
function Insert (clip old, clip inclip, int frame)
{
return old.Trim(0, frame - 1) + inclip + old.Trim(frame, 0)
}
# as above, using aligned splices
function AlignedInsert (clip old, clip inclip, int frame)
{
return old.Trim(0, frame - 1) ++ inclip ++ old.Trim(frame, 0)
}
# replace 'numframes' frames of 'old' with 'inclip', starting at 'frame'
function Replace (clip old, clip inclip, int frame, int numframes)
{
numframes = ((numframes == 0) || (numframes > inclip.framecount)) ? inclip.framecount : numframes
return old.Trim(0, frame - 1) + inclip.Trim(0, numframes) + old.Trim(frame + numframes, 0)
}
# as above, using aligned splices
function AlignedReplace (clip old, clip inclip, int frame, int numframes)
{
numframes = (numframes == 0 || numframes > inclip.framecount) ? inclip.framecount : numframes
return old.Trim(0, frame - 1) ++ inclip.Trim(0, numframes) ++ old.Trim(frame + numframes, 0)
}