Hi i am new to octoprint. I have a new install of Octoprint on my Linux Mint intel Nuc. I have manage to get my Logitech c920 to work but i my restart the camera each time i reboot. I must run this command to get my webcam to work sudo /home/chris/scripts/webcam start. Can anyone help me figure out what is wrong?? This is a guide i followed because i am pretty new with linux.
cd ~
sudo apt install subversion libjpeg8-dev imagemagick ffmpeg libv4l-dev cmake
git clone GitHub - jacksonliam/mjpg-streamer: Fork of http://sourceforge.net/projects/mjpg-streamer/
cd mjpg-streamer/mjpg-streamer-experimental
export LD_LIBRARY_PATH=.
make
Test mjpg streamer:
sudo ./mjpg_streamer -i "./input_uvc.so" -o "./output_http.so"
Create webcam startup scripts don’t use sudo:
cd ~
mkdir scripts
nano /home/chris/scripts/webcam
#!/bin/bash
Start / stop streamer daemon
case "$1" in
start)
/home/chris/scripts/webcamDaemon >/dev/null 2>&1 &
echo "$0: started"
;;
stop)
pkill -x webcamDaemon
pkill -x mjpg_streamer
echo "$0: stopped"
;;
*)
echo "Usage: $0 {start|stop}" >&2
;;
esac
Create webcam Daemon script don’t use sudo:
nano /home/chris/scripts/webcamDaemon
#!/bin/bash
MJPGSTREAMER_HOME=/home/chris/mjpg-streamer/mjpg-streamer-experimental
MJPGSTREAMER_INPUT_USB="input_uvc.so"
MJPGSTREAMER_INPUT_RASPICAM="input_raspicam.so"
init configuration
camera="auto"
camera_usb_options="-r 640x480 -f 10"
camera_raspi_options="-fps 10"
if [ -e "/boot/octopi.txt" ]; then
source "/boot/octopi.txt"
fi
runs MJPG Streamer, using the provided input plugin + configuration
function runMjpgStreamer {
input=$1
pushd $MJPGSTREAMER_HOME
echo Running ./mjpg_streamer -o "output_http.so -w ./www" -i "$input"
LD_LIBRARY_PATH=. ./mjpg_streamer -o "output_http.so -w ./www" -i "$input"
popd
}
starts up the RasPiCam
function startRaspi {
logger "Starting Raspberry Pi camera"
runMjpgStreamer "$MJPGSTREAMER_INPUT_RASPICAM $camera_raspi_options"
}
starts up the USB webcam
function startUsb {
logger "Starting USB webcam"
runMjpgStreamer "$MJPGSTREAMER_INPUT_USB $camera_usb_options"
}
we need this to prevent the later calls to vcgencmd from blocking
I have no idea why, but that's how it is...
vcgencmd version
echo configuration
echo camera: $camera
echo usb options: $camera_usb_options
echo raspi options: $camera_raspi_options
keep mjpg streamer running if some camera is attached
while true; do
if [ -e "/dev/video0" ] && { [ "$camera" = "auto" ] || [ "$camera" = "usb" ] ; }; then
startUsb
elif [ "vcgencmd get_camera
" = "supported=1 detected=1" ] && { [ "$camera" = "auto" ] || [ "$camera" = "raspi" ] ; }; then
startRaspi
fi
sleep 120
done
Edit webcam file startup permissions:
sudo chmod +x /home/chris/scripts/webcam
sudo chmod +x /home/chris/scripts/webcamDaemon
Add webcams to startup:
sudo nano /etc/rc.local
#!/bin/sh -e
rc.local
This script is executed at the end of each multiuser runlevel.
Make sure that the script will "" on success or any other
value on error.
In order to enable or disable this script just change the execution
bits.
By default this script does nothing.
/home/chris/scripts/webcam start
exit 0
Start webcam:
sudo /home/chris/scripts/webcam start
Change rc.local permissions:
sudo chmod +x /etc/rc.local
Any help would be greatly appreciated
Thanks
Chris