# good program for capturing webcam images 1/sec? [SOLVED]

## gnychis

Hey guys,

I've looked all around for a good program for capturing webcam images and my head is starting to hurt.  It just needs to be command line, and it needs to be able to take 1 image a second.

I found the linux.com wiki about webcams but its so old... I can't even find "streamer" and "camE" insists on ftp or scp'ing... i can't get it to just copy.  Not to mention I can't find a way to speed it up, only seems to take 1 image every 10 seconds.

Then I tried "camsource", which works great, however no matter what brightness values i set, it seems to do whatever it wants, and it always ends up being too dark.  I tried changing brightness, contrast, color... autobrightness, no matter what i do i cannot get the image how i like it, and i've toyed with it for hours.

Does anyone have any suggestions?  I'd greatly appreciate it.

Thanks!

George

----------

## chrismortimore

Mplayer can do it through V4L

----------

## quag7

I use mplayer to do this with my 3Com Homeconnect webcam.  From my notes:

View your cam to test:

```

mplayer -tv driver=v4l:device=/dev/video1:width=320:height=240:outfmt=rgb24 -vf-add screenshot,flip tv://

```

That should get you started.

I think this is kind of what you want - I use it to do timelapses.  This will capture a series of images from the webcam and save them into a directory.  

```

#!/bin/sh

cd /work/timelapse

mplayer -quiet -tv driver=v4l:device=/dev/video1:width=320:height=240:outfmt=rgb24 -frames 1 -vf-add screenshot,flip tv:// -vo jpeg

```

You may have to play with some settings in there - your device will probably be /dev/video0 rather than /dev/video1 (Mine is 1 because my TV card is 0).   The -frames says how many frames to capture until exiting - if you omit this, it will keep capturing and saving pictures as 00000001.jpg, 00000002.jpg and so on until you hit Q.

You could play with this.  This is a little scribble in my Linux notebook on how to to save a movie captured from the webcam, though it saves frames back to back as fast as they can be captured, so it isn't realtime:

```

mencoder -tv driver=v4l:device=/dev/video1:width=320:height=240:outfmt=rgb24:buffersize=256:fps=15 tv:// -ovc lavc -nosound -noskip -flip -o testvid.avi

```

The -vo switch can be added to this to add some cool effects (like the aalib output, which I like) - not all of these work for me:

Add -vo switch, then:

(example: -vo aa)

Available video output drivers:

xv      X11/Xv

x11     X11 ( XImage/Shm )

gl      X11 (OpenGL)

gl2     X11 (OpenGL) - multiple textures version

dga     DGA ( Direct Graphic Access V2.0 )

ggi     General Graphics Interface (GGI) output

fbdev   Framebuffer Device

svga    SVGAlib

aa      AAlib

dxr3    DXR3/H+ video out

png     PNG file

jpeg    JPEG file

gif89a  animated GIF output

null    Null video output

pgm     PGM file

md5     MD5 sum

mpegpes Mpeg-PES to DVB card

yuv4mpeg        yuv4mpeg output for mjpegtools (to "stream.yuv")

vesa    VESA VBE 2.0 video output

xvidix  X11 (VIDIX)

[/code]

Lastly, this may of use to you - this will take a directory full of images and make them into a 25fps video:

```

#!/bin/sh

mencoder "mf://*.jpg" -mf fps=25 -of mpeg -ovc lavc -lavcopts vcodec=mpeg2video -o output.mpg

```

Hope this helps.  I used to use camsource myself, but now I just try to use mplayer and mencoder for everything I do.

----------

## gnychis

okay so i've found a gentoo wiki on webcams that shows some mplayer commands:

```

mplayer tv:// -tv driver=v4l:width=352:height=288:device=/dev/video0

```

however i don't have X installed on that comp to view anything...

so how do i get it to dump images to a file?

Thanks!

George

----------

## chrismortimore

Read up about mencoder on gentoo-wiki.org, and use "tv:// -tv driver=v4l:width=352:height=288:device=/dev/video0" as the input.

----------

## gnychis

ok so I'm not sure if its with the drivers I am using for the webcam, but the first image always comes out completely white, then it slowly starts to get darker and darker until in my opinion, the image is visible, but is too dark... for instance, here is my webcam right now:

http://thulium-ini.ini.cmu.edu/

See how dark it is?  It will start completely white when the camera is first turned on.

So if i do something like this:

```

mplayer -quiet -tv driver=v4l:device=/dev/video0:width=320:height=240:outfmt=rgb24 -frames 1 -vf-add screenshot,flip tv:// -vo jpeg

```

where it only dumps 1 frame... then it will always be white.

Its almost like the driver is doing its own brightness adjustment, which keeps me from controlling it at all.  Is this possible? Because no matter what I touch in "camsource" settings, which is what is taking my images right now for the webcam website, the settings do not seem to effect the brightness of the picture.  It makes it look like the room I am in is in a dungeon, when in fact I have sunlight blasting in my face

