Further notes on the NSLU2 and QuickCam Pro 9000

I have been playing around with the webcam firmware that was the subject of my last post and have a number of random notes that I should put up here on using it.

Power-on and Power off
The NSLU2 running OpenWRT has some odd characteristics. First, it will not automatically turn on when power is applied, and you can’t make it do so without modifying the hardware (see here for a lengthy discussion of how to do so). You have to press the power-on button to get it to start up. Thats true of the NSLU2 generally and not OpenWRTs fault. Second, under OpenWRT, pressing the power button again won’t turn it off. Thats something that isn’t implemented, yet, in OpenWRT. Pressing the reset button will turn it off, but thats kind of awkward. Logging in (see below) and issuing the “poweroff” command will do so too.
I’m looking into ways of reducing the boot time from the present 55 seconds from power-on to first image, but I don’t expect to get it down to less than 30 seconds.

In my first post I skated lightly over the question of why the QuickCam is running at 960×720 if its supposed to be capable of doing 1600×1200. The answer turns out to be a bit complicated. The QuickCam can generate images in two formats, an uncompressed one known as YUY2, and a compressed form, M-JPEG. Compressing the images is quite hard work for the camera, and at the maximum resolution it simply can’t do it, either because it takes too long or it doesn’t have enough onboard RAM. And the difference in size between the compressed and uncompressed images is pretty huge, as you can see in the following table. These are all the available image formats >= 640×480 for the Pro 9000:

Resolution Format Frames/second Kbytes/frame Kbytes/second
1600×1200 YUY2 5 3840 19,200
960×720 YUY2 10 1382 13,820
800×600 YUY2 25 480 12,000
640×480 YUY2 30 614 18,432
960×720 MJPEG 15 ~85 1275
800×600 MJPEG 30 ~85 2550
640×480 MJPEG 30 ~85 2550

The problem with the YUY2 format is that its simply huge and generates 12-20 Mbytes/second. We can’t move this over 100Mbit Ethernet, which will do 10-12 MBytes/second, tops. Even if we did, browsers don’t understand it. It is possible to ask MJPG-streamer to read YUY2 and do the compression to MJPEG itself, but its hard work for the NSLU2 as well. At 1600×1200 it generates one image about every five seconds and seems to buffer about six images, so what you see is thirty seconds in the past. It also falls over with segmentation faults fairly frequently (less frequently with lower quality images). So full resolution is pretty much limited to snapshots (another subject I want to get into). The 960×720 JPEGs direct from the camera are pretty heavily compressed and the quality of the picture does suffer a bit. Less severe compression doesn’t seem to be available from the camera, but I’m hoping I can find a way of getting it.

The Pro 9000 has a variable focus control. This is unusual on webcams, and allows it to focus on objects as little as 4-5 cm away. The MJPG-streamer software has an option that automates focusing, but having experimented with it I have not activated it in the firmware build. The reason for this is that the default focus seems to manage perfectly well between about 30cm and infinity, and the auto-focus is a bit painful to watch. It operates by checking the sharpness of the picture every ten seconds or so. If the sharpness deteriorates, it triggers a procedure that runs through the whole range of focus settings, and then picks the sharpest one. This works, but it can take at least ten seconds, and is easily fooled by movement. Unless you need this facility, its probably best left turned off.

Note that the manual focus controls in MJPG-streamer work just fine and let you focus down to a few centimeters.

Modifying the camera

If you want to know how to take the Pro 9000 apart, mount it in a box, and do things like attach a large lens to it you can photograph, say, craters on the moon, look no further than here

Low-level firmware access
If you have some Linux experience and want to get in and add packages or change settings, you can telnet into the firmware and edit the configuration files with vi. The firmware will advise you to set a secure root password, and thereafter you will need to log in using ssh and that password (this is, incidentally, essential if you are going to make the camera visible to the Internet at all). To switch to a static IP at, for example, you would edit /etc/config/network and change the line

	option proto dhcp


	option proto    static

        option ipaddr

        option netmask

The startup commands that run MJPG-streamer are in /etc/init.d/done. MJPG-streamer takes the following parameters:

-i | –input “< input-plugin.so > [parameters]”
-o | –output “< output-plugin.so > [parameters]”
[-h | –help ]……..: display this help
[-v | –version ]…..: display version information
[-b | –background]…: fork to the background, daemon mode

The UVC input plugin, input_uvc.so, takes these parameters:

[-d | –device ]…….: video device to open (your camera)
[-r | –resolution ]…: the resolution of the video device, can be one of the following strings:
or a custom value like 640×480
[-f | –fps ]……….: frames per second
[-y | –yuv ]……….: enable YUYV format and disable MJPEG mode
[-q | –quality ]……: JPEG compression quality in percent (activates YUYV format, disables MJPEG)
[-m | –minimum_size ].: drop frames smaller then this limit, useful if the webcam produces small-sized garbage frames which may happen under low light conditions
[-n | –no_dynctrl ]…: do not initialise dynctrls of Linux-UVC driver

The output HTTP plugin, output_http.so, takes these parameters:

[-w | –www ]………..: folder that contains webpages in a flat hierarchy (no subfolders)
[-p | –port ]……….: TCP port for this HTTP server
[-c | –credentials ]…: ask for “username:password” on connect
[-n | –nocommands ]….: disable execution of commands

The file output plugin, output_file.so, takes:

[-f | –folder ]……..: folder to save pictures
[-d | –delay ]………: delay after saving pictures in ms
[-b | –bytes ]………: save only on change in picture-size
[-c | –command ]…….: execute command after saving picture

And the autofocus output plugin, output_autofocus.so takes just

[-d | –delay ]………: delay after saving pictures in ms


, ,

  1. #1 by Lance Benson on April 1, 2008 - 2:25 pm


    I see from your post that different “output-plugins” may be attached to mjpg-streamer. In addition to the “output-http.so” which you use I see only “output-file.so” and “output-autofocus.so”. Begging your pardon, but I know nothing about this. Your blog and other sources talk about feeding to other programs with the plugins–can you point me to any discussion about what plugins are available. Can it be a UPnP server? I would like for it to feed my D-Link DSM-320 media server, either directly or through twonkyvision which I have running through a different slug which runs Unslung 6.8. If there is a more appropriate place to discuss these matters, please direct me there. Thanks.

  2. #2 by johnarthur on April 1, 2008 - 7:26 pm

    Those plugins are part of the mjpg-streamer package and there are no others apart from a file-input one used for testing. I would guess that the way to feed other programs with images would be via the output-file.so plugin and the useful ‘-c command’ option, but as I haven’t experimented with this I know no more than that.

  3. #3 by Tom on April 5, 2008 - 8:13 am

    Can you run 2 cameras at once with this off one NSLU2?

  4. #4 by johnarthur on April 5, 2008 - 8:19 am

    I’m looking into that. It requires a simple hardware mod (adding one jumper) and some software changes. But in principle I can’t see why not. I need to get hold of two cameras to try it out.

  5. #5 by Lance Benson on April 7, 2008 - 10:12 am


    Is the hardware mod required the one to add power to the NSLU2’s USB port 1? As in:

    Would the software changes be in the source, or is it a matter of settings? This would be very useful.

    At the mjpg-streamer site it is recommended that for opening the stream to the internet, one use the program “motion”. Have you tried anything like that?

  6. #6 by johnarthur on April 7, 2008 - 12:45 pm

    Yes, two cameras would need the mod for two powered ports. Once that was working I would simply try running two invocations of mjpg-streamer on two different ports (e.g port 80 and port 8080). Its not very elegant, but as far as I can tell it should work.

    I haven’t tried motion on the NSLU2, but I suspect you would have to cut the resolution and the frame rate down a lot to get it to work, even at 266MHz.

  7. #7 by Darren on July 24, 2008 - 1:12 pm

    I am so pleased that I stumbled across this site! 🙂

    I had two used NSLU2 units (from eBay), with the full intention of running one of the Linux distributions on it with ‘gphoto2’, just like Helmut Dersch described on one of his pages to drive a digital camera (http://webuser.fh-furtwangen.de/~dersch/gphoto/remote.html).

    However, as recently as today — with the newest version of gphoto2, I have still not coaxed my Nikon Coolpix digital cameras to work on that platform.

    At the same time, I have recently switched my mother’s laptop from WinXP to Fedora Linux, and the nice Logitech ‘Fusion’ webcam (uvc based) refuses to work for ‘everyday’ uses like Skype, so I gave her one of my ‘pwc based’ cameras instead.

    Fast forward to now: a use for my NSLU2 devices, and I find that my ‘flakey’ fusion webcam seems to work just fine with your project!

    My only confusion was that I had to reboot the device before the ‘MJPG-streamer’ page would show up.

    Also, in the previous column Lance mentioned installing ‘webif’ ,which I also did (it appears that the instructions were here: http://www.nslu2-linux.org/wiki/OpenWrt/BuildInstructions). However, I am not sure how to use it — the ‘main’ webpages are in the ‘/webcam_www’ directory, whereas the webif stuff is in ‘/www’. I thought that I would be able to use logical links to lump them together, but I cannot make it work.

  8. #8 by Boris on April 25, 2009 - 1:55 am

    I am really excited about this and would love to try this but I have a couple of questions that I didn’t see answers to.

    Forgive my ignorance on the issues involved, I didnt not read everything I could on this.

    Does it or is it possible to get the sound on the video stream. QuickCam Pro 9000 seems to have a mic. Is it part of the video?

    Another question is, from what I read most of people opening video in the browser, but what if I want to save the files on the network location. I am assuming this should be pretty easy.

    Finally, do I have to have linux on the host computer as you say or can I get by with cygwin ?

    Thank you for your awesome efforts ! This is great.

    • #9 by johnarthur on April 25, 2009 - 2:24 pm

      The video stream from the NSLU2 is just video; the OpenWRT UVC driver doesn’t know how to get at the audio that the camera can generate. I’m afraid I can’t help with saving the video stream or using Cygwin as I haven’t tried to do either and I just don’t know whats involved. Both sound perfectly feasible to me…

  1. A Megapixel Time-lapse Camera System « The Machine in Shaft Ten
  2. Bookmarks about Nslu2
  3. Web-kamera tukiasemaan | Open-wrt mesh kokeilun Blogi

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: