为什么node.js找不到avconv?

时间:2013-05-09 12:11:02

标签: node.js bash exec avconv

为什么在node.js中使用exec:

child = exec("avconv -i " + result.params.fullDestinationFilename + " -ab 128k -vcodec libx264 -vb 2000k -r 24 -s 1280x720 " + convertedFileName720p + ".mp4", function (error, stdout, stderr) {
    sys.print('stdout: ' + stdout);
    sys.print('stderr: ' + stderr);
    if (error !== null) {
        console.log('exec error: ' + error);
    }
    console.log("CONVERTED!");
});

我收到错误:

  exec error: Error: Command failed: /bin/sh: avconv: command not found

在bash中我可以正常执行它。 对于node.js开发,我使用了nodeclipse。

2 个答案:

答案 0 :(得分:0)

供参考

var exec = require('child_process').exec;
exec("ls -la");    

答案 1 :(得分:0)

由于对mark a comment as an answer的功能请求仍然被拒绝,我在此处复制上述解决方案。

你自己的$ PATH和节点的PATH有什么区别?给出avconv - glenn jackman的全部路径会更安全。

我在偏好中看到它是空的。但完整的路径是唯一最快的解决方案。谢谢 - 静态