I am new to the Raspberry Pi and even new to the Raspberry Pi camera. I have seen a lot of tutorials online for the Raspberry Pi camera but have yet to find on that lets me stream straight from the Raspberry Pi camera like you can with a webcam (using SimpleCV or OpenCV). Was hoping someone could point me in the right direction.

14 Answers 14

up vote 70 down vote accepted

The solution suggested by Diego is good except that it's pretty slow and has a huge video delay since the vlc there re-streams a stream of the raspvid. Since 12/2013 there is an official v4l2 driver available: http://www.ics.com/blog/raspberry-pi-camera-module#.VJFhbyvF-b8 This renders the mentioned re-streaming obsolete. Simply load the module and use it:

sudo modprobe bcm2835-v4l2
cvlc v4l2:///dev/video0 --v4l2-width 1920 --v4l2-height 1080 --v4l2-chroma h264 --sout '#standard{access=http,mux=ts,dst=}'

This creates an http stream at port 12345, you can use other formats too, like the rtcp one from the Diego's answer. Read more on it here: https://web.archive.org/web/20151012014829/http://www.videolan.org:80/doc/streaming-howto/en/ch03.html

  • 2
    In this answer, it's suggested to add :demux=264 to cvlc because the stream is RAW h264 and you need to set the demuxer: cvlc v4l2:///dev/video0 --v4l2-width 1920 --v4l2-height 1080 --v4l2-chroma h264 --sout '#standard{access=http,mux=ts,dst=}' :demux=264. That's make possible to watch the stream in VLC for Android, for example. – Jaime M. May 7 '15 at 20:01
  • 8
    In the provided link, instead of autoreconf -vfi you should now use ./bootstrap.sh – JuJoDi Jun 1 '15 at 16:35
  • 1
    Is there a way that will allow me to both stream the video and also save it on the RPi SD card? – Or Weinberger Dec 1 '15 at 13:03
  • 4
    The videolan.org/doc/streaming-howto/en/ch03.html link is dead. – Kal Jul 2 '16 at 1:55
  • 4
    I think it might be worth noting / confirming that this method does not work in a headless environment. I am getting errors, one of which talks about X11 – Nick Jan 11 '17 at 19:52

There are several options you can choose between. At my work we are using VLC to stream video captured by Raspberry Pi Camera from our server-rooms to the office. One downside of this is that there are about 5 seconds delay and I haven't found a solution to this. The following is our setup:

  1. Have raspbian installed and updated and make sure your camera is enabled (you enable this by running sudo raspi-config and choose Enable Camera)

    sudo apt-get update
    sudo apt-get upgrade
  2. Install vlc

    sudo apt-get install vlc
  3. Create a script to start the stream with the following content, or run the command (you can't do anything else if you just run the command).

    sudo nano myscript.sh
    raspivid -o - -t 0 -hf -w 640 -h 360 -fps 25 | cvlc -vvv stream:///dev/stdin --sout '#rtp{sdp=rtsp://:8554}' :demux=h264
  4. Make the script runable

    sudo chmod +x myscript.sh
  5. If you want to start the stream automatically you have to add the script to crontab. To make this work I had to make another script runned by cron (OBS! VLC can't be run as sudo so make sure you're in the right cron). sudo nano myscript2.sh:



    sudo chmod +x myscript2.sh
    crontab -e
    @reboot /path/to/myscript2.sh
  6. To watch the videostream, open VLC on a computer on the same network as the raspberry pi you are using for streaming. Press Media -> Open Networkstream and paste the following in the field:


If you don't care about FPS (frames per second) and don't want any delay you could use MJPEG. You can read more about this HERE

Watch THIS wiki about Raspberry Pi Camera Module. Hope you find what you're looking for.

  • Any idea why I would be getting the following on VLC on Windows ? Your input can't be opened: VLC is unable to open the MRL 'rtsp://'. Check the log for details. The Pi-side seems to be ok - no errors and seems to reacting to the connected client? – monojohnny Mar 7 '15 at 22:54
  • @monojohnny Is the raspberry pi streaming? Check if the video is actually working by plugging in a screen. If video is working you should see the stream on the screen plugged to the raspberry pi. – Diego Apr 23 '15 at 12:25
  • @monojohnny Thanks for the write-up Diego... works perfectly on the first try! monojohnny ... you have to put the trailing "/" otherwise vlc complains. Try this: rtsp:// – Sujay Phadke Nov 5 '16 at 6:04
  • Thanks @Diego this worked great for me but how do I quit my stream? – Denoteone Jan 14 '17 at 16:27
  • I have the same problem on windows and i am not able to stream the video from my pi. given i see the video streaming from pi camera on a screen connected to the pi but not through VLC installed on my windows 10 pc. – Mostafa May 30 '17 at 23:01

I tried some options. However, I found the best result using that project: RPi-Cam-Web-Interface from eLinux community

the stream has almost zero delay.

good luck :)

  • 4
    People looking for zero latency, check this for sure. Props to @user2998302. I can't believe, for one year this no upvotes(acknowledgment) on this. – igaurav Nov 7 '16 at 16:57
  • While this is a quick and easy setup, the software is far from optimized, so while its low latency (no such thing as zero latency), the interface is very chatty, and uses some extra CPU cycles. Not a problem if you aren't running anything else, but could be if you are, especially on a Pi 1. – Nick Jan 11 '17 at 20:46
  • This is awesome! – Hamza Ouaghad Apr 9 '17 at 16:29
  • Fastest web video streaming so far among the ones i've tested (also native v4l2 driver streamed via vlc), almost zero latency. No point in complaining about optimization while every resource on the internet regarding this problem won't get you any better result than this application does. – Gabber Jun 18 '17 at 19:10
  • woah, i must admit this one rocks! – L.Trabacchin Jan 20 at 22:08

