我在树莓派上运行nodejs,我想运行一个子进程以生成网络摄像头流。
在节点之外,我的命令是:
raspivid -n -mm matrix -w 320 -h 240 -fps 18 -g 100 -t 0 -b 5000000 -o - | ffmpeg -y -f h264 -i - -c:v copy -map 0:0 -f flv -rtmp_buffer 100 -rtmp_live live "rtmp://example.com/big/test"
随着child_process
我要打破每个参数最多
var args = ["-n", "-mm", "matrix", "-w", "320", "-h", "240", "-fps", "18", "-g", "100", "-t", "0", "-b", "5000000", "-o", "-", "|", "ffmpeg", "-y", "-f", "h264", "-i", "-", "-c:v", "copy", "-map", "0:0", "-f", "flv", "-rtmp_buffer", "100", "-rtmp_live", "live", "rtmp://example.com/big/test"];
camera.proc = child.spawn('raspivid', args);
但是,它使|
角色窒息:
error, exit code 64
Invalid command line option (|)
如何使用该竖线字符作为参数?
这已在另一个问题中得到解答:对spawn使用两个命令(使用pipe |)
总之,child.spawn
所有内容args
都应作为“ raspivid”命令的参数。在您的情况下,管道及其后的所有内容实际上都是的参数sh
。
一种变通方法是调用child.spawn('sh', args)
args在哪里:
var args = ['-c', <the entire command you want to run as a string>];
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句