Feb 22, 2018

Auto-starting mjpg-streamer on Octopi

The normal command for me to start my mjpg-streamer (from its directory) is:
    ./mjpg_streamer -i "./input_uvc.so -n" -o "./output_http.so -w ./www"

The problem arises, when you want this to start automatically when your Raspberry Pi reboots (or even run in the background). You can't just simply add an & and even the built-in -b(ackground) option doesn't seem to work amazingly well.

So, here's what I've been able to sort out:
Copy all of the files to:
    /usr/local/sbin/mjpg-streamer/mjpg-streamer-experimental
Test execution from any folder use the following full path:
    /usr/local/sbin/mjpg-streamer/mjpg-streamer-experimental/mjpg_streamer -i "input_uvc.so -n" -o "output_http.so -w ./www"

If you get the message "ERROR: could not find input plugin", use the following command:
    export LD_LIBRARY_PATH=/usr/local/sbin/mjpg-streamer/mjpg-streamer-experimental/

If you want it to run & stay running (background mode), use the -b switch:
    /usr/local/sbin/mjpg-streamer/mjpg-streamer-experimental/mjpg_streamer -i "input_uvc.so -n" -b -o "output_http.so -w ./www"

To stop the background mjpg-streamer daemon, use the following command:
    kill -9 `pidof mjpg_streamer`

To make the camera start-up automatically, add the following lines to /etc/rc.local:
    /usr/local/sbin/mjpg-streamer/mjpg-streamer-experimental/mjpg_streamer -i "input_uvc.so -n" -o "output_http.so -w ./www" export LD_LIBRARY_PATH=/usr/local/sbin/mjpg-streamer/mjpg-streamer-experimental/
Also, make sure that /etc/rc.local is set to execute:
    sudo chmod 755 /etc/rc.local

For clarity, the actual binary is mjpg_streamer but it is usually referred to in conversation as mjpg-streamer. If you're searching, search for both!

No comments: