質問

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