1

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 を使用します。

4

2 に答える 2

0

コメントを回答としてマークする機能のリクエストは引き続き拒否されるため、上記のソリューションをここにコピーします。

自分の $PATH とノードの PATH の違いは何ですか? avconv のフル パスを指定する方が安全です – グレン ジャックマン

設定で見たように空です。しかし、フルパスが唯一の最速の解決策でした。ありがとう – 静的

于 2013-10-31T12:41:02.113 に答える
0

参考のため

var exec = require('child_process').exec;
exec("ls -la");    
于 2013-05-09T13:04:10.607 に答える