After Effects:如何启动外部进程并将其分离

问题描述 投票:0回答:1

我有一个After Effects脚本问题,但我不确定是否可以通过AE知识解决,也许可以通过独立开发解决。

我想从After Effects启动一个外部进程,实际上我想使用After Effects提供的aerender.exe启动一个打开的AEP文件的渲染,同时保持其可用。

var projectFile = app.project.file;
var aeRender = "C:\\Program Files\\Adobe\\Adobe After Effects CC 2018\\Support Files\\aerender.exe";
var myCommand = "-project" + " " + projectFile.fsName;
system.callSystem("cmd /c \""+aeRender+"\"" + " " + myCommand);

所以我写了这个简单的JSX代码,它起作用了,它正确地渲染了场景渲染队列。但是,在Effects冻结之后,它会等待过程结束。我希望它保持可用状态。

因此,我尝试编写一个.cmd文件,并使用AE system.callSystem启动它,我遇到了同样的问题,我试图通过一个.exe文件(使用pyInstaller从一个简单的python编译),同样的问题:

import sys
import subprocess

arg = sys.argv
pythonadress = arg[0]
aeRender = arg[1]
projectFileFSname = arg[2]

myCommand = "-project" + " " +projectFileFSname
callSystem = "cmd /c \""+aeRender +"\"" + " " + myCommand
subprocess.run(callSystem)

我什至尝试使用“ cmd / c start”,而且由于After Effects在该过程完成后继续冻结,因此情况似乎更糟。

有没有一种方法可以使AE相信该过程已经完成,而实际上却没有?

任何帮助都会非常感激!

python cmd jsx after-effects
1个回答
0
投票

[system.callSystem()将冻结脚本的执行,因此,您可以动态创建一个.bat文件并使用.execute()运行它。

这里是一个示例.js:

var path = {
  "join": function ()
  {
    var args = [];

    if (arguments.length === 0) return null;

    for (var i = 0, iLen = arguments.length; i < iLen; i++)
    {
      args.push(arguments[i]);
    }

    return args.join(String($.os.toLowerCase().indexOf('win') > -1 ? '\\' : '/'));
  }
};

var aepFile = app.project.file;

if (aepFile !== null)
{
  var
  aepFilePath = aepFile.fsName,
  comp = app.project.activeItem;

  if (comp !== null && comp instanceof CompItem)
  {
    var
    slash = $.os.toLowerCase().indexOf('win') > -1 ? '\\' : '/',
    scriptFolderPath = new File($.fileName).parent.fsName,
    aeRenderPath = path.join(new File($._ADBE_LIBS_CORE.getHostAppPathViaBridgeTalk()).parent.fsName, 'aerender.exe'),
    batFile = new File(path.join(scriptFolderPath, 'render.bat')),
    batFileContent = [
      '"' + aeRenderPath + '"',
      "-project",
      '"' + aepFilePath + '"'
    ];

    batFile.open('w', undefined, undefined);
    batFile.encoding = 'UTF-8';
    batFile.lineFeed = 'Unix';
    batFile.write(batFileContent.join(' '));
    batFile.close();

    // system.callSystem('explorer ' + batFile.fsName);
    batFile.execute();

    $.sleep(1000); // Delay the script so that the .bat file can be executed before it's being deleted
    batFile.remove();
  }
}

当然,您可以进一步开发它并使它与OSX兼容,为它添加更多功能。等,但这是主要思想。

这里是所有aerender选项的列表(如果您还不知道的话:https://helpx.adobe.com/after-effects/using/automated-rendering-network-rendering.html

顺便说一句,$._ADBE_LIBS_CORE.getHostAppPathViaBridgeTalk()将为您提供“ AfterFX.exe”文件路径,因此您可以通过这种方式更轻松地获得“ aerender.exe”路径。

© www.soinside.com 2019 - 2024. All rights reserved.