forked from ae-scripting/scripting-snippets
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dropNthFrame.jsx
43 lines (31 loc) · 1.28 KB
/
dropNthFrame.jsx
1
//Script drops every Nth frame starting from a given frame//by placing TimeRemap keyframes//CC-BY Nik Ska//2014-2016var dropNthFrame = function (frameNum, startFrame) { var activeItem = app.project.activeItem; if(activeItem != null && activeItem instanceof CompItem){ var startFrame = startFrame || 0; //when to start var delta = frameNum; //Drop this frame var fd = activeItem.frameDuration; var sel = activeItem.selectedLayers; if(sel.length > 0){ app.beginUndoGroup("Dropping every " + String(delta+1) + " frame"); if(sel[0].timeRemapEnabled == false){ sel[0].timeRemapEnabled = true; } delta--; var curFrame = startFrame*fd; var tr = sel[0].property("ADBE Time Remapping"); var shift = 0; while((curFrame+fd*(delta))<sel[0].source.duration){ tr.setValueAtKey(tr.addKey(curFrame-shift*fd), curFrame); //add first tr.setValueAtKey(tr.addKey(curFrame+fd*(delta-shift)), curFrame+delta*fd); //add second +shift curFrame += (delta*fd + 2*fd); //increment frame shift++; } app.endUndoGroup(); } }}dropNthFrame(5,0);