var fp = 'ffprobe ' + fileName + ' -show_streams | grep '
var width = exec(fp+'width', function(err, stdout, stderr){
return stdout;
});
alert(stdout + 'random example');
如何将标准输出从进程中“取出”,以便稍后使用它。
Node's exec http://nodejs.org/docs/v0.4.9/api/child_processes.html#child_process.exec函数是异步的。这意味着不能保证下面的代码exec
调用将等待子进程完成运行。要在进程退出后执行代码,您必须提供处理结果的回调。您的代码可以从那里分支:
var fp = 'ffprobe ' + fileName + ' -show_streams | grep ';
var width = exec(fp+'width', function(err, stdout, stderr){
console.log(stdout);
// ... process stdout a bit ...
afterFFProbe(stdout);
});
function afterFFProbe(output) {
// your program continues here
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)