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 :)
You are a GENIUS!
I have been fighting with this for months!
Blessing to you and yours
Thanks mate, Appreciate it :)
Very Nice,
but i have min 4 sec delay! is that a normal worth?
It all depends on the type of network you are streaming via.
I find that 2 – 4 sec delays are pretty normal
Excellent tutorial but I have a question is it possible to save the captured video to a file while still streaming ???
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.
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.
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 ^.^
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 ^^)
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.
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
Problem solved, just a typo
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.
have you run the update commands?
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
you can create a start up script with the command. have a look at this post here for help with that.
http://www.stuffaboutcode.com/2012/06/raspberry-pi-run-program-at-start-up.html
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.
spot on. :)
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?
good. i gonna use it for my robot.
set -t 0 instead of 99999