I am trying to launch mjpg streamer when a webcam is plugged in. So far I've been able to detect when the webcam is pluged and I've been able to launch it.
But two issues appear:
first the port doesn't appear to be open
second the process is killed after about 3 minutes
Im running on Ubuntu 18.04.4 LTS
here is what I assume is the culprit file
/etc/udev/rules.d/10-usbmount.rules
#https://stackoverflow.com/questions/20084740/udev-run-program-on-usb-flash-drive-insert
KERNEL=="video[0-9]*", ENV{ID_SERIAL}!="?*", SUBSYSTEMS=="usb", RUN+="/usr/bin/usbdevinserted"
/usr/bin/usbdevinserted
#!/bin/bash
echo $DEVNAME 2>&1 > /tmp/usbdevinfo
#set 2>&1 >> /tmp/usbdevinfo
if [[ $(pgrep mjpg_streamer) ]];
then
echo "Stoping Mjpg_Streamer" 2>&1 >> /tmp/usbdevinfo;
pkill mjpg_streamer;
echo "mjpg_Streamer stoped" 2>&1 >> /tmp/usbdevinfo;
fi
if [[ $(v4l2-ctl --device=$DEVNAME --all | grep "Video input") ]];
then
echo "launching mjpg_streamer on $DEVNAME" 2>&1 >> /tmp/usbdevinfo;
(mjpg_streamer -i "input_uvc.so -f 15 -r 1080x720 -d $DEVNAME" -o "output_http.so -w /pathToHome/mjpg-streamer/www -p 8080" 2>&1 >> /tmp/usbdevinfo) | at now
fi