Skip to content

Instantly share code, notes, and snippets.

@virtuald
Last active March 24, 2016 04:38
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save virtuald/c8835244759e53314211 to your computer and use it in GitHub Desktop.
Save virtuald/c8835244759e53314211 to your computer and use it in GitHub Desktop.
FRC mjpg-streamer scripts

NOTE: These scripts are obsolete, you should use the mjpg-streamer.ipk file published at https://github.com/robotpy/roborio-packages instead.


mjpg-streamer scripts for RoboRIO

This was very quickly put together... so not quite as polished as I would normally like. :)

We used these scripts to run two camera servers on our roboRIO. Very little CPU usage as far as we can see. Only tested with the Microsoft LifeCam 3000 cameras.

Instructions

  • Download the tarballs at http://www.chiefdelphi.com/forums/showthread.php?p=1460637
  • scp them to the roborio
  • untar the tarballs in the home directory of the admin user
  • Copy the libjpeg*.so files into the mjpg-streamer-182 directory
  • Create the files in this gist in the mjpg-streamer-182 directory

Usage

If you run install.sh, it will cause two camera servers to start on startup. Obviously, you can edit it to only start a single server.

If you run run_one.sh, it will run a server on http://roborio-XXXX.local:5800 which you can access with a web browser and figure out how to use.

Author & Thanks

Scripts created by Dustin Spicuzza, FRC Team 1418

Thanks to Mike Anderson, FRC Team 116 for distributing the roboRIO compatible builds of mjpg-streamer.

#!/bin/sh
#
# init script used to start a camera server in the background, suitable for starting the
# camera server at startup
#
PIDFILE=/var/run/mjpeg1.pid
SCRIPT=run_one.sh
case "$1" in
start)
if [ -e $PIDFILE -a -e /proc/`cat $PIDFILE 2> /dev/null` ]; then
echo "$0 already started"
exit 1
fi
touch $PIDFILE
chmod +r $PIDFILE
chown lvuser $PIDFILE
/home/admin/mjpg-streamer-182/$SCRIPT &
echo $! > $PIDFILE
;;
stop)
# kill saved PID
if [[ -f "$PIDFILE" ]]; then
kill `cat $PIDFILE`
rm $PIDFILE
fi
;;
esac
#!/bin/sh
#
# init script used to start a camera server in the background, suitable for starting the
# camera server at startup
#
PIDFILE=/var/run/mjpeg2.pid
SCRIPT=run_two.sh
case "$1" in
start)
if [ -e $PIDFILE -a -e /proc/`cat $PIDFILE 2> /dev/null` ]; then
echo "$0 already started"
exit 1
fi
touch $PIDFILE
chmod +r $PIDFILE
chown lvuser $PIDFILE
/bin/su - -- lvuser -l -c /home/admin/mjpg-streamer-182/$SCRIPT &
echo $! > $PIDFILE
;;
stop)
# kill saved PID
if [[ -f "$PIDFILE" ]]; then
kill `cat $PIDFILE`
rm $PIDFILE
fi
;;
esac
#!/bin/sh
cd `dirname $0`
ln -s `pwd`/init1.sh /etc/rc5.d/S42mjpegStream1
ln -s `pwd`/init2.sh /etc/rc5.d/S42mjpegStream2
#!/bin/sh
#
# Starts a camera server at http://roborio-XXX.local:5800/
#
cd `dirname $0`
LD_LIBRARY_PATH=`pwd` exec ./mjpg_streamer -i "./input_uvc.so --device /dev/video0 -f 10 -r 160x120" -o "./output_http.so --port 5800 -w www"
#!/bin/sh
#
# Starts a camera server at http://roborio-XXX.local:5801/
#
cd `dirname $0`
LD_LIBRARY_PATH=`pwd` exec ./mjpg_streamer -i "./input_uvc.so --device /dev/video1 -f 10 -r 160x120" -o "./output_http.so --port 5801 -w www"
#!/bin/sh
rm /etc/rc5.d/S42mjpegStream1
rm /etc/rc5.d/S42mjpegStream2
@sciencewhiz
Copy link

Mike is from Team 116, not 118

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment