0

I'd like to take a picture with my webcam on the command line with VLC.

The camera is a Microsoft XBox Live Vision camera that I picked up on a whim (it was $5) and it miraculously worked out-of-the-box on Linux.

The thing is, the first frame every time the camera turns on is half purple static. The next few frames are poorly lit as the camera calibrates to its lighting (yes, the webcam itself calibrates the brightness, entirely independently of the computer.)

What I want is to open the webcam, stream for 1 second (or even a set number of frames would be fine), then save the last frame as a JPEG. It's not necessary to open a window.

What would it take to do this?

7
  • Is usage of VLC a strict requirement? – llogan Jan 3 '14 at 1:43
  • @LordNeckbeard Comparatively strict, but I suppose a solution involving FFMpeg would be tolerable. – JamesTheAwesomeDude Jan 3 '14 at 17:46
  • Does the following do what you want? ffmpeg -f v4l2 -i /dev/video0 -ss 1 -vframes 1 -qscale:v 2 output.jpg? Of course change /dev/video0 to the actual name of your device. You may be able to adjust brightness or maybe even disable auto exposure with v4l2-ctl. – llogan Jan 3 '14 at 21:03
  • @LordNeckbeard Doesn't work. Where VLC can access the webcam without any problems as a normal user (I'm in the video group,) that ffmpeg command doesn't create an output file. I even tried running it as root and got the same result. pastebin.com/XjCGDfTz (As for the lighting, it's automatically calculated on the camera itself. The OS doesn't have a thing to do with it. Any meddling done by the OS would just mess up the image in the end, as it couldn't inform the camera that the image was being corrected on the OS end.) – JamesTheAwesomeDude Jan 4 '14 at 17:22
  • Does a recent build of ffmpeg also behave similarly? – llogan Jan 6 '14 at 19:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.