运行 shell 渲染完成时的命令(After Effects)
Run shell command when render is complete (After Effects)
在 Adobe After effects 中完成渲染后,有没有办法以编程方式 运行 shell 命令?
试试这个代码。您唯一需要调查的是 (rq_item.status === RQItemStatus.DONE)
被调用两次的原因。
// Create a comp with a solid
var comp = app.project.items.addComp('test', 100, 100, 1, 1, 12);
comp.layers.addSolid([0.5, 0.5, 0.5], 'solid', 100, 100, 1, 1);
// Add the comp to the render queue
var rq_item = app.project.renderQueue.items.add(comp);
rq_item.outputModule(1).file = File('~/Desktop/out.mov');
rq_item.render = true;
// Set a function which will be called every frame when the comp will be rendering
// A boolean to be sure that the function called at the end is called once
var called = false;
rq_item.onStatusChanged = function() {
while (rq_item.status === RQItemStatus.RENDERING) {
// Is rendering...
$.writeln('Rendering');
}
// When the render is finished
if (!called && rq_item.status === RQItemStatus.DONE) {
called = true;
$.writeln('Done rendering');
// test for Mac or Win
var res = null;
if($.os.charAt (0) === 'M'){
res = system.callSystem('echo "Hello Mac World"');
}else{
res = system.callSystem('cmd.exe /c echo "Hello Win World"');
}
$.writeln(res);
}
};
// Launch the render
app.project.renderQueue.render();
// If something goes wrong
app.onError = function(err) {
$.writeln('ERROR ' + err);
};
从 After Effects 执行命令行
您可以使用 sysmte.callSystem(cmdLineToExecute)
函数执行命令行。请查看 After Effects Scripting Guide 页 180 部分 System callSystem() 方法.
这是一个 echo
命令的例子:(callSystem
return 命令行 return 的):
var commandOutput = system.callSystem("cmd.exe /c echo hi ");
alert(commandOutput);
这将输出
hi
/c
后面是cmd中要执行的命令
脚本指南中获取系统时间的更复杂示例:
var timeStr = system.callSystem("cmd.exe /c \"time /t\"");
alert("Current time is " + timeStr);
这将输出
Curent time is 11:28
从 After Effects 打开命令行
现在,如果您想在另一个 window 中打开命令行,则必须像在命令行中一样设置 cmdLineToExecute
。
在 windows 上,如果你想在另一个 window 上打开命令行,你必须这样做:
start cmd.exe
所以如果你想从 After
开始
system.callSystem("cmd.exe /c start cmd.exe ");
在 After Effects 中完成渲染后打开命令行
这是与@fabiantheblind 的回答的混合。
// Create a comp with a solid
var comp = app.project.items.addComp('test', 100, 100, 1, 1, 12);
comp.layers.addSolid([0.5, 0.5, 0.5], 'solid', 100, 100, 1, 1);
// Add the comp to the render queue
var rq_item = app.project.renderQueue.items.add(comp);
rq_item.outputModule(1).file = File('~/Desktop/out.mov');
rq_item.render = true;
// Set a function which will be called every frame when the comp will be rendering
// A boolean to be sure that the function called at the end is called once
var called = false;
rq_item.onStatusChanged = function() {
while (rq_item.status === RQItemStatus.RENDERING) {
// Is rendering...
$.writeln('Rendering');
}
// When the render is finished
if (!called && rq_item.status === RQItemStatus.DONE) {
called = true;
system.callSystem("cmd.exe /c start cmd.exe ");
}
};
// Launch the render
app.project.renderQueue.render();
// If something goes wrong
app.onError = function(err) {
$.writeln('ERROR ' + err);
};
在 Adobe After effects 中完成渲染后,有没有办法以编程方式 运行 shell 命令?
试试这个代码。您唯一需要调查的是 (rq_item.status === RQItemStatus.DONE)
被调用两次的原因。
// Create a comp with a solid
var comp = app.project.items.addComp('test', 100, 100, 1, 1, 12);
comp.layers.addSolid([0.5, 0.5, 0.5], 'solid', 100, 100, 1, 1);
// Add the comp to the render queue
var rq_item = app.project.renderQueue.items.add(comp);
rq_item.outputModule(1).file = File('~/Desktop/out.mov');
rq_item.render = true;
// Set a function which will be called every frame when the comp will be rendering
// A boolean to be sure that the function called at the end is called once
var called = false;
rq_item.onStatusChanged = function() {
while (rq_item.status === RQItemStatus.RENDERING) {
// Is rendering...
$.writeln('Rendering');
}
// When the render is finished
if (!called && rq_item.status === RQItemStatus.DONE) {
called = true;
$.writeln('Done rendering');
// test for Mac or Win
var res = null;
if($.os.charAt (0) === 'M'){
res = system.callSystem('echo "Hello Mac World"');
}else{
res = system.callSystem('cmd.exe /c echo "Hello Win World"');
}
$.writeln(res);
}
};
// Launch the render
app.project.renderQueue.render();
// If something goes wrong
app.onError = function(err) {
$.writeln('ERROR ' + err);
};
从 After Effects 执行命令行
您可以使用 sysmte.callSystem(cmdLineToExecute)
函数执行命令行。请查看 After Effects Scripting Guide 页 180 部分 System callSystem() 方法.
这是一个 echo
命令的例子:(callSystem
return 命令行 return 的):
var commandOutput = system.callSystem("cmd.exe /c echo hi ");
alert(commandOutput);
这将输出
hi
/c
后面是cmd中要执行的命令
脚本指南中获取系统时间的更复杂示例:
var timeStr = system.callSystem("cmd.exe /c \"time /t\"");
alert("Current time is " + timeStr);
这将输出
Curent time is 11:28
从 After Effects 打开命令行
现在,如果您想在另一个 window 中打开命令行,则必须像在命令行中一样设置 cmdLineToExecute
。
在 windows 上,如果你想在另一个 window 上打开命令行,你必须这样做:
start cmd.exe
所以如果你想从 After
开始system.callSystem("cmd.exe /c start cmd.exe ");
在 After Effects 中完成渲染后打开命令行
这是与@fabiantheblind 的回答的混合。
// Create a comp with a solid
var comp = app.project.items.addComp('test', 100, 100, 1, 1, 12);
comp.layers.addSolid([0.5, 0.5, 0.5], 'solid', 100, 100, 1, 1);
// Add the comp to the render queue
var rq_item = app.project.renderQueue.items.add(comp);
rq_item.outputModule(1).file = File('~/Desktop/out.mov');
rq_item.render = true;
// Set a function which will be called every frame when the comp will be rendering
// A boolean to be sure that the function called at the end is called once
var called = false;
rq_item.onStatusChanged = function() {
while (rq_item.status === RQItemStatus.RENDERING) {
// Is rendering...
$.writeln('Rendering');
}
// When the render is finished
if (!called && rq_item.status === RQItemStatus.DONE) {
called = true;
system.callSystem("cmd.exe /c start cmd.exe ");
}
};
// Launch the render
app.project.renderQueue.render();
// If something goes wrong
app.onError = function(err) {
$.writeln('ERROR ' + err);
};