mcamip

Software for the D-Link DCS-900 internet security webcam

This is Unix / Linux OS software running on X windows, released under the GPL licence.

Current version has motion dection and frame rate control (saves on disk space), can output mjpeg tools YUV,
you can view in X or with mplayer, and encode to almost any known format with mencoder, ffmpeg, or transcode.
Also you can add on screen text on objects in any color and any position, and dynamically change text.
Added support for EASYN Chinese ethernet webcam.

Download

Full source in C:
mcamip-0.7.9.tgz

The lsm info file:
mcamip-0.7.9.lsm

Current known bugs:

None.

Features as command line switches (it is possible to run the program from a script without display):

command line switchfunction
-a stringcamera URL IP address in decimal with points, or as a URL
-bforce black and white to YUV out (color off)
-cactivate change detection (motion detection), default off
-d stringdirectory name where single frames are stored, default ~/frames
-e intmotion detection threshold, more is less sensitive
-f floatframes_per_second playback speed, set camera to auto in video setup, mcamip will display the real fps and warn you if the system cannot keep up with what you specified.
-gdisplay in UTC time
-hhelp (this help)
-i stringfilename of semaphore file created when motion detected, default none, use with -j or -y, and -c and -e, the program using the semaphore file should erase it.
-joutput jpeg single pictures with incrementing numbers in framedir
-oread and display on screen text in mcamip format from ~/mcamip_os.txt every second
-nshow frame number since start
-p intcamera IP port in decimal
-s intclock position, 0=top_left, 1=top_middle, 2=top_right, 3=bottom_left, 4=bottom_middle, 5=bottom_right, default bottom_middle
-tshow time in yuv output
-u stringusername for access control
-v debug, prints functions and arguments
-w stringpassword for access control
-xshow X windows display
-ysend mjpeg tools yuv format to stdout
-zsend full camera stream to stdout


Examples:

Visual output via mplayer:
mcamip -a 10.0.0.151 -p 81 -u USERNAME -w PASSWORD -y | mplayer -fs -

Show just a picture in X windows:
mcamip -a 10.0.0.151 -p 81 -u USERNAME -w PASSWORD -x

Encode to mpeg4 AVI:
mcamip -a camera4 -p 81 -u USERNAME -w PASSWORD -y | mencoder - -o title2.avi -oac copy -ovc lavc

Encode to mpeg4 AVI with on screen clock bottom middle in UTC (Greenwich time),
and set playback speed to 25 fps:
mcamip -t -f 25 -a camera4 -p 81 -x -y -g -u USERNAME -w PASSWORD | \
mencoder - -o title2.avi -oac copy -ovc lavc

Encode with motion detection to an AVI file:
mcamip -e 1000 -c -u USERNAME -w PASSWORD -f 16 -t -a camera4 -p 80 -x -y | \
mencoder - -o /huge/recording.avi -oac copy -ovc lavc

Write single frames if motion detected to ~/framedir/ , no X display:
mcamip -c -e 1000 -t -a IPADDRESS -p PORT -j -u USERNAME -w PASSWORD

You can list these in sequence with:
ls -rtl ~/frames/

And you can see the exact date to the second of a picture with for example:
ls -l --full-time mcamip.197.jpg

When storing as single frame .jpg files, a counter file 'jpeg_sequence_number' is written
to the directory where you stored the frames (~/frames or as in -d directory).
The jpg files will be numbered starting at this number, a check is always made for existing
numbers, and these are skipped.
You can set the start number by editing the file jpeg_sequence_number, or delete that file,
then the numbering will start at zero or the first free number.

The same, using a different directory for the jpg images:
mcamip -d /huge -c -e 1000 -t -a IPADDRESS -p PORT -j -u USERNAME -w PASSWORD

Display all .jpg images in sequence:
xv -wait 1 mcamip.*.jpg

Just watch the (any) camera:
mcamip -a IPADDRESS -p PORT -u USERNAME -w PASSWORD -x

Encode with ffmpeg version 0.4.8 (from 2004 02 22, some other versions seem to differ):
mcamip -x -f 2 -t -a 10.0.0.151 -p 80 -u USERNAME -w PASSWORD -y | \
ffmpeg -f yuv4mpegpipe -i - -f avi -vcodec mpeg4 -b 800 -g 300 -bf 2 -y camera4.avi

If you have a recent ffmpeg that supports H264,
this is what I use:
Encode H264 in the background at 2 fps, with very low bit rate of 10 kbits / second, and low cpu usage,
uses hardly any disk space (set bitrate with the '-b 10'):
nice -n 19 mcamip -x -f 2 -t -a 10.0.0.151 -p 80 -u USERNAME -w PASSWORD -y 2>mcamip-log | \
nice -n 19 ffmpeg -f yuv4mpegpipe -i - -f avi -vcodec h264 -r 2 -b 10 -g 300 -bf 2 -y camera4.avi \
1>/dev/zero 2>/dev/zero &
Play for example (some players may not be able to play H264) with:
ffplay camera4.avi

