Introduction: Raspberry Pi Video Streaming

This instructable will show how to stream a Raspicam to a web using a Raspberry Pi and the UV4L driver.

Step 1: Material

- Raspberry Pi or Odroid-W Running Raspbian

- Raspicam

- Router

- Ethernet Cable

Step 2: Enable Raspicam

Before starting to configure the Raspberry, you'll need to enable the Raspicam CSI port and expand the root filesystem.

First, connect the Raspicam and the Raspberry to a router using an Ethernet cable.

Then, power the Raspberry

Open the terminal and run:

$sudo raspi-config

Select "Enable Camera" and then "Enable"

Select "Expand Filesystem"

Step 3: Installing Raspicam Driver

To install the uv4l driver, open the terminal and run the following commands:

$ wget http://www.linux-projects.org/listing/uv4l_repo/lrkey.asc && sudo apt-key add ./lrkey.asc

Add the following line to the file /etc/apt/sources.list :

$sudo nano /etc/apt/sources.list

deb http://www.linux-projects.org/listing/uv4l_repo/raspbian/ wheezy main

$ sudo apt-get update

$ sudo apt-get upgrade

$ sudo apt-get install uv4l uv4l-raspicam

$ sudo apt-get install uv4l-raspicam-extras

$ sudo apt-get install uv4l-server

$ sudo apt-get install uv4l-uvc

$ sudo apt-get install uv4l-xscreen

$ sudo apt-get install uv4l-mjpegstream

$ sudo reboot

Source: http://www.linux-projects.org/modules/sections/ind...

Step 4: Start the Streaming Server

Open the terminal and run the following commands:

$sudo pkill uv4l (Optional)

$sudo uv4l -nopreview --auto-video_nr --driver raspicam --encoding mjpeg --width 640 --height 480 --framerate 20 --server-option '--port=9090' --server-option '--max-queued-connections=30' --server-option '--max-streams=25' --server-option '--max-threads=29'

Notes:

The --port=9090 is the local IP port. You can use any port you like.

The --max-streams=25 is the maximum simultaneous streams.

Step 5: Find Raspberry Pi Local IP Address

Open the terminal and run:

$ifconfig

Check and write down the inet addr at eth0

Step 6: Configure Your Router

- Open a Web browser

- Type your router ip address ( http://192.168.1.1/ ).

- Router login. If you're using Linksys router, the user and pass could be "admin"

- Port forward your Raspberry Pi IP address.

If your using Linksys router:

- Click "Application&Gamming" Tab

- Click "Simple Port Forwarding" Tab

- Configure the following parameters:

External Port: 9090 (Public IP port to reach your Raspberry stream)

*Make sure your choosen port is Open with http://mxtoolbox.com/PortScan.aspx . If it's not, call your internet provider to open the port.

Internal Port: 9090 (Raspberry Pi streaming port)

Protocol: Both

To IP Address: 192.168.1.104 (Your local Raspberry Pi IP Address)

Enabled: checked

Resources

How to find your router IP address: http://portforward.com/networking/routers_ip_addre...

Port Forwarding: http://setuprouter.com/router/cisco/linksys-e1200/...

Step 7: Final Test

To see the streaming follow the next steps:

- Open a browser

- Type your public IP follow by the external/public port (http://Your public IP:9090/stream)

Comments

author
CodingJoe1 (author)2017-09-15

I also found that 720x480 resolution works well at 15 fps. I made a bash script (stored the sudo uv4l ... command in a .sh file) that I can easily access on boot up. I boot up the pi headless, press CTRL+ALT+F1 to jump to terminal. Then I type in my sh file name to startup the streaming server. I also attached one of those ten dollar cell phone lens clip on attachments to it. With the fish eye attachment I can view my whole front room from one corner.

author
CodingJoe1 (author)2017-09-15

If you have problems with the libssl1.0.0 not installable then visit this web page which tells you to add another source for deb http://security.debian.org/debian-security wheezy/updates main

https://community.spotify.com/t5/Desktop-Linux-Win...

Also if you are using the new Stretch Raspbian then replace all instances of "wheezy" with "jessie"

author
bsdaiwa (author)2017-08-20

Needs to be updated, errors when attempting to install deb http://www.linux-projects.org/listing/uv4l_repo/r... wheezy main and uv4l-server using the new Pi os Stretch.

author
bmikeb (author)2017-08-02

I also just came across this.

It is neat, reasonably concise, and nice that the video delay is reduced.

The instructions are a bit over explained with pictures of the terminal window that are barely legible and don't really add much. However, to understand how simple these instructions are, one must have a working knowledge of the Linux command line. If one is lacking such knowledge, explaining that is way beyond the scope of this instructable.

I have not yet tried putting this together. However, as for audio, i doubt it, since the Pi camera does not produce audio and incorporating audio from another source would add complications and additional CPU overhead. As for a USB camera, since the USB port and the Eithernet port use the same interface chip it might overload it. It would also add CPU usage since the onboard Pi video processing would not be used, and it (superficially) seems like this package is designed for the Pi camera. These are just guesses, more information would be available at: https://www.linux-projects.org/uv4l/ The User space Video 4Linux page, the source of the modules.

author
KHALEDA123 (author)2017-05-21

wow really nice and easy to do, love it,

Thanks

author
dick55 (author)2017-02-08

I just came across this Instructable because I am looking at ways to implement web streaming. The procedure looks pretty straight forward.

But I was struck by the fact that neither the author nor other Pi fanatics had responded to the questions asked.

As one who has asked help from a number of forums, and usually received much appreciated help, I am sensitive to this subject and can't help but find fault here.

Wish I could help, but i haven't even sampled the Pi yet :-)

author
GrantB17 (author)2016-12-05

can someone help me with next step. Once these are written in terminal, do i: Writeout, read file, justify?? forgive me, i am new to raspberry world. I need some more literal instructions

author
Carlswanson60 (author)2016-11-30

This is a great solution to the delay using VLC, not so bad getting it going either.

author
ClaraT1 (author)2016-03-29

Does it stream live audio?

author
MehtlliK (author)2016-03-08

I was wondering if this is applicable in USB cameras, and the code on how to enable it,

Any help would gladly be appreciated.

author
GeorgeT7 (author)2016-02-17

This is excellent stuff. I was wondering what do I have to run in order to use uvc driver instead of raspicam/camera module.

I have successfully set up the Uv4l server and I can reach it at http://my_RPI_address:port.

I have also installed the other modules including UV4L-uvc but I'm stack into what I have to do to run the service right now.

My usb cameras are capable of delivering H.264 streams so I'd also wanted to take advantage of this.

Any help would be greatly appreciated.

About This Instructable

83,214views

131favorites

License:

More by JoseBarreiros:Trigger a Webcam with a button and Raspberry PiRaspberry Pi Video StreamingSouth Made
Add instructable to: