I am trying to start a stream on my Raspberry Pi Camera when I boot the Raspberry Pi. I have tried the following options:
Using crontab
@reboot /home/pi/video.sh &
Using init.d Copied the script video.sh into init.d
Added following code to /etc/rc.local
if [ $(tty) == /dev/tty1 ]; then
/home/pi/video.sh &
fi
I can also add that the script contain this:
raspivid -o - -t 0 -hf -w 640 -h 360 -fps 25 | cvlc -vvv stream:///dev/stdin --sout '#rtp{sdp=rtsp://:8554}' :demux=h264
This string starts a continuous flow of data and start to stream from VLC. To watch the stream I start VLC, or as I do, start the HTML page I have created and enter the raspberry IP-address.
My guess is that when booting the Pi it runs the script, but after that stop or get terminated by another startup script, since the camera just blinks for a second then turn off.
Is there a way to make this script keep running even after startup?
root
and as userpi
?