Skip to content

Instantly share code, notes, and snippets.

@miguelmota
Last active June 30, 2018 18:38
Show Gist options
  • Save miguelmota/8203904 to your computer and use it in GitHub Desktop.
Save miguelmota/8203904 to your computer and use it in GitHub Desktop.
Bash scripts to start and stop raspistill and mjpg_streamer. Blog post: http://www.miguelmota.com/blog/raspberry-pi-camera-board-video-streaming/
#!/bin/bash
if [ ! -d /tmp/stream ]
then
mkdir /tmp/stream/
fi
if pgrep raspistill > /dev/null
then
echo "raspistill already running"
else
raspistill -w 640 -h 480 -q 5 -o /tmp/stream/pic.jpg -tl 100 -t 9999999 -th 0:0:0 -n > /dev/null 2>&1&
echo "raspistill started"
fi
if pgrep mjpg_streamer > /dev/null
then
echo "mjpg_streamer already running"
else
LD_LIBRARY_PATH=/opt/mjpg-streamer/ /opt/mjpg-streamer/mjpg_streamer -i "input_file.so -f /tmp/stream -n pic.jpg" -o "output_http.so -p 9000 -w /opt/mjpg-streamer/www" > /dev/null 2>&1&
echo "mjpg_streamer started"
fi
#!/bin/bash
if pgrep raspistill
then
kill $(pgrep raspistill) > /dev/null 2>&1
echo "raspistill stopped"
else
echo "raspistill not running"
fi
if pgrep mjpg_streamer
then
kill $(pgrep mjpg_streamer) > /dev/null 2>&1
echo "mjpg_streamer stopped"
else
echo "mjpg_streamer not running"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment