I was wondering if someone can help me out?
I have mjpg-streamer installed that i normally start manually using
./mjpg-streamer.sh start
I am wanting to make mjpg-streamer start on boot up.
I followed this link initially but with no joy.
http://www.phillips321.co.uk/2012/11/05 ... ream-cctv/
The program is running after boot but only for a few seconds then i get no response from the page http://x.x.x.x:8081/?action=stream
When i say running i can see the process in netstat -lp -tu and for a few seconds the webcam stream works.
If i start it manually i get the response that its already runnning.
If I kill it first then start it manually the above url link working and video is streamed ok.
These are the actions i have taken to get this far.
I have created a file called mjpg-streamer.sh in /etc/init.d/ directory. The contents are
- Code: Select all
#!/bin/sh
# /etc/init.d/mjpg_streamer.sh
# v0.2 phillips321.co.uk
### BEGIN INIT INFO
# Provides: mjpg_streamer.sh
# Required-Start: $network
# Required-Stop: $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: mjpg_streamer for webcam
# Description: Streams /dev/video0 to http://IP/?action=stream
### END INIT INFO
f_message(){
echo "[+] $1"
echo "space here"
}
# Carry out specific functions when asked to by the system
case "$1" in
start)
f_message "Starting mjpg_streamer"
/home/pi/mjpg-streamer/mjpg-streamer.sh start
#mjpg_streamer -b -i "/usr/lib/input_uvc.so -d /dev/video0" -o "/usr/lib/output_http.so -p 8081 -w /var/www/mjpg_streamer -n"
sleep 2
f_message "mjpg_streamer started"
;;
stop)
f_message "Stopping mjpg_streamer."
/home/pi/mjpg-streamer/mjpg-streamer.sh stop
f_message "mjpg_streamer stopped"
;;
restart)
f_message "Restarting mjpg_streamer"
/home/pi/mjpg-streamer/mjpg-streamer.sh stop
#killall mjpg-streamer
/home/pi/mjpg-streamer/mjpg-streamer.sh start
#mjpg-streamer -b -i "/usr/lib/input_uvc.so -d /dev/video0" -o "/usr/lib/output_http.so -p 8081 -w /var/www/mjpg_streamer -n"
sleep 2
f_message "Restarted mjpg_streamer"
;;
status)
pid=`ps -A | grep mjpg-streamer | grep -v "grep" | grep -v mjpg-streamer. | awk .{print $1}. | head -n 1`
if [ -n "$pid" ];
then
f_message "mjpg_streamer is running with pid ${pid}"
f_message "mjpg_streamer was started with the following command line"
cat /proc/${pid}/cmdline ; echo ""
else
f_message "Could not find mjpg_streamer running"
fi
;;
*)
f_message "Usage: $0 {start|stop|status|restart}"
exit 1
;;
esac
exit 0
you can see that i commented out the line
- Code: Select all
mjpg-streamer -b -i "/usr/lib/input_uvc.so -d /dev/video0" -o "/usr/lib/output_http.so -p 8081 -w /var/www/mjpg_streamer -n"
as this was the only way to get it working manually, by putting the direct path to the program and adding the start/stop parameter on the end instead.
After creating the above I made the file and path to it executable using chmod +X <xxx> and chmod 777 <name>.
I then did as per the instructions and made it runnable from boot with
- Code: Select all
sudo update-rc.d mjpg-streamer.sh defaults
Watching the streaming url on bootup, it starts the webpage streaming but then it stops(light goes out on webcam/url stops responding) even though the process (netstat -lp -tu) still shows it as running.
My thoughts were that there was a problem with the symbolic links and one of these was killing the program but there again it still showing in netstat- -lp -tu.
To try it anyway I manually added these
ln -s /etc/init.d/mjpg-streamer.sh /etc/rc0.d/K01mjpg-streamer.sh
ln -s /etc/init.d/mjpg-streamer.sh /etc/rc1.d/K01mjpg-streamer.sh
ln -s /etc/init.d/mjpg-streamer.sh /etc/rc2.d/S03mjpg-streamer.sh
ln -s /etc/init.d/mjpg-streamer.sh /etc/rc3.d/S03mjpg-streamer.sh
ln -s /etc/init.d/mjpg-streamer.sh /etc/rc4.d/S03mjpg-streamer.sh
ln -s /etc/init.d/mjpg-streamer.sh /etc/rc5.d/S03mjpg-streamer.sh
ln -s /etc/init.d/mjpg-streamer.sh /etc/rc6.d/K01mjpg-streamer.sh
So in all i think the process is running from boot but there is a problem with the actual streaming working, but as mentioned only when asking it to do it from boot, works ok when manually executing the program with
/etc/init.d/mjpg-streamer.sh start
I maybe off the track completely so maybe useful to try and diagnose why it starts and works ok and then a few seconds after, further into the bootup, it stops again.
If anyone has any ideas or tips they would be much appreciated.
Thanks in advance
Adrian