Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Assume new framerate to imported sequence

  • Assume new framerate to imported sequence

    Posted by Tom Pinnes on January 17, 2021 at 7:09 pm

    Hello,

    I am trying to create a script that imports an image sequence and changes the framerate to 1 and creates a comp, however I can’t seem to find a way to do it.

    Here’s my code so far-

    var importFolder = new File (“c:\\”); // Set default import folder

    var myImportFolder = importFolder.openDlg(“Select files to import”,”*.tif”,true).toString(); /// Select import folder path

    var myImportOptions = new ImportOptions(File(myImportFolder)); /// Import options

    myImportOptions.importAs = ImportAsType.FOOTAGE;

    myImportOptions.sequence = true; /// Import sequence

    myImportOptions.forceAlphabetical = true; /// Force alphabetical

    var newSequence = app.project.importFile(myImportOptions); /// Set new import files to var

    var frameRate = newSequence.frameRate;

    var compHeight = newSequence.height;

    var compWidth = newSequence.width;

    var vidName = newSequence.name;

    var duration = newSequence.duration*frameRate +1;

    var myComp = app.project.items.addComp(vidName, compWidth, compHeight,1.0,duration,1.0);

    myComp.layers.add(newSequence); /// Add layers to comp

    myComp.displayStartTime = 1; /// Set start time to 1

    app.project.item(1).openInViewer();

    I’m getting a 240 frames footage instead of 7200 (30 fps).

    Thanks in advance !

    Tom Pinnes replied 5 years, 7 months ago 2 Members · 2 Replies
  • 2 Replies
  • Filip Vandueren

    January 19, 2021 at 12:05 pm

    Hi Tom,

    try this:

    var importFolder = new File ("c:\\"); // Set default import folder
    var myImportFolder = importFolder.openDlg("Select files to import","*.tif",true).toString(); /// Select import folder path
    var myImportOptions = new ImportOptions(File(myImportFolder)); /// Import options
    myImportOptions.importAs = ImportAsType.FOOTAGE;
    myImportOptions.sequence = true; /// Import sequence
    myImportOptions.forceAlphabetical = true; /// Force alphabetical
    var newSequence = app.project.importFile(myImportOptions); /// Set new import files to var
    newSequence.mainSource.conformFrameRate = 1; // force the imported file to have framerate 1
    app.executeCommand(2796); // do "New Comp from Selection"
    myComp = app.project.activeItem;
    // fix the things that weren't set by default
    myComp.name = newSequence.name;
    myComp.displayStartTime = 1;
    myComp.openInViewer();
  • Tom Pinnes

    January 23, 2021 at 2:20 pm

    Hey Filip, thanks for that. Very neat looking code

    I also never knew about executeCommand too, that’s very cool!

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy