Streaming webcams via RTSP (Real Time Streaming Protocol) to regular browsers (Chrome, Firefox, Safari, Explorer, Vivaldi) is a POA. Browser support for 99% of the webcams out there just plain sucks. If you want to embed video so all browsers can view it, you use motion jpeg (MJPEG) instead. What you get is a low-quality, video bandwidth hogging webcam stream that most browsers will support. There are other solutions (mostly Flash or Java based), but I've never found one that supported all major browsers (and that was free :-).
So the day came when a customer presented me with a webcam that did not support MJPEG, I knew I had my work cut out for me. However, the smart guys at PHOBOSLAB came up with a totally hacked and clever way to stream webcams using a combination of RTSP and web sockets, which most modern browsers support. I used this solution and so far it is working quite well.
gyp failed with exit code: 1
sudo npm -g install ws
However, when I ran the command, I received the following error:
/bin/sh: 1: node: not found gyp: Call to 'node -e "require('nan')"' returned exit status 127. while trying to load binding.gyp gyp ERR! configure error gyp ERR! stack Error: <em>gyp failed with exit code: 1</em> gyp ERR! stack at ChildProcess.onCpExit (/usr/share/node-gyp/lib/configure.js:431:16) gyp ERR! stack at ChildProcess.EventEmitter.emit (events.js:98:17) gyp ERR! stack at Process.ChildProcess._handle.onexit (child_process.js:797:12) gyp ERR! System Linux 3.13.0-37-generic gyp ERR! command "nodejs" "/usr/bin/node-gyp" "rebuild" gyp ERR! cwd /home/drodrig/www/staging/node_modules/ws/node_modules/bufferutil gyp ERR! node -v v0.10.25 gyp ERR! node-gyp -v v0.10.10 gyp ERR! not ok npm WARN This failure might be due to the use of legacy binary "node" npm WARN For further explanations, please read /usr/share/doc/nodejs/README.Debian
The first line gives us a good clue -- "node: not found". Typing "node" on the command line displayed another not found error. I knew Node.js was installed. The problem was that on my Linux distrubtion (Ubuntu 14.10), the install of Node.js was to /usr/bin/nodejs, not /usr/bin/node. To solve the problem, I simply linked the file as such:
sudo ln -s /usr/bin/nodejs /usr/bin/node
Unrelated to the problem and solution, if you try the streaming setup mentioned herein, note that your server will be streaming the webcam feeds to all who access them. This can add up to some bandwidth if you have popular public cams.