The drivers I am using are in portage as spca5xx

I don't get it....

- George

----------

## gnychis

ok it seems like no matter what i try to tell the driver, it always sets itself in autobrightness mode:

```

mplayer -quiet -tv driver=v4l:device=/dev/video0:width=320:height=240:outfmt=rgb24:brightness=-50 -frames 40 -vf-add screenshot,flip tv:// -vo jpeg

```

I set brightness=-50 and it still starts as completely white, then adjusts the brightness to the normal dark level... maybe this is a driver issue, am i missing something here?

----------

## quag7

What brand and model of camera is it?  I see you on the webcam there, it is a little dark.  Somehow there has got to be a way of turning off auto brightness control, and it's probably not through mplayer.

----------

## gnychis

its a knock off webcam shaped like a penguin (yey linux), from ebay

i assumed that when i specify a brightness level in mplayer, it passes the parameter to v4l and v4l access to camera to set the brightness level

I know its not the camera, because using the camera in windows with the drivers it came with i was able to set it manually

----------

## yabbadabbadont

It is both a little dark, and yellowish when I view it.  Maybe the two are related?

----------

## quag7

I'm not an expert on any of this, mind you, but I assume that mplayer brightness settings apply brightness adjustments to the final picture, so if you turn brightness up, it will simply brighten a picture taken at a fast shutter speed, which will wash it out.  What we seem to be talking about here, ultimately, is shutter speed - we want the shutter speed to be longer so that the picture exposes more.

It surprises me not at all that there is scant information about this online.  I'm going to google a little bit.

----------

## quag7

Ah, this is more what I was looking for.  I see that other people have your exact same problem - I noticed this bit from an Ubuntu bug site:

```

# modinfo spca5xx.ko

filename:       spca5xx.ko

author:         Michel Xhaard <mxhaard at users.sourceforge.net> based on spca50x

driver by Joel Crisp <cydergoth at users.sourceforge.net>,ov511 driver by Mark

McClelland <mwm at i.am>

description:    SPCA5XX USB Camera Driver

license:        GPL

vermagic:       2.6.12-8-386 386 gcc-3.4

depends:        usbcore,videodev

alias:          usb:v0733p0430d*dc*dsc*dp*ic*isc*ip*

[... many rows like last one ...]

srcversion:     6D9499E0C05382938ED6BD5

parm:           usbgrabber:Is a usb grabber 0x0733:0x0430 ? (default 1)  (int)

parm:           lum_level:Luminance level for brightness autoadjustment (default

32) (int)

parm:           min_bpp:The minimal color depth that may be set (default 0) (int)

parm:           ccd:If zero, default to the internal CCD, otherwise use the

external video input (int)

parm:           contrast:Initial contrast factor (0-255) not know by all webcams

!! (int)

parm:           bright:Initial brightness factor (0-255) not know by all webcams

!! (int)

parm:           GGreen:Gain Green setting range 0 to 512 /256  (int)

parm:           GBlue:Gain Blue setting range 0 to 512 /256  (int)

parm:           GRed:Gain Red setting range 0 to 512 /256  (int)

parm:           OffGreen:OffGreen setting range -128 to 128 (int)

parm:           OffBlue:OffBlue setting range -128 to 128 (int)

parm:           OffRed:OffRed setting range -128 to 128 (int)

parm:           gamma:gamma setting range 0 to 7 3-> gamma=1 (int)

parm:           force_rgb:Read RGB instead of BGR (int)

parm:           snapshot:Enable snapshot mode (int)

parm:           debug:Debug level: 0=none, 1=init/detection, 2=warning,

3=config/control, 4=function call, 5=max (int)

parm:           autoexpo:Enable/Disable hardware auto exposure / whiteness

(default: enabled) (PC-CAM 600 only !!) (int)

parm:           autoadjust:CCD dynamically changes exposure (spca501x only !! )

```

It looks like to set the brightness, you have to specify a parameter when you modprobe the kernel driver.  You can see several parameters there related to brightness/exposure such as autoadjust, autoexpo, bright, and lum_level.

This is logical, related to what I was talking about re: the brightness setting in mplayer not being what you want.  Have a go at rmmod'ing the driver, then modprobing it using some of those parameters and see if it makes a difference.

----------

## gnychis

ahhhh awesome, thank you very much... we're getting closer...

so, it has a way to set the "initial" brightness level, such as when you first turn on the cam, what the brightness level is, whenever i used to start it, it would be so bright it would be completely white, so now i set it to bright=60 and it starts at a nice level

and i finally got the autoadjust to turn off!

autoexpo=0  :Smile: 

thanks!!

----------

## quag7

Wow, glad it worked, and glad I could help.

----------