Encode with transcode (v0.6.11, later version may have different options) to DivX4,
in transcode you must specify the size, and the -z flag reverses the upside down picture.
It uses the old DivX 4 codec, you can find it here: divx4linux-20011010_4.02.tgz
and the old transcode: transcode-0.6.11.tar.gz

mcamip -x -f 2 -t -a 10.0.0.151 -p 80 -u USERNAME -w PASSWORD -y | \
transcode -f 2 -i /dev/fd/0 -g 320x240 -x yuv4mpeg,null -y divx4 -z -o camera4.avi

If you want nice subtitles, moving title rolls, effects, or pictures mixed,
try piping the output via subtitler-yuv-0.6.5.tgz like this:
mcamip -q -y | subtitler-yuv -c 32 -p demo-yuv.ppml | mplayer -
(demo-yuv.ppml and the font is in the subtitler-yuv tgz distribution)

Using mcamip with video for Linux, and perhaps Flash:
Here is a small utility that works with the vloopback device, and allows watching with for example xawtv:
click here to download mjpegtools_yuv_to_v4l-0.2.tgz
click here for the lsm info file.
You can find vloopback in flashcam-1.1.tgz from www.swift-tools.net/Flashcam/
This is how I use it:
modprobe vloopback
Now do dmesg to see what is input and output, you could already have other webcams, here its says:
vloopback: Video4linux loopback driver v1.1.2
vloopback: Loopback 0 registered, input: video2, output: video1
mcamip -a IPADDRESS -p PORT -u USERNAME -w PASSWORD -y | mjpegtools_yuv_to_v4l /dev/video2
Test with:
xawtv -c /dev/video1 -geometry 640x480
If you want to use flash, and flash does not recognize the vloopback device, try this,
_BUT_ it may hang your system, you may no longer be able to remove the module, as it will always report busy, so use at you own risk,
as far as I have been able to find out, one needs to select 'none' in Flash _before_ stopping mcamip, to prevent the module from hanging.
rmmod vloopback
modprobe vloopback inminor=9
This will hopefully cause Flash to scan and find the loopback device, select it.
mcamip -a IPADDRESS -p PORT -u USERNAME -w PASSWORD -y | mjpegtools_yuv_to_v4l /dev/video9
To undo zooming effect in Flash, perhaps pipe via y4mscaler:
mcamip -a IPADDRESS -p PORT -u USERNAME -w PASSWORD -y | y4mscaler -Isar=1:1 -Iilace=NONE -Osize=160x120 | mjpegtools_yuv_to_v4l /dev/video9
This experimental script plays some format movies via flashplayer, YMMV, I call it 'movie-to-flash':
if [ "$1" = "" ]
then
echo "Usage: movie-to-flash movie.xxx"
exit 1
fi
echo "To stop: stop flashplayer first, then use ctrl C, and do rmmod vloopback when done."
rmmod vloopback
sleep 1
modprobe vloopback inminor=9
sleep 1
nice -n 19 ffmpeg -i $1 -f yuv4mpegpipe - | y4mscaler -Isar=1:1 -Iilace=NONE -Osize=160x120 2>/dev/zero | mjpegtools_yuv_to_v4l /dev/video9
exit 0

Some observations:

The firmware I have uses 'server push', you connect to /video.cgi, and then a stream of jpeg pictures is send.
This can be tested like this:
wget CAMERA_IP_ADDRESS:PORT/video.cgi --http-user=USERNAME --http-passwd=PASSWORD --referer=http://CAMERA_IP_ADDRESS:PORT/Jview.htm
The referer field is needed, else the camera will stop sending data after a few minutes.
Unlike the manual suggests, you only need to set the http port open, so ONE port, for each camera.
This is because the server push video.cgi will send to the same port.
Security:
The security of this webcam is broken, it is possible to record from it without username and password.


Hardware

Inside the DCS-900 camera:

The camera opens by removing the 2 crosshead screws deep inside holes at the top back.
Make sure you completely remove those screws, else plastic will break,
then flip the top backwards.
Loosen the board assembly by removing the 2 small screws at the bottom.
There are 3 PCB boards.
Take the boards apart, these are connected with little headers.
Now we have 3 boards:
1) sensor board
2) processor board
3) Ethernet interface board.


In more detail:

sensor board has:
12 MHz xtal
A SGS STV0676 video procressor, it can do RGB, YCrCb, and MJPEG output.
A TTL type 245 buffer (8 bits bidirectional)
A sensor (I did not open up the optical assembly, but very likely a SGS VGA 640x480 CMOS sensor).

processor board has:
25 MHz xtal
RDC R1610 16 bits RISC processor, 80C186 software compatible, with non multiplexed address out.
Some FLASH(?) memory (chip with label hiding type number).
Some RAM? Possibly D-Ram, perhaps static? unknown type number.

ethernet board has:
VIA VT6103 Ethernet controller PHY.


return to homepage