Home/Computers & IT/Raspberry Pi Camera Streaming to VLC Player

Recently I discovered the pi’s in my quest for making a device with recognition software to locate items on the ground while being attached to a multi-rotor helicopter.

The Raspberry Pi is perfect. only needing 5v to run means its great for running off batteries etc.

anyway to the streaming part.

To stream to VLC from your Raspberry Pi Camera to your computer over a network you need to install VLC Player on both the Raspberry Pi & PC/ Mac what ever.

 

for the PC/ MAC its simple just go to the VLC downloads page – http://www.videolan.org/
as for the Pi its more complicated.

 

login to your pi via ssh or use the terminal directly on the Pi

Updating is important run the below commands
sudo apt-get update

sudo apt-get upgrade

Once they are finished lets install VLC

sudo apt-get install vlc

once you have VLC on both the Pi & the machine you want to stream to you want to run this command to start the stream

raspivid -o - -t 9999999 |cvlc -vvv stream:///dev/stdin --sout '#rtp{sdp=rtsp://:8554/}' :demux=h264

if you encounter issues streaming like frezzes etc use this script

raspivid -o - -w 920 -h 540 -t 9999999 |cvlc -vvv stream:///dev/stdin --sout '#rtp{sdp=rtsp://:8554/}' :demux=h264

once the script is running open VLC Player on your computer.
go to File, Open Network or Open Network Stream (it’s a little different between mac & pc versions)
type this in the field – rtsp://IPofRaspberryPi:8554/   (example: rtsp://192.168.1.105:8554/)

click OK & you’re done!

enjoy the stream 🙂

By | 2015-01-06T15:18:33+00:00 July 25th, 2013|Computers & IT|20 Comments

20 Comments

  1. Macmen007 October 14, 2013 at 4:34 am - Reply

    You are a GENIUS!
    I have been fighting with this for months!
    Blessing to you and yours

    • Sammit
      Sammit October 15, 2013 at 7:23 pm - Reply

      Thanks mate, Appreciate it 🙂

  2. Jakob October 24, 2013 at 5:19 am - Reply

    Very Nice,

    but i have min 4 sec delay! is that a normal worth?

    • Sammit
      Sammit October 24, 2013 at 10:06 am - Reply

      It all depends on the type of network you are streaming via.
      I find that 2 – 4 sec delays are pretty normal

  3. Ali Serhal November 7, 2013 at 3:58 am - Reply

    Excellent tutorial but I have a question is it possible to save the captured video to a file while still streaming ???

    • Sammit
      Sammit November 7, 2013 at 3:51 pm - Reply

      Hi Ali,

      I have not personally tried what you are suggesting. but in theory I don’t see an issue.

      Here is the output command for raspivid:
      -o, --output : Output filename (to write to stdout, use '-o -')
      so you could write to your own location & filename instead of writing to stdout.

      Hope this helps.
      If you have any other questions feel free to ask.

  4. Riley January 4, 2014 at 7:45 am - Reply

    Thank you so much for the tutorial! I just have a few questions. Once you start the live feed, how do you stop it without rebooting the RPi? Also, is there any way to reduce the lag? I would like to use the RPi for a FPV UAV, but the lag tends to be a problem.

    • Sammit
      Sammit January 4, 2014 at 11:40 am - Reply

      To stop the stream just simply push ctrl C via the SSH Terminal to the pi.

      as for stopping the lag… it all depends on the network hardware you are using.
      you can try reducing the lag by lowering the resolution in the stream script as per in the article.

      I find the less lag occurs when using a good well known brand wifi adapter with an antenna.

      Let me know how you go ^.^

  5. GregPouet January 9, 2014 at 2:47 am - Reply

    Hi!
    Nice tutorial, thanks !
    Why using vlc and not ffmpeg ? What is the diffrence ? (my question is stupid but I see a lot of people using ffmpeg ^^)

    • Sammit
      Sammit January 14, 2014 at 10:19 am - Reply

      when it comes down to it VLC is more recognized & known.
      it constantly is being updated & developed, just made more sense to me to use something abit more known & trusted.

  6. trout149 January 18, 2014 at 4:25 am - Reply

    Hi, when I run this command with vlc installed on my Pi and everything as you said, I get the error “Invalid command line option (-vvv)”. Do you have any suggestions?
    Thanks

    • trout149 January 18, 2014 at 4:34 am - Reply

      Problem solved, just a typo

  7. David February 1, 2014 at 2:45 am - Reply

    Thank you for this post. Perhaps someone can give me a push… Did exactly as above, hit enter and the camera flashes about 1 second of video then returns to command line and says…”main libvlc error: configuration file not found: is a directory” and the next line says “main libvlc error: No plug-ins found”

    There are no other errors. Thanks in advance for any advice.

    • Sammit
      Sammit February 1, 2014 at 10:32 pm - Reply

      have you run the update commands?

  8. Piers February 3, 2014 at 10:28 pm - Reply

    Superb write up. Thanks for taking us through this.

    Is there anyway to have this service start on the Pi booting?

    I don’t wan tto keep having to type the stream command.

    Thanks

  9. Daniel March 15, 2014 at 7:22 am - Reply

    I would like to understand the code…

    Does the -t 9999999 means the seconds the script ist running? This would mean it runs ca. for 19 Years if i don’t stop with Ctrl + C…

    Thanks for the answer.

    • Sammit
      Sammit March 18, 2014 at 11:16 am - Reply

      spot on. 🙂

  10. Yann Hivert April 24, 2014 at 10:06 pm - Reply

    Hello, when I run the video everything goes fine but when I run vlc on my smartphone, there wrote that the stream can not be opened.

    What does it do?

  11. nirmal April 26, 2014 at 4:56 pm - Reply

    good. i gonna use it for my robot.

Leave A Comment