20070503 webcam_server - plembo/onemoretech GitHub Wiki
title: webcam_server link: https://onemoretech.wordpress.com/2007/05/03/webcam_server/ author: lembobro description: post_id: 716 created: 2007/05/03 21:13:00 created_gmt: 2007/05/03 21:13:00 comment_status: open post_name: webcam_server status: publish post_type: post
There were some pretty glaring errors in the init script below that were carried over from the import of my old site’s content, for which I apologize to anyone who tried and failed to get it working.
I work at some distance from my company’s corporate headquarters in New York. Although they try to get me to come up for a visit from time to time, for some of my co-workers this just isn’t enough to satisfy their curiosity, nay, need, to see what I look like from day to day. As a result, early on I set up “Phil Cam” on my work desktop. An old Creative USB webcam provided the hardware. For the software I downloaded and installed the open source webcam_server software written by Mike Morrison.
Installation is pretty straightforward. I basically followed the doc that came with the package, with a couple of differences for my own CentOS Linux environment.
Basically all you have to do is run the webcam_server binary, which sets up a listener on port 8888 for a web page that invokes the included Java applet (called “applet.jar”).
Here’s the APPLET code that needs to be embedded in the web page:
`
<APPLET CODE = "WebCamApplet.class" archive="applet.jar" WIDTH = "320"
HEIGHT = "240">
<param name=URL value="http://www.example.com:8888">
<param name=FPS value="10">
<param name=width value="320">
<param name=height value="240">
</APPLET>
`
The Java applet, supporting classes, jpegs and index.html pages are kept in /var/www/html/philcam.
Because this runs on my desktop at work, I wanted to run it as a daemon. To make that happen I moved the webcam_server binary from /usr/local/bin to /usr/sbin and then deployed the following RHEL init script:
`
#!/bin/bash
# webcam_server This shell script takes care of starting
# and stopping the Webcam Server Application
#
# chkconfig: 2345 99 40
# description: Webcam Server is an application for streaming video
# processname: webcam_server
# pidfile: /var/run/webcam_server.pid
# Source function library
prog="webcam_server"
. /etc/rc.d/init.d/functions
if [ -f /etc/sysconfig/$prog ]; then
. /etc/sysconfig/$prog
fi
wcargs=" -s -l /var/log/webcam_server.log"
wcserver=${WEBCAM_SERVER-/usr/sbin/webcam_server}
pidfile=${PIDFILE-/var/run/webcam_server.pid}
lockfile=${LOCKFILE-/var/lock/webcam_server}
RETVAL=0
start() {
echo -n $"Starting $prog: "
daemon $wcserver $wcargs
RETVAL=$?
echo
[ $RETVAL = 0 ] && touch ${lockfile}
return $RETVAL
}
stop() {
echo -n $"Stopping $prog: "
killproc $wcserver
RETVAL=$?
echo
[ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile}
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
*)
echo $"Usage: $prog {start|stop}"
exit 1
esac
exit $RETVAL
`
Copyright 2004-2019 Phil Lembo