Remote video streaming from Raspberry PI camera

Check my RPI articles in Best Raspberry PI projects article or home page. Or subscribe my newsletter (top right in this page) to be notified when new projects are available! Also interested to start 3D printing with a cheap budget? Visit my cheap 3D printers list

Streaming camera video within a Raspberry PI OS Desktop is simple and useful. But some projects may need remote video streaming from Raspberry PI camera with a headless setup (Lite)

This tutorial will show you how to setup a remote video streaming from a Raspberry PI camera using terminal, without the need of a desktop environment.

In this project, Raspberry PI will work as a streaming server, broadcasting its camera video using Raspivid piped to Netcat.

Raspivid is the default (preinstalled in all Raspberry PI OS distributions) command line tool for capturing video with a Raspberry Pi camera module. It is part of raspicam tools, a set of software able to manage your Raspberry PI Camera for getting videos (raspivid), time lapse video or photographs (raspistill).

NetCat (alias nc) is a computer networking utility for receiving and sending data to network connections using TCP or UDP.

I will use a Raspberry PI 3 Model A+, but this procedure applies to all Raspberry PI boards.

What We Need

RPI 3 model A+

As usual, I suggest adding from now to your favourite ecommerce shopping chart all needed hardware, so that at the end you will be able to evaluate overall costs and decide if continuing with the project or removing them from shopping chart. So, hardware will be only:

Check hardware prices with following links:

Amazon raspberry pi boards box
Amazon Micro SD box
Amazon Raspberry PI Power Supply box
Amazon Raspberry PI Camera box

Step-by-Step Procedure

Stat preparing your operating system. You can install Raspberry PI OS Lite (for a headless, fast linux distribution) or Raspberry PI OS Desktop (in this case, using its internal terminal).

Make your OS up-to-date. From terminal:

sudo apt update -y && sudo apt upgrade -y

Connect camera to your Raspberry PI camera module port.

Enable camera interface from raspi-config tool. From terminal:

sudo raspi-config
raspi-config home pi3 model A+

Select option 3 (Interface Option) with arrow keys and press ENTER:

raspi-config interface options pi3 model A+

We’ll use first option (Camera). So, simply press ENTER again. In next window, select “yes” with left arrow key:

raspi-config interface options camera pi3 model A+

Press ENTER to confirm. Next window will confirm that camera is enabled:

raspi-config interface options camera enabled pi3 model A+

Press ENTER. You will go back to raspi-config home. Go to FINISH and press ENTER. A reboot will be required:

raspi-config reboot pi3 model A+

Please confirm and wait for your Raspberry PI to be rebooted.

Start Raspberry PI Streaming

Raspberry PI streaming will start with following terminal command:

raspivid -t 0 -b 25000000 -fps 30 -w 800 -h 600 -o - | nc -lkv4 8080

This command will trigge raspivid to start capturing camera video and directing its output, via pipe operator (“|”) to netcat (nc is an alias for netcat command). Used options mean following:

  • -t: specifies ms of video to capture (default 5000). If set to zero, disables timeout to have a continuous stream
  • -b: sets bitrate, in bits per second. 25000000 means 25Mbps
  • -fps: sets frames per second capturing rate
  • -w and -h: set image width and height (in pixels)
  • -o sets output. If you specify a file name, it will save video to a file. With “-o -” it will redirect output to stdout.

Following explain netcat options:

  • -l: work in listening mode, waiting for inbound connections
  • -k: Keep inbound sockets open for multiple connects
  • -v: enable verbose mode
  • -4: use IPv4
  • last parameter (8080) sets port to 8080

Once used this command, Raspberry PI will start to listen on network for incoming connections:

pi@raspberrypi:~ $ raspivid -t 0 -b 25000000 -fps 30 -w 800 -h 600 -o - | nc -lkv4 8080
Listening on [] (family 2, port 8080)

From receiving PC side, you will now be ablo to get video stream with video player able to read network stream using tcp protocol and h264 encoding. In my example I will use the free VLC (Videolan), avaliable both for windows and linux. I will use it installed on a windows PC on same LAN.

From VLC interface, select from “Media” menù “Open Network Stream”. Use your Raspberry PI IP address instead of mine ( and insert a link composed as following:

VLC remote streaming tcp h264 port 8080

Finally use Play button to start vieweing you Raspberry PI camera stream.

Final Toughts

Raspivid with netcat will produce a reliable remote video streaming, but introducing delay. Some user report having better performance by using rtp (Real Time Protocol). This way requires installing vlc on Raspberry PI (which uses ablout 1GB of storage).


How useful was this post?

Click on a star to rate it anonymously!

Average rating 4 / 5. Vote count: 1

No votes so far! Be the first to rate this post.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?