Reverse Footage Script

What type of scripts do you need?

Moderator: byronnash

Post Reply
rdarton
Posts: 2
Joined: January 11th, 2014, 12:15 pm

Hello all,

I'm here to ask a favor. I do not know Javascript at all. I wrote an AppleScript that when ran will open a video file with AE and then run a script (which needs to be written). I need a script that will:

1) Move whatever is in the 'Project Panel' to the 'Composition Panel'
2) Execute 'Layer > Time > Time-Reverse Layer'
3) Render the video, retaining original quality (saving in a specified folder).
4) Execute 'File > New > New Project'
5) Select 'Don't Save'

Could someone please help me get this script written? I would very much appreciate it!

Thanks in advance!
tschomp
Posts: 3
Joined: February 10th, 2014, 1:14 pm

Hey there! Would love to help you out if you still need this done, but I had a few questions.

-When you say "Move whatever is in the 'Project Panel' to the 'Composition Panel'" -- knowing the purpose of the Script would be useful. Would this just be one video that needs to be turned into a composition? Or would it be an image sequence? Or would it be a number of files, and if so, how should they relate to one another in the composition?

-What is the purpose for creating a new project at step 4?

If you still need this script, just let me know and I'll see if I can come up with something! Thanks
rdarton
Posts: 2
Joined: January 11th, 2014, 12:15 pm

Hey tschomp! So excited to see your post! Thank you for your willingness to help.

To better explain, I have created a watch folder on my mac and whenever a video file is dropped in the folder, my mac opens the file with AE and then runs an assigned script. The goal is to have an AE script that creates a reversed version of the footage. That way, every time I drop a video file in my watch folder, I will automatically get a reversed version of the video file without clicking a single button.

The reason the script should create a new project at step 4 is because that will allow me to drop another video file in my watch folder after one has already been processed and have the script work again without issue.

I've revised my list after realizing that it could be better communicated.

1) Execute 'File > New Comp From Selection'
2) Execute 'Layer > Time > Time-Reverse Layer'
3) Render the video (using the last settings and 'save to' location used).
4) Execute 'File > New > New Project'
5) Select 'Don't Save'


I was able to find someone to help me to a point but I haven't been able to get a hold of him for a while and the script still needs some fine tuning. I'm going to show you two versions of the script that he came up with.

This first script works but isn't reliable. Sometimes the script will run so fast that it will jump to the enableTimeRemapping function before AE even has time to create the comp, resulting in a pop up error message in AE (because there is no comp available to reverse). This didn't happen every time, but enough to be an issue. The script was about 50% reliable. Here's the script:

function createComp()
{
var sourceItem = app.project.selection[0];
app.executeCommand(app.findMenuCommandId("New Comp from Selection"));
}

function enableTimeRemapping()
{

var proj = app.project;
var comp = proj.activeItem;
var activeLayer, curTime, newKey;

/*


return;
} else if (comp.selectedLayers.length != 1){
alert("Select only one comp.");
return;
} else if (!(comp.selectedLayers[0].canSetTimeRemapEnabled)){
alert("Cannot be remapped.)");
return;
}
*/

activeLayer = comp.selectedLayers[0];
curTime = comp.time;
if (activeLayer.timeRemapEnabled == false){
activeLayer.timeRemapEnabled = true; // enable time-remapping
activeLayer.timeRemap.selected = true; // select all keyframes
} else {
newKey = activeLayer.timeRemap.addKey(curTime);
for (i = 1; i < activeLayer.timeRemap.numKeys; i++) {
activeLayer.timeRemap.setSelectedAtKey(i, false);
}
activeLayer.timeRemap.setSelectedAtKey(newKey, true);
}
app.executeCommand(app.findMenuCommandId("Time-Reverse Keyframes"));
}

function addToRenderQueue()
{
var activeItem = app.project.activeItem;
var myQueue = app.project.renderQueue;
var theRender = app.project.renderQueue.items.add(activeItem);
myQueue.render(1);
}

function createNewProject()
{
app.project.close(CloseOptions.DO_NOT_SAVE_CHANGES);
app.newProject();
}

createComp();
enableTimeRemapping();
addToRenderQueue();
createNewProject();



After telling him about the occasional error message because of the script jumping ahead before the comp was created, he sent me this next script. This script is reliable and essentially does everything right, but doesn't actually result in a reversed video:

function createComp() {
$.writeln("createComp");
var sourceItem = app.project.selection[0];
var theComp = app.project.items.addComp(sourceItem.name, sourceItem.width, sourceItem.height, sourceItem.pixelAspect, sourceItem.duration, sourceItem.frameRate);
theComp.layers.add(sourceItem);
return theComp;
}

function enableTimeRemapping(comp) {
$.writeln("enableTimeRemapping");
var proj = app.project;
var activeLayer, curTime, newKey;

activeLayer = comp.layer(1);
curTime = comp.time;
if (activeLayer.timeRemapEnabled == false) {
activeLayer.timeRemapEnabled = true; // enable time-remapping
activeLayer.timeRemap.selected = true; // select all keyframes
} else {
newKey = activeLayer.timeRemap.addKey(curTime);
for (i = 1; i < activeLayer.timeRemap.numKeys; i++) {
activeLayer.timeRemap.setSelectedAtKey(i, false);
}
activeLayer.timeRemap.setSelectedAtKey(newKey, true);
}
app.executeCommand(app.findMenuCommandId("Time-Reverse Keyframes"));
}


function addToRenderQueue(comp) {
$.writeln("addToRenderQueue");
var myQueue = app.project.renderQueue;
var theRender = app.project.renderQueue.items.add(comp);
myQueue.render(1);
}

function createNewProject() {
$.writeln("createNewProject");
app.project.close(CloseOptions.DO_NOT_SAVE_CHANGES);
app.newProject();
}

var newComp = createComp();
enableTimeRemapping(newComp);
addToRenderQueue(newComp);
createNewProject();


Are you able to look at both of those scripts and come up with a hybrid that gets the job done? Thanks again for joining the conversation. I'm looking forward to having this script done!
Post Reply