Robert Cudmore    archive    tags    search    software


mjpg-streamer on a Raspberry Pi

This post covers downloading, installing and running mjp-streamer on a raspberry pi. There are two options for installation and streaming depending on if you stream from (1) a rapsberry pi camera module or (2) a USB camera.

Install mjpg streamer

    sudo 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  

Here is where the installation differs depending on if you are installing (1) a usb camera or (2) the raspberry pi camera module

(1) Raspberry Pi camera module

    # build with 'make'
    cd mjpg-streamer-code-182/mjpg-streamer  
    make mjpg_streamer input_file.so output_http.so  
    # install by copying files
    sudo cp mjpg_streamer /usr/local/bin  
    sudo cp output_http.so input_file.so /usr/local/lib/  
    sudo cp -R www /usr/local/www      
FOR COMPARISON, HERE IS SAME FOR USB CAMERA. IMPORTANT THING HERE IS '**input_uvc.so**'.
    # build with 'make'
    cd mjpg-streamer
    make mjpg_streamer input_file.so input_uvc.so output_http.so
    # install by copying
    sudo cp mjpg_streamer /usr/local/bin
    sudo cp output_http.so input_file.so input_uvc.so /usr/local/lib/
    sudo cp -R www /usr/local/www
I GUESS YOU COULD JUST FOLLOW 'USB CAMERA' AND IT WOULD WORK FOR BOTH
    mkdir /tmp/stream  
    raspistill --nopreview -w 640 -h 480 -q 5 -o /tmp/stream/pic.jpg -tl 100 -t 9999999 -th 0:0:0 &  
    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"

(2) build for usb camera

    mjpg_streamer --input "input_uvc.so --help"
    # note, i am not showing the output here
    # important line in output is this:
    #  [-y | --yuv ]..........: enable YUYV format and disable MJPEG mode
    # build with 'make'
    cd mjpg-streamer
    make mjpg_streamer input_file.so input_uvc.so output_http.so
    # install by copying
    sudo cp mjpg_streamer /usr/local/bin
    sudo cp output_http.so input_file.so input_uvc.so /usr/local/lib/
    sudo cp -R www /usr/local/www
    /usr/local/bin/mjpg_streamer -i "/usr/local/lib/input_uvc.so -y" -o "/usr/local/lib/output_http.so -w /usr/local/www"
If my camera used MJPEG instead of YUYV, the command is the same without the '-y'.
    /usr/local/bin/mjpg_streamer -i "/usr/local/lib/input_uvc.so" -o "/usr/local/lib/output_http.so -w /usr/local/www"

done

Tags: raspberry pi

©2020. Robert Cudmore.