Setting up an IP Camera to Live Stream Experiments
This guide will walk the user through setting up an IP Camera for streaming live video to the Internet.
Overview:
The following items will be needed for the setup:
Item | Cost (8/14/14) | Link |
---|---|---|
IP Camera | $357.90 | Axis M1054 |
Power Over Ethernet (POE) Injector | $17.89 | |
Linux Server with VLC installed | N/A | VLC |
Web Server | N/A | N/A |
The IP camera will capture the video and send the video stream to the Linux server. The Linux server will then re-stream the data to the web server. The Linux server will keep the load off of the camera, allowing more users to view the stream at once. An example network layout is provided below.
Choosing a camera:
The type of camera chosen will determine the quality of your final video stream. The camera we will use in this guide is an Axis M1054 network camera. This camera provides all of the needed features for a great price.
When looking for a camera, consider the following features:
-
RTSP streaming support – The camera must support this protocol to be able to stream video to the Linux server.
-
Resolution – The higher the resolution, the better the image quality will be. Look for a camera that has a resolution of at least 1280x800.
- Power Over Ethernet Support– POE will allow the camera to be powered from the ethernet cable. This means that you will only have to run one cable for both data and power to the camera.
Setting up the camera:
The instructions below are for setting up the Axis M1054 network camera. If you are using a different camera, please refer to its user guide for setup.
- Connect the camera to your network and provide power.
- Use the Axis IP Utility to find the IP of the camera.
- Open a web browser and enter the IP that you received from Step 2.
- Set a secure root password for the camera, this will be used when making changes to the camera settings.
- Contact your network administrator and determine what IP settings your camera should have. For security, the camera should only be visible on your local area network (LAN). The camera should be on the same LAN as your Linux server.
- Check the “Enable RTSP server” box under System Options -> Network -> TCP/IP -> Advanced
- If the camera is in very dark or very bright environment you may need to adjust the image settings (brightness, contrast, and exposure).
Setting up the Linux server
The Linux server will re-stream the video from the IP camera and stream it to the web server. For this example we will use CentOS 6.0 however any Linux distribution that supports VLC will work.
- Install VLC onto your Linux server. If you need help, check this guide.
- Create a new bash script with the name ‘vlc.sh’.
- Type the following into the bash script, note the cvlc command is all one line.
#! /bin/bash
cvlc -vvv rtsp://YOUR CAMERA IP/axis-media/media.amp --sout '#transcode{vcodec=mjpg,vb=2500,scale=1,fps=30,acodec=none}:std{access=http{mime=multipart/x-mixed- replace;boundary=--7b3cc56e5f51db803f790dad720ed50a} , mux=mpjpeg , dst=:7070/stream.mpjpeg}'
- Replace “YOUR CAMERA IP” above with the IP address of your camera.
- Create a new user on your Linux machine called vlc.
- Make sure the vlc user has read and execute privileges to the vlc.sh script.
- Add the script to the startup file for your system. To do this on CentOS edit '/etc/rc.d/rc.local’ and add ‘su –l vlc –c /vlc.sh &’. This will launch the script as the VLC user on startup.
- Reboot the machine and check that the script started using the top command.
Setting up the Web Server:
Once the Linux server is up and running, you can embed the stream on your webpage using the HTML <img> tag. See the code below for an example.
<img height="600" width="800" src="http://YOUR SERVER IP/stream.mpjpeg" />
Replace “YOUR SERVER IP” with the IP address of your Linux server. The stream will be visible to modern web browsers as well as mobile devices such as iPads ands iPhones.
Example Image
The image below is from the Axis M1054 network camera running at a scaled resolution of 800x500.