Linksys Video, MPlayer, and MEncoder
WHATABOUT
Details how-to retrieve, store and manipulate the video stream of the Linksys WVC54G camera using debian linux and a few GNU tools...
Linksys WVC54G rundown
This camera has a relatively simple built-in web server; you can find many resources on the net on how to manipulate the web server to record small clips, email them, ftp them, etc...; the camera webserver supports viewing the camera through a microsoft internet explorer with the miracle of an activeX component - not entirely useful for other uses such as recording...
Another really cool thing is the ability to setup an RTSP server from within the setup pages of this webserver. Although, the maximum resolution you can achieve for this camera is only 160x120; this is really ment for connecting with a mobile device, and not useful for anything else.
So what is a guy to do when wanting to record this camera; we could read some forums and learn how this camera actually runs a small linux kernel; we could reflash this device with our own custom firmware todo all sorts of nifty things i'm sure - but the rest of this article will center around what the factory device can do.
Problem
Generally, we don't want continuous recording of this camera; we also might mention the linksys WVC54G camera has really lame motion detection. So we opted for finding out how to create a time lapsed recording - grab 1 frame of video once per second and make a movie out of it.
One Solution
Using debian we installed mplayer; surfing google we found alot of chatter about mplayer being included with recent debian release, but pieces of it are stripped such as the mencoder application that is normally distributed as part of its bundle... we'll need to uninstall mplayer if it exists and reinstall from debian-multimedia.org.
First we add a line to /etc/apt/sources.list
deb http://www.debian-multimedia.org lenny main
Fetch and install the mplayer & mencoder packages using apt-get
apt-get remove mplayer apt-get update apt-get install mplayer apt-get install mencoder
Next, we demonstrate how mplayer can connect to, and dump the video feed of the linksys camera; to do this we
mplayer http://[usr]:[pswd]@192.168.0.25/img/video.asf -vo jpeg -fps 24 -vf framestep=24
Where:
[usr]
username for authenticating to linksys video camera
[pswd]
password for authenticating to linksys video camera
192.168.0.25
ip address of the camera
img/video.asf
url of video stream;
-vo jpeg -fps 24 -vf framestep=24
basically indicates we want output of jpegs into working directory; force camera to 24 fps, only take jpeg every 24 frames (1 times a second). see the man pages for more info
-frames 500
add this option to limit the number of frames of video to process; otherwise video will be split into jpegs indefinitely -- until harddrive is full.
At this point, we should add that checking out these mplayer options presented above may be useful in performing some more advanced jpeg capturing; the "-vo jpeg" option in particular has a few attributes that allow allocating sub directorys and naming conventions that may be useful in a more sustainable end solution; see the 'Bringing this altogether' section below for some ideas;
Once we have the jpegs, we could use MEncoder to acquire all the jpgs within the working directory and create an avi compatibile with microsoft mpeg4 encoding (player codecs); to do this we
mencoder "mf://*.jpg" -mf fps=1 -o output.avi -ovc lavc -lavcopts vcodec=msmpeg4
Where:
options are best looked up in man pages
in particular the "-lavcopts vcodec=" option controls the output avi encoding format
and fps=1 controls the rendering of each jpeg frame (in this case); 1 jpeg per second.
Bringing this altogether...
This article has given the break down of making the connecting to the raw video stream; splitting it into jpegs, and even showing how to potentially reclaim those jpegs into a movie format again; the final steps could be to setup cron to kick off parellel processes such as:
- use mplayer "-vo jpeg" attributes to place a specified number of jpegs into named directorys and this could continue indefinitely
- have a bash script run periodically to
- run MEncoder to rip directorys into short movies
- remove processed directorys
- and possibly index and clean old movies as they are generated in such a way to make this sustainable
- Login to post comments