20090313 webcam_server on ubuntu intrepid - plembo/onemoretech GitHub Wiki

title: webcam_server on Ubuntu Intrepid link: https://onemoretech.wordpress.com/2009/03/13/webcam_server-on-ubuntu-intrepid/ author: lembobro description: post_id: 362 created: 2009/03/13 07:16:50 created_gmt: 2009/03/13 07:16:50 comment_status: open post_name: webcam_server-on-ubuntu-intrepid status: publish post_type: post

webcam_server on Ubuntu Intrepid

Since moving everything from CentOS to Ubuntu 8.10 (Intrepid Ibex), I’ve been slowly getting all the bells and whistles running again. This evening I finally sat down to figure out how to get webcam_server to work.

An earlier article describes how I set it up on CentOS.

Ubuntu makes it available as a package. The name is webcam-server. Out of the box it throws an error message, “No supported colour palette found”, due to a bug. The basic problem is that this old software was written to use V4L. To run it in compatibility mode first enter

export LD_PRELOAD=/usr/lib/libv4l/v4l1compat.so

as the executing user.

Once you’ve done this you can go ahead and invoke it in daemon mode by adding the “-s” switch:

webcam-server -s

If you use the included sample Java applet to connect to the server from a web page, remember to change the frame rate to something reasonable like

<param name=FPS value="10">

rather than the “1” value in the example, in order to get the image refreshed enough to actually see some motion.

Another important point is to make sure the URL you enter for the server is resolvable and accessible to anyone you want to be able to dial it up in a web browser. The default “localhost” in the example will only work for someone who is on the server host itself.

One last item to deal with is the writing of a simple init script to start the server automatically after a reboot.

POSTSCRIPT:

My init script:

`

#! /bin/sh
export LD_PRELOAD=/usr/lib/libv4l/v4l1compat.so
	
### BEGIN INIT INFO
# Provides:          webcam-server
# Required-Start:    $remote_fs
# Required-Stop:     $remote_fs
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: WebCam Server initscript
# Description:       This file starts/stops the webcam-server service
#                    placed in /etc/init.d.
### END INIT INFO
	
PATH=/sbin:/usr/sbin:/bin:/usr/bin
DESC="WebCam Server service"
NAME=webcam-server
DAEMON=/usr/bin/$NAME
DAEMON_ARGS="-s"
PIDFILE=/var/run/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME
	
[ -x "$DAEMON" ] || exit 0
	
[ -r /etc/default/$NAME ] && . /etc/default/$NAME
	
. /lib/init/vars.sh
	
. /lib/lsb/init-functions
	
do_start()
{
	start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null
		|| return 1
	start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --
		$DAEMON_ARGS
		|| return 2
}
	
do_stop()
{
	start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME
	RETVAL="$?"
	[ "$RETVAL" = 2 ] && return 2
	start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON
	[ "$?" = 2 ] && return 2
	rm -f $PIDFILE
	return "$RETVAL"
}
	
do_reload() {
	start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name $NAME
	return 0
}
	
case "$1" in
  start)
	[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
	do_start
	case "$?" in
		0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
		2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
	esac
	;;
  stop)
	[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
	do_stop
	case "$?" in
		0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
		2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
	esac
	;;
  restart|force-reload)
	log_daemon_msg "Restarting $DESC" "$NAME"
	do_stop
	case "$?" in
	  0|1)
		do_start
		case "$?" in
			0) log_end_msg 0 ;;
			1) log_end_msg 1 ;; # Old process is still running
			*) log_end_msg 1 ;; # Failed to start
		esac
		;;
	  *)
	  	# Failed to stop
		log_end_msg 1
		;;
	esac
	;;
  *)
	echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
	exit 3
	;;
esac
	
:

Copyright 2004-2019 Phil Lembo