Quick tutorial step-by-step for streaming live video from your Raspberry 3 using the PI Camera to a web browser. Using Motion to deliver the stream to the browser which has a near 5 second latency. Might want to use something like Gstreamer for better performance. Downside with Gstreamer is that you need a Gstreamer client or SDK on the other side. It does not stream into a browser. Motion does stream into a browser. I reduced the framerates to minimize the latency.
This tutorial assumes that you have already done a base Jessie install and you have fitted the PI Cam.
Update Rasbian
Getting started with making sure you have latest installs on your Raspberry and reboot:
sudo apt-get update sudo apt-get upgrade sudo apt-get install rpi-update sudo rpi-update sudo reboot
As the pi user, change into your home directory to do the Motion and MMAL install:
cd ~/ mkdir mmal cd mmal
Install and Configure Motion
apt-get install motion libjpeg62
Download specially compiled motion-mmal. I got missing library errors when using the vanilla mmal tar.gz and found that I had to use a specially compiled mmal binary to make it work:
wget https://www.dropbox.com/s/6ruqgv1h65zufr6/motion-mmal-lowflyerUK-20151114.tar.gz tar -zxvf motion-mmal-lowflyerUK-20151114.tar.gz
You will need to adjust the motion-mmalcam.conf in /etc/pi/mmal directory. I configured the width/height of an iPhone 6 and set the frame rate low to reduce latency. Following should be adjusted in the file:
width=667 height=375 target_dir=/home/pi/mmal/video_dump logfile=/home/pi/mmal/motion.log stream_maxrate=5 framerate=5 output_pictures=off
Start the video stream with:
./motion -n -c motion-mmalcam.conf
Test in Browser
Check it in your browser. My local Raspberry ip address was 172.16.1.52 and port in conf was 8081:
http://172.16.1.52:8081
Test it using Xcode Swift
I setup a really simple Xcode Swift app to browse the live stream. You can download the source code GitHub