Page 1 of 1

save frame as... through a script

Posted: February 25th, 2008, 2:34 pm
by ajk48n
I'm trying to automate the "Save Frame As...File" function through a script. I've gotten it to work by sending an item to the render queue, changing the duration of the render to be 1 frame, and using a jpg template for the output module.

The problem comes in when naming what the render will be called. I do not want the render to have the time code or frame number in it.

If I save a frame through the interface, then the render will get named "comp_name (0;00;03;09)"
Then, clicking on the templates in the "Output To:" field, I can choose "Comp Name", and my comp will render as "comp_name"

If I run my script, I can set the output to be set as "comp name". However, if I then choose "Comp Name" (or any other Output To: template), and get the additional "[####]" added to the name.

Is there any way to add an item to the render queue, and not have it default back to "[####]", besides going into each comp, and running "Save Frame As..."

Hopefully this makes sense, and thanks for any help.

Re: save frame as... through a script

Posted: February 25th, 2008, 3:30 pm
by lloydalvarez
If you don't want the frame number, am I assuming that you are not exporting more than 1 frame? If so, why do you need a script?

Re: save frame as... through a script

Posted: February 25th, 2008, 3:42 pm
by ajk48n
I need to be able to select a few hundred comps, and save out a single frame from each one. However, I also may need to change the "Output To:" name, depending on the factors in the comp, (ex. just a color channel, just an alpha, embedded alpha, etc.). So it would be very helpful if I could change the name the comp renders to, without the numbers getting added at the end.

Re: save frame as... through a script

Posted: February 25th, 2008, 3:49 pm
by lloydalvarez
I see, here's some code from a script that I wrote to set the output modules, including the file name:

Code: Select all

var curItem = app.project.renderQueue.item(existingRQ+1+a);
curItem.outputModule(1).file = new File(newLocation + "/" + network +  element  + /gi,"_") + OMSetterData.strFolderSuffix + "/" + network + element + /gi,"_") + OMSetterData.strOM1HDSuffix);
Let me know if you have any questions.

Re: save frame as... through a script

Posted: November 11th, 2009, 2:32 pm
by jkcraig
Though much time has passed on this topic...

I am having the same issue. I am scripting the creation of qicktimes etc. and also want to generate a single jpg thumbnail. There seems to be a flag set somewhere (in CS4 at least) that differentiates between rendering a single frame and rendering a sequence that is 1 frame long.
Small section of the code I am using:
var outFile = new File(outputFolder+"/"+outputModule.fileName);
// outfile= c:\temp\[compName]-thumbnail.jpg
qItem.outputModule(idx+1).file = outFile;
// When it is added to the module it converts [compName] to the comp name as it should
// However it ends up looking like this: (lets say the comp is named 'clip')
// c:\temp\clip-thumbnail.jpg_[#####].jpg
// If I trim it off the end and it looks ok in the queue
var messedUpName=qItem.outputModule(idx+1);
qItem.outputModule(idx+1).file=new File(outputFolder+"/"+messedUpName.replace(/_%5B#####%5D\.[^\._-]+$/i,''));
// Set it to a single frame in the middle of the comp
var halfTime=qItem.comp.duration/2;
halfTime=halfTime-(halfTime%qItem.comp.frameDuration); // make it a whole frame by subtracting the remainder
qItem.timeSpanStart=halfTime; // Use middle frame
qItem.timeSpanDuration=qItem.comp.frameDuration; // One frame long

When I hit render it will actually create a frame named like this:
Here is a couple of screen caps with a reproducible (for me) symptom.
If 'Output Info:' says 'Single frame' I can edit the filename all I want.
If it says '-' then AE will add _[#####].jpg to whatever name I type.
Is this reproducible for anyone else? Any Ideas?

Re: save frame as... through a script

Posted: November 11th, 2009, 2:45 pm
by lloydalvarez
This is a known bug. The only way I have been able to work around it to render then correct the file name using File.rename(newName)


Re: save frame as... through a script

Posted: December 21st, 2017, 3:09 am
by almosvagyok
hey there! is the any news regarding this question? i'm struggling with the same exact problem, however, in my case, renaming AFTER the render is not an option.

I found this but not the best method.