20150509 webcam servers - plembo/onemoretech GitHub Wiki

title: webcam servers link: https://onemoretech.wordpress.com/2015/05/09/webcam-servers/ author: phil2nc description: post_id: 9667 created: 2015/05/09 13:03:31 created_gmt: 2015/05/09 17:03:31 comment_status: closed post_name: webcam-servers status: publish post_type: post

webcam servers

For a long time I used a little [Java program called webcam_server to "broadcast" images of myself at my desk at work for co-workers to peer in on. It was mostly a gag that let me learn a lot about image capture techniques.

Recently I tried getting the old app up and running again, which quickly led down a rabbit hole with a bit of light at the end. The webcam_server software itself was last updated in 2004, around the time most of us were still running Java 1.4 and were in the process of thinking about moving to the newly released J2SE 5. Oh, good times. But it doesn't run at all on more modern versions of Java, and there's no way I'm installing Java 1.4 on either my Fedora 21 or CentOS 7 machines. Ubuntu people may have the courage for that, but I don't.

Looking around for alternatives, I first came across flumotion, a project from 2012 sponsored by Fluendo, the Spanish company that provides major development support to the gstreamer project (and a source of affordable legal codecs for most major media formats). There was a package for Fedora 21, and the installed app had what seemed like a nice gui for setting up captures. Unfortunately it crashed and burned on execution. Since the project site explicitly warned against trying to compile from source, I moved on.

A little program called motion seemed more promising, especially since it appeared to be widely used among Raspberry Pi experimenters for simple webcam servers. The problem was that the only motion packages available for Fedora are from rpmfusion, and for reasons I've discussed before, I'm not going there. That left building from source as my only option (well, I could just switch to Ubuntu but that's not happening either). Among the prerequisites for building motion from source are the headers and shared libraries for ffmpeg.

Although I've been using statically compiled binaries for ffmpeg and its associated utilities for some time, the headers and libraries available for Fedora outside rpmforge come with most codec support missing. So my first step had to be compiling and installing the ffmpeg headers and libraries from scratch. It turned out that the latest ffmpeg source (2.6.2 from April, 2015) was relatively easy to compile, once I'd gotten all the prerequisite development packages installed. In fact the resulting binaries worked just as well as the static versions available from the ffmpeg project site.

But the the latest stable version of motion, 3.2.12, last updated in 2010, won't build with the latest ffmpeg. In fact it also wouldn't build with the recommended 2006 version of ffmpeg hosted on the motion project site. I did give ffserver (a utility that can be set up to stream webcam video) at try, but had trouble getting it to generate either webm or flv, which at the time were what I though would be the formats I'd like to use.

After about a week I finally found fswebcam, another little utility like motion that could be used to capture jpeg images from a webcam. There was an rpm available for Fedora 21. The really nice thing about fswebcam is that it only needed the gd, jpeg, png and freetype libraries. It could be run in daemon mode and configured to refresh as many times a second as desired. Even a simple meta refresh of a page with a link to the image would provide a passable stop-action experience for users. It wasn't by any means going to be a live streaming solution, but it would do for most purposes.

Copyright 2004-2019 Phil Lembo