So I'm new to Apache servers and LAMP stacks in general.
I'm working on a home website that's gonna show room temperatures and a few other functions using a MySQL server.
I have a Raspberry Pi with a USB camera at my front door and I want to stream it to my Apache server to display the camera's live feed on my website. The PC is running Ubuntu 16.04.5.
Install git: sudo apt-get install git
Clone mjpg-streamer-experimental: git clone https://github.com/jacksonliam/mjpg-streamer/tree/master/mjpg-streamer-experimental
- The experimental version worked way better for me on my Raspberry Pi than the regular one, that's why I recommend using it.
Compile it: cd mjpg-streamer-experimental && ./config && make
Create a script that will start the streaming automatically on every boot: nano onboot.sh
#!/bin/bash
cd /home/pi/mjpg-streamer-experimental
./mjpg_streamer -i "input_uvc.so -d /dev/video0 -t pal -r 720x576" -o "output_http.so -w ./www -p 8740"
Replace video0
with your video interface, pal
with ntsc
if your camera uses ntsc
and 720x576
with the resolution of your camera. Then hit CTRL + O to save the file.
You can now run bash ./onboot.sh
to test if the streaming works.
We will now use cron
(should be pre-installed) to make this script run everytime on boot:
Run crontab -e
to edit the current user's crontab and append the following line into it:
@reboot bash /path/to/mjpg-streamer-experimental/onboot.sh
Again CTRL + O to save the file and apply it.
Now this is very simple. You are able to access mjpg-streamer's interface using http://<your-raspberry-pi-IP>:8740
on any machine in the network. In order to embed the live scream into your website, simple put the following code on the site where you want the stream to be:
<img src="http://<raspberry-pi-IP>:8740/?action=stream" />
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments