Can please someone here help me out on this topic, i am new to AFX/java scripting and i already spent around 15h on that
subject but it simply does not work-
the background:
we are shooting DPX sequences with a Convergent Design ODYSSEY SSD recorder, thats the only way for it to get perfect
image quality inside the box, i want 4:4:4 and RGB together with minimal compression (and the box is not yet able to do ProRes4444).
For editing/finishing purpose it is way easier to work with .MOV files instead of image sequences (as we are producing around 100.000 DPX files a day,
compared to around 80 .MOV files)
the task:
create a script that imports a DPX sequence from a folder,
imports the corresponding .WAV file with same starting name too,
creates a new timeline in AFX "from DPX sequence selection" (to keep the timcode!)
renders that timeline with a given output module to another given folder
deletes all items and projects afterwards
Somehow, I managed to do that, it works most of the time but function "app.executeCommand(app.findMenuCommandId("New Comp from Selection"
seems to be buggy somehow, does not work everytime or just after you did that at least once manually inside AFX ?
the bonus task (thats where i failed)
create a folder selection dialog that reads all subfolders (with the corresponding DPX sequences inside) to an array
use that array to get the sequence file names and count the number of Sub-directories
do the above (Seq conversion from "the task") to ALL THOSE SUBDIRECTORIES (using the names from the array)
this cant be that complex ... right ???
i tried to implement it but somehow i always get the error "/e/ODYSSEY/S020_AK0787/S020_AK0787_0000000.dpx is not a File or Folder"
(as this is the image sequence that should be imported - there must be some wrong interpretation between the file name with whole filepath and
the import function ?)
Any help is hugely appreciated, i am also willing to donate for help/a working script
(as i cannot afford to enter around 1.000 folders by myself)
i can also provide such a Odyssey file structure for testing/help purposes via wetransfer
thanks
Script below:
_______________________________________________________
var SourceFolder = Folder.selectDialog("Choose SOURCE folder: ");
var SourcePath = decodeURI(SourceFolder.toString());
var DestFolder = Folder.selectDialog("Choose DESTINATION folder: ");
var DestPath = decodeURI(DestFolder.toString());
var scriptName = "DPX Sequence TO MOV DNxHD with Audio + TC";
var intendedFootageFPS = 25;
var fileToImport, fileToImport2;sidecarFile, sidecarContents, importOpts, footageItem, filePath, fileBaseName, audioFile, audioFootageItem;
var FolderName, SourcePath;
var scriptName = "Change Render Locations";
function checkForFiles(folderItem, tabString) {
var theFiles = folderItem.getFiles();
for(var c = 0; c < theFiles.length; c++){
//resultArray.push(tabString + theFiles[c].name + "\r");
resultArray.push(tabString + theFiles[c].name);
//if (theFiles[c] instanceof Folder)
{
// checkForFiles(theFiles[c], tabString + "\t");
}
}
}
function AFXConvert(FolderName) {
app.newProject();
// fileToImport = File.openDialog("Select file from the DPX sequence", "*.dpx", false);
// if (!fileToImport || !fileToImport.exists) {
// }
app.beginUndoGroup(scriptName);
app.project.showWindow = true;
fileToImport2 = (SourcePath + "/"+ e + "/" + e + "_0000000.dpx");
alert("Folder Import Name " + fileToImport2);
importOpts = new ImportOptions(fileToImport2);
importOpts.sequence = true; // import as sequence
importOpts.forceAlphabetical = true; // force alphabetical order (to work around 3709647)
app.project.importFile(importOpts);
app.executeCommand(app.findMenuCommandId("New Comp from Selection"));
//app.executeCommand(app.findMenuCommandId("New Comp from Selection")); //sometimes it works better with 2 or 3x ???
//app.executeCommand(app.findMenuCommandId("New Comp from Selection"));
footageItem.name = decodeURI(fileToImport2.name).replace(/\.\d+\.png/, ""); // remove the numeric part for the footage item name
footageItem.mainSource.conformFrameRate = 25;
// if matching audio recording (WAV file), import that
filePath = footageItem.file.path;
fileBaseName = (footageItem.file.name).replace("_0000000.dpx","");
audioFile = new File(filePath + "/" + fileBaseName + ".WAV");
audioFootageItem = app.project.importFile(new ImportOptions(audioFile));
comp = app.project.item(1).layers.add(audioFootageItem);
audioFootageItem.selected = true;
comp.selected = true;
comp = app.project.item(1);
comp.openInViewer();
app.project.item(1).layer(2).moveToBeginning();
app.endUndoGroup();
app.project.renderQueue.items.add(comp);
app.project.renderQueue.item(1);
app.project.renderQueue.item(1).outputModule(1).file = new File("D:/" + e + ".MOV");
//alert("d:/" + fileBaseName + ".MOV");
app.project.renderQueue.item(1).outputModule(1).applyTemplate("QUICKTIME DNxHD 365 RGB444 Audio");
app.project.renderQueue.item(1).outputModule(1).postRenderAction.NONE;
app.project.renderQueue.render(1);
app.project.renderQueue.item(1).remove()
app.project.item(1).remove();
app.project.item(1).remove();
app.project.item(1).remove();
}
//---------------------------------------------------------------------------------------- ------------------------------------
//PROGRAM START
//---------------------------------------------------------------------------------------- ------------------------------------
app.project.close(CloseOptions.DO_NOT_SAVE_CHANGES);
if(SourceFolder != null){
var resultArray = new Array(1); //clear old array to 1 entry
var resultArray = new Array();
checkForFiles(SourceFolder, "");
$.writeln(resultArray.toString().replace("",""));
//alert(resultArray);
var FolderCount = resultArray.length;
alert("Number of folders: " + FolderCount);
}
if(DestFolder != null){ //Makes sure root folder choice was not canceled
var d1 = resultArray.toString();
}
//----ENCODING LOOP ----------------------------------------------------------
var e = resultArray.shift();
for(var k=0; k<FolderCount; k++){
alert("Array/Folder Counter: " + k +":" + e);
//resultArray.toString(resultArray);
fObj = Folder(DestPath + "/"+ e);
fObj.create();
AFXConvert(e);
var e = resultArray.shift();
}