Raspberry Pi – using the MJPG-Streamer to stream a Raspberry Cam over HTTP

raspberrypi_logo.jpg   How to build and run MJPG-Streamer on the Raspberry Pi

# cd /tmp
# apt-get install libjpeg8-dev imagemagick libv4l-dev
# ln -s /usr/include/linux/videodev2.h /usr/include/linux/videodev.h
# wget http://sourceforge.net/code-snapshots/svn/m/mj/mjpg-streamer/code/mjpg-streamer-code-182.zip
# unzip mjpg-streamer-code-182.zip
# cd mjpg-streamer-code-182/mjpg-streamer
# make mjpg_streamer input_file.so output_http.so
# cp mjpg_streamer /usr/local/bin
# cp output_http.so input_file.so /usr/local/lib/
# cp -R www /usr/local/www
# mkdir /tmp/stream
# raspistill —nopreview -w 640 -h 480 -q 5 -o /tmp/stream/pic.jpg -tl 100 -t 0 -th 0:0:0 > /dev/null 2>&1 &
# LD_LIBRARY_PATH=/usr/local/lib mjpg_streamer -i „input_file.so -f /tmp/stream -n pic.jpg“ -o „output_http.so -w /usr/local/www“ > /dev/null 2>&1 &
# cd /tmp
# rm -rf mjpg-streamer-182*
 RaspberryPI_Cam_01
# vi /usr/local/bin/stream/start_stream.sh
#!/bin/bash
if [ ! -d /tmp/stream ]
then
mkdir /tmp/stream/
fi
if pgrep raspistill > /dev/null
then
echo „raspistill already running“
else
 raspistill —nopreview -w 640 -h 480 -q 5 -o /tmp/stream/pic.jpg -tl 100 -t 0 -th 0:0:0 > /dev/null 2>&1 &
echo „raspistill started“
fi
if pgrep mjpg_streamer > /dev/null
then
echo „mjpg_streamer already running“
else
 LD_LIBRARY_PATH=/usr/local/lib mjpg_streamer -i „input_file.so -f /tmp/stream -n pic.jpg“ -o „output_http.so -w /usr/local/www“ > /dev/null 2>&1 &
echo „mjpg_streamer started“
fi
# vi /usr/local/bin/stream/stop_stream.sh
#!/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

Leave a Reply

You must be logged in to post a comment.