Streaming video from RaspberryPI to the network using Node.js

Avi Zurel
Fullstack Network
Published in
2 min readJul 22, 2017

--

If you did not follow the story, I build a chatbot controller RC car.

In order to make the experience even better, I wanted to stream the video from the car point of view.

In order to do that, I needed another RaspberryPI and a camera.

The raspberry comes with a handy tool called raspivid. You can use it to watch the video from the camera. But what I really wanted to do is stream it to another computer on the network.

In this post. I will take you step by step on how to set it up.

First thing you would do is sudo apt-get update in order to make sure you are running the latest versions of everything.

Once that’s done, you will need to install Node.js on the Pi

First execute curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash — Once this is done you can just do sudo apt-get install nodejs.

Verify you have node install using node -v

From here. it’s pretty simple…

Create a file called app.js and paste this code:

var spawn = require('child_process').spawn;
var http = require("http");
var child = spawn('/opt/vc/bin/raspivid', ['-hf', '-w', '1280', '-h', '1024', '-t', '999999999', '-fps', '20', '-b', '5000000', '-o', '-']);var server = http.createServer(function(request, response) {
child.stdout.pipe(response);
});
server.listen(8080);
console.log("Server is listening on port 8080");

Now, you can open VLC on your PI address and port 8080 and behold your video.

If VLC does not work, make sure you enable H264 demuxer in the advanced settings.

--

--