The easiest way I have found, to get a live videofeed from an headless raspberry pi, with a raspberry pi camera.

This solution works right out of the box, without installing additional software on the PI.

On the PI:

raspivid -t 0 -l -o tcp://

On the Computer, one can stream with VLC:

vlc tcp/h264://

(assuming is the PI's IP address)

  • Welcome to Raspberry Pi! We generally discourage copying your answers verbatim from one question to another—once you reach 15 rep, you will be able to flag questions that are identical as 'duplicate' so that there's only one copy your answer. Thanks for sharing your answer to the problem, though! – Aurora0001 Aug 25 '17 at 10:18
  • @Per Hansen Not working for me...There might be something else that needs to be done apart from assigning a port. – Amit Ray Oct 30 '17 at 17:39
  • This works great ! Using a RPi3B+ and Raspbian 9.4 (stretch) headless. – dparkar Jul 13 at 5:51

I posted a possible solution in raspberry forum using a lightweight RTSP server based on live555 that is fed with a V4L2 driver supporting H264 capture :

sudo modprobe -v bcm2835-v4l2
git clone https://github.com/mpromonet/v4l2rtspserver.git
cd v4l2rtspserver
cmake .
make install
v4l2rtspserver -H <height> -W <width> -F <fps>

Next you should be able to access to the RTSP stream using :

vlc rtsp://<raspberry>:8554/unicast
  • what about the time lag? – kuhajeyan Jun 28 '16 at 17:43
  • shorter than cvlc. – mpromonet Aug 7 '16 at 10:18
  • cmake complained about "Could NOT find ALSA (missing: ALSA_LIBRARY ALSA_INCLUDE_DIR)", until I added a few more packages for my project. Solution is within these: "sudo apt-get install libopus-dev libexpat1-dev libasound2-dev libudev-dev libavahi-client-dev" (my guess is asound may be enough here). – MoonCactus Sep 15 '16 at 7:06
  • oh, and it works pretty well (lightweight solution), thanks. Time lag is decent, about 2 seconds si it compares favorably with other solutions imho. – MoonCactus Sep 15 '16 at 7:14
  • @MoonCactus: I think I fixed ALSA installation (it needs only libasound2-dev). The lag should be below a seconds, if you use vlc, you could reduce network buffering using --network-caching 300 – mpromonet Sep 16 '16 at 20:20

UV4L (also) supports standard HTML5 video and audio streaming with no configuration required. Other options are possible too, like MJPEG over http.


UV4L now also supports live audio & video broadcasting to Jitsi Meet Rooms over the Web. No special configuration is required. It's as easy as filling your name, room and clicking on Start.

2nd Update:

UV4L now supports H264 hardware-encoded video too, at full fps, HD and possibly Full HD in the future.

  • 1
    Only thing is, you're only able to get the elemental stream which pretty much everything DOESN'T understand. Not much use, sadly. You need something to emit WebRTC (Which if you've got a Pi2 and later, you can with UV4L. If you're needing (because of power/size constraint) a Zero to do this, your SOL. – Svartalf Oct 29 '16 at 13:02

I don't know if you are looking for a surveillance software, but I have succeeded in installing and running motion, a software motion detector. You should have a look in the official guide.

  • Motion only applies to USB cameras – geneorama Feb 21 '15 at 20:44
  • 3
    @geneorama motion use video4linux interface that is not restricted to USB camera, the bcm2835-v4l2 module give access to the camera board through this interface. – mpromonet Apr 13 '15 at 6:42

I've been able to stream video using uv4l WebRTC on Raspberry Pi 2. It's super easy. Just follow this tutorial. I hope this help.

  • Please include relevant parts of the tutorial here, as to prevent link rot. – Bex Jul 12 '15 at 19:09
  • Only applicable on the Pi2 and above. Doesn't work with a 1A/1A+/Zero. Not wholly sure why he can't since people seem to be able to do it, but hey... – Svartalf Oct 29 '16 at 13:00

I was having trouble getting the video stream on windows 7. There were many linux solutions, not I couldn't replicate them on windows until now. I got a pretty quick solution eventually:

  1. get a windows version of netcat: http://joncraton.org/files/nc111nt.zip, unzip it and add to path
  2. get a new version of mpc-hc, which may read from stdin: https://mpc-hc.org/downloads/ install and add its path to path as well (mine is 64-bit, but 32-bit will hopefully do as well)

On raspberry pi:

raspivid -t 0 -w 1024 -h 768 -fps 20 -b 1000000 -o - | nc your.receiver.ip.address 5001

On windows machine:

nc -l -p 5001 | mpc-hc64 -

Thus, i deem, nothing gets repacked or restreamed, remuxed or what so ever. Binary stream from raspvid is feeded into mpc and shown. My raspberry operates over wifi, so at first I get a fair delay, which is in a matter of half a minute reduced to those 0.2-0.3 seconds delay.

Unfortunately, I couldn't use vlc in the same manner, as nc -l -p 5001 | vlc - just opens vlc window without any video.

I used Nginx with RTMP support for streaming to the world, together with avconv for processing camera input. Code is available on Github.

  • Good one, would you share about any experience video time lag? – kuhajeyan Jun 28 '16 at 17:55
  • 2
    Yes, there was a lag of about 5 seconds. – TTT Jul 25 '16 at 10:07

Both mjpeg_streamer and motion seem to have better latency than cvlc.

Using mjpg_streamer

mjpeg_streamer requires compilation but the instructions on the github are straightforward.

After compilation it can be run by launching start.sh from the project dir, or by running directly (in the project dir):

./mjpg_streamer -i "./input_uvc.so -rot 180" -o "./output_http.so -w ./www -p 8090"

where 8090 is the TCP port. If not specified, then port 8080 will be used by default. The start.sh script contains some usage examples with extra options.

Using motion

Motion includes a systemd service which makes it easy to autostart at boot, stop or restart.

To use it in IP webcam mode the following settings should be set in /etc/motion/motion.conf:

daemon on
stream_localhost off
output_pictures off
ffmpeg_output_movies off
stream_maxrate 24
framerate 24
width 640
height 480

Next, in /etc/default/motion set:


To make the service autostart on boot:

systemctl enable motion

Use systemctl start/stop/restart motion for the corresponding action.

Default streaming port is 8081. The port is set under stream_port in /etc/motion/motion.conf.

While Peter Hansen's code quite possibly works fine on a LAN, for completeness sake : TCP is about data integrity as against real-time. In a real-time stream some data loss may be acceptable for the sake of timely display. In this case UDP may be better. I haven't tested that code.

If it is a security camera, multicasting may be considered. Modern routers can do it even the $100 models.

I have installed an ONVIF solution from https://github.com/BreeeZe/rpos on my pi, following the instructions on README.md.

The only difference is that I have installed node v8.4.0. This allows me to see my camera output in a NVR connected on same network. Also, camera can be directly played through VLC player network stream using address rtsp://

A while a go had a similar problem came up with this:


Its more barebone than other proposed solutions, but I think it works well if low latency over web is the priority.

Works on most browsers (even mobile at 480p) without any plugins needed on the browser.

  • Holy shit. An h.264 decoder written in JavaScript. The receiving device must be burning after a while. – kwasmich Mar 7 at 10:47
  • I did not write the decoder itself, its a separate project github.com/mbebenita/Broadway However is surprisingly well optimised, and as I said in the answer it can easly handle a 480p on a droid. The reason I went with Brodway is because there is no vp8/9 hardware encoder on rpi so h264 is really the only decent option. But if you want to use native h264 decoder in browser you can forget the low latency. – MatijaG Mar 7 at 10:52
  • It sounds so incredible that I have to give it a try. – kwasmich Mar 7 at 11:02
  • Any feedback will be very welcome :) – MatijaG Mar 7 at 11:03
  • Only now I had some spare time. I'm having trouble getting the example to run with the raspivid camera feed. With ffmpeg on the other hand I'm just getting tenth of frames per second. I used a clean Raspbian and a Pi Zero. Do you have some hints for me? – kwasmich Apr 18 at 19:45

protected by goldilocks Apr 23 at 16:48

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.