문제

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