How to render a mp4 animation from jsx script?

New Here ,
Feb 21, 2021 Feb 21, 2021

Copy link to clipboard

Copied

I have some complex automation in Photoshop based on a jsx script that calls some actions to create both a static image and an animation automatically.

The logic and sequence in the script is working perfectly fine and the only thing that I still need to figure out in my script is how I can have the jsx script to execute the same export as I would get by clicking on File > Export > Render Video

I want my script to set all the options and perform the export automatically without user interaction.

 

Here is a snippet of the code just to show where I would place the render if I can discover how to do it.

 

var minhapasta = File($.fileName).parent.fsName;

var basenome = prompt("Escreva a base do nome de arquivos para usar! (evite acentos e caracteres especiais", "my_test_files"); 

var doc = app.activeDocument;

var jpgOptions = new JPEGSaveOptions();
jpgOptions.quality = 12;
jpgOptions.embedColorProfile = true;
jpgOptions.formatOptions = FormatOptions.PROGRESSIVE;
if(jpgOptions.formatOptions == FormatOptions.PROGRESSIVE){
jpgOptions.scans = 5};
jpgOptions.matte = MatteType.NONE;

doAction("pedaco1","Marcus Tavares - auto");
//first save as static image (working fine)
doc.saveAs (new File(decodeURI(minhapasta) +'/' + basenome + '01' + '.jpg'), jpgOptions, true);
//then just after saving a copy as static image, I should have the block that renders the animation that is already created by the action and name it using this: decodeURI(minhapasta) +'/' + basenome + '01' + '.mp4'

 

Could you please help with this? I searched everywhere and could not find a reference so I could base in it.

 

Thanks!

TOPICS
Actions and scripting

Views

68

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 2 Correct Answers

Most Valuable Participant , Feb 21, 2021 Feb 21, 2021
Do you have Adobe Scriptlistener plug-in installed. If you do use file>Export>Render Video... fill in the dialog for the way you want to encode and save the video.  The create a Javascript render function for your script using the action manager code recorded by Adobe plug-in. After your script run the action  and save a jpeg file add a step that uses the function you created to render a video. .

Likes

translate

Translate

Translate
New Here , Feb 23, 2021 Feb 23, 2021
Thanks!That was exactly what I was looking for. I used script listener and this cleaner script to translate the captured code into a more readable javascript code.For others who may arrive in this thread in the future, this is the function for exporting the timeline as MP4.function export2(directory, name2, ameFormatName, amePresetName, useDocumentSize, frameRate, manage, selectedFrames, quality, Z3DPrefHighQualityErrorThreshold) { var s2t = function (s) { return app.stringIDToTypeID(s); }; ...

Likes

translate

Translate

Translate
Most Valuable Participant ,
Feb 21, 2021 Feb 21, 2021

Copy link to clipboard

Copied

Do you have Adobe Scriptlistener plug-in installed. If you do use file>Export>Render Video... fill in the dialog for the way you want to encode and save the video.  The create a Javascript render function for your script using the action manager code recorded by Adobe plug-in. After your script run the action  and save a jpeg file add a step that uses the function you created to render a video. .

JJMack

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 23, 2021 Feb 23, 2021

Copy link to clipboard

Copied

Thanks!

That was exactly what I was looking for. I used script listener and this cleaner script to translate the captured code into a more readable javascript code.

For others who may arrive in this thread in the future, this is the function for exporting the timeline as MP4.

function export2(directory, name2, ameFormatName, amePresetName, useDocumentSize, frameRate, manage, selectedFrames, quality, Z3DPrefHighQualityErrorThreshold) {
	var s2t = function (s) {
		return app.stringIDToTypeID(s);
	};

	var descriptor = new ActionDescriptor();
	var descriptor2 = new ActionDescriptor();

	descriptor2.putPath( s2t( "directory" ), directory );
	descriptor2.putString( s2t( "name" ), name2 );
	descriptor2.putString( s2t( "ameFormatName" ), ameFormatName );
	descriptor2.putString( s2t( "amePresetName" ), amePresetName );
	descriptor2.putBoolean( s2t( "useDocumentSize" ), useDocumentSize );
	descriptor2.putDouble( s2t( "frameRate" ), frameRate );
	descriptor2.putEnumerated( s2t( "pixelAspectRatio" ), s2t( "pixelAspectRatio" ), s2t( "document" ));
	descriptor2.putEnumerated( s2t( "fieldOrder" ), s2t( "videoField" ), s2t( "preset" ));
	descriptor2.putBoolean( s2t( "manage" ), manage );
	descriptor2.putBoolean( s2t( "selectedFrames" ), selectedFrames );
	descriptor2.putEnumerated( s2t( "renderAlpha" ), s2t( "alphaRendering" ), s2t( "none" ));
	descriptor2.putInteger( s2t( "quality" ), quality );
	descriptor2.putInteger( s2t( "Z3DPrefHighQualityErrorThreshold" ), Z3DPrefHighQualityErrorThreshold );
	descriptor.putObject( s2t( "using" ), s2t( "videoExport" ), descriptor2 );
	executeAction( s2t( "export" ), descriptor, DialogModes.NO );
}

//call it like this
var minhapasta = File($.fileName).parent.fsName;
export2(new File( minhapasta ), 'myvideo.mp4', "H.264", "1_High Quality.epr", true, 23.976, true, true, 1, 5);

 

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines