Topic: Recording a USB webcam

I have a USB Microdia webcam hooked up to my Chumby, and it seems to work fine.  I would like to record its output to a file in real-time.  Is there any command-line program that could run on the Chumby which is able to record the output of the webcam (it's video4linux) to a file in real-time?  Quality-wise, I would like at least 320*240, 10fps.  Better quality would be great.  Anything is better than nothing.  I'm on Windows, so I can't cross-compile, but two of my friends both unsuccessfully tried to compile ffmpeg for the Chumby.  It compiles, but segfaults when run.  If someone could find me a binary of ffmpeg that runs on the Chumby, I would be very grateful.  A different program would be great too; I'll take whatever works.  :-)

Sorry if the answer is buried somewhere in this forum; I searched and didn't find any specifics.


Re: Recording a USB webcam

This class of processor typically isn't powerful enough to do video compression on its own - so even if you were able to successfully cross-compile ffmpeg, it's possible it wouldn't be able to compress the video (and presumably audio) at the rate you desire.  Most of them have an extra DSP specifically designed to compress video.

In the case of the Freescale MX21 processor used in the Ironforge chumby, it has a DSP core that can compress to H.263 in real time.  However, the core is not documented, and numerous attempts by Chumby Industries to get sufficient information to create and distribute a properly licensed Linux driver have been unsuccessful.

The problem is that the DSP core was not designed by the chip's manufacturer (Freescale), but rather another company (Hantro) that has been acquired by another company (On2), and they consider the core to be highly proprietary.  At one time they provided a binary-only driver and libraries to communicate with the DSP, however, they were for a much older (2.4.x) version of the kernel and thus not useable in our firmware.

We did not choose this processor on the basis of its ability to encode video - that wasn't a goal of the design - and the MX21 had other attributes that made it the ideal processor for us to use.

My understanding is that Freescale uses a different, openly documented DSP core in their newer chipsets.

3 (edited by biolizard89 2009-04-06 09:20:02)

Re: Recording a USB webcam

Hi Duane, thanks for the reply.

Yeah, I figured the Chumby wouldn't be fast enough to do any kind of good compression.  I was hoping something like MJPEG (or just writing a JPEG image every 10th of a second) would be usable on the Chumby, since the processing requirements for it are pretty low.  I'm also fine with writing uncompressed video; this will only run for about 2 minutes, and I will probably be writing it to a large flash drive, so uncompressed video is probably usable for my purposes.

Are there any programs that could run on the Chumby which would be able to log either uncompressed video or something like MJPEG?  (Putting each frame in a separate file is perfectly fine.)


EDIT: Also, I'd be interested in any program that can display the webcam video on the Chumby screen.  I looked through the forum, and didn't find anything.  Thanks.

Re: Recording a USB webcam

If you can get the webcam to display an image on the screen, you can capture uncompressed RGB565LE framebuffer images by simply doing a:

cat /dev/fb somefile.rgb565

...and use some other program to munge them into whatever format you like.

There's already a program on the device called "imgtool" which can capture the frame buffer to a JPEG or PNG file.  Do "imgtool -h" for the options.

If you can get the webcam to place the video into *any* reasonable offscreen buffer, then modifying imgtool or creating another program to convert it to JPEG is pretty straightforward.

Re: Recording a USB webcam

Yes, I've seen imgtool, but I'm unsure of how to get the webcam image onto the screen to begin with.

A related question: if I use

cat /dev/video0 > /tmp/frame

How would I figure out the format that it outputs?  And if I can get the file back onto my PC, is there an easy way to convert that format back to a .jpg or a .png?


Re: Recording a USB webcam

You can often figure out the format of an image simply based on its size, if you know the dimensions.

If, for instance, you know the image is 320x240, then the total number of pixels would be 76800.  If the size of the file you get is 153600, then you know that it's two bytes/pixel and it's very likely RGB565 or RGB555, and you just need to figure out the byte ordering.  If it's 307200, then you know it's four bytes/pixel, and thus probably some 8 bits/component format such as ARGB8888.

Photoshop has the ability to open raw files like these, or you can write a simple application or script.  The source for imgtool can be found here.

If you *do* figure out the formal. you could probably write a pretty simple Perl script to copy images (converting the pixel format as required) from /dev/video0 to /dev/fb and use imgtool to capture it.