Software Tutorial

Low Latency Video Streaming from Raspberry Pi and Camera Module

So I’ve been trying to get my raspberry pi to stream video to my laptop with as low latency as possible because I intend to use it as an FPV system for my quad. Here’s where I’ve gotten till now, using the instructions found here, and modifying them a little.

Step 1 (Video Receiving Machine):

Requirements: Make sure you have mplayer and netcat installed (I used macports).

On receiving machine, type the following command in the terminal:

$ ifconfig -v

This will output a bunch of info, you can use this to retrieve your receiving machine’s local ip. You can also open your router’s admin page and check the ip assigned to your computer. Then type the following:

$ nc -l 5000 | mplayer -fps 60 -cache 1024 –

This uses nectat to pipe the data from port 5000 to mplayer.

Step 2 (On RPI):

I’m running raspbian on my RPI and using an rpi camera module that you can get off amazon or adafruit. Assuming that your camera module is up and running with your Raspberry Pi. Do the following:

$ sudo apt-get update

$ sudo apt-get upgrade

sudo aptget install netcattraditional

mkfifo fifo.500

This creates a fifo queue.

cat fifo.500 | nc.traditional <your receiving machines ip> 5000 &

This, lets netcat read the queue and stream it to the receiving machine at port 5000.

$ raspivid -h 640 -w 480 -fps 25 -o fifo.500 -t 0

Uses raspivid to write the video buffer to the queue.

Finally, after about 2-10 seconds you should start seeing the video feed on your computer. This a barely noticeable lag. As you increase the video capture resolution, you start seeing some lag increasing. You can connect the RPI with an ethernet cable to get rid of the packet drops.

Recommended Articles