I'm trying to spawn an avconv process inside node.js. It should receive data on stdin and output converted data to stdout

While the command works in the shell, it immediately closes in node.js and I don't know why:

avconv -v quiet -i pipe:0 -vn -f s16le -acodec pcm_s16le pipe:1

That just works, and in node:

var a = spawn('avconv', ['-v quiet -i pipe:0 -vn -f s16le -acodec pcm_s16le pipe:1']);

a.on('exit', function(code) {
    pr(code, true);
})

I immediately get a '1' exit code. Can anyone tell my what's going wrong here?

有帮助吗?

解决方案

You need to separate the argument array yourself:

var a = spawn('avconv', ['-v', 'quiet', '-i', 'pipe:0', '-vn', '-f', 's16le', '-acodec', 'pcm_s16le', 'pipe:1']);

The space delimitation you are used to from command line work is provided by your shell (bash, zsh...). The shell breaks up your command into argument using spaces and lets you say "I want this as a single argument" by adding quotes.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top