Other online diaries:
Martijn van Oosterhout,
Linux Weekly News,
Planet Linux Australia,
Archive by month:
Tue, 08 Jul 2008
How to capture one image from a v4l2 device - 17:22
So after seeing Mikal wondering about it again yesterday, I had a look at some
source code, decided that it could be done but it would be nicer to do it with
existing software. I recalled seeing ffmpeg or mplayer commands that may in
theory be able to do a capture of a single image. Then I stumbled upon a way
to do this with gstreamer filters and sinks.
"gst-launch-0.10 v4l2src ! video/x-raw-yuv,width=640,height=480 ! ffmpegcolorspace ! pngenc ! filesink location=foo.png"
As one command captures the image at that resolution into a file foo.png. This
is on my laptop, however I tested this with the QuickCam 9000 on my desktop
with a resolution of 1600x1200 and it worked, the focus meant it took a while
but it popped out a good image. Gstreamer really is cool, I still remember
seeing Federico talk about GMF (Gnome Media Framework, which is what became
GStreamer) at CALU in 1999 and being excited by it.