Install a webcam in Slacko 5.3

How to do things, solutions, recipes, tutorials
Message
Author
User avatar
MochiMoppel
Posts: 2084
Joined: Wed 26 Jan 2011, 09:06
Location: Japan

#21 Post by MochiMoppel »

Maybe this already helps:
Aunt Google wrote:ffmpeg -f video4linux2 -s 640x480 -i /dev/video0 -ss 0:0:2 -frames 1 /tmp/out.jpg

The -ss parameter is used to allow the device to start up correctly. Here in my tests, there is a fade-in effect while the camera is being turned on, so, if I just omit -ss 2, the captured frame will be very dark.
At least it helped me. When taking consecutive shots at 1 frame/sec the first 2 pictures turn out too dark. I noticed that ffmpeg takes 3 pictures rapidly before adjusting to the 1 per second rate, which may explain the dark (under exposed) shots.

I also discovered that I can take less than 1 picture per second.
This will take 30 consecutive pictures, one every 2 seconds. Names start with shot-0001.jpg:

Code: Select all

ffmpeg -f video4linux2 -s 640x480 -i /dev/video0 -ss 2 -vf fps=0.5 -vframes 30 /tmp/shot-%04d.jpg

User avatar
greengeek
Posts: 5789
Joined: Tue 20 Jul 2010, 09:34
Location: Republic of Novo Zelande

#22 Post by greengeek »

Awesome. That is great.
cheers!

Code: Select all

#!/bin/bash 
#Test script to take PC webcam images using MochiMoppel code from
#http://www.murga-linux.com/puppy/viewtopic.php?p=960402#960402
#Substitute the name of your preferred webcam (you may have more than one)
#Find your webcam name by opening a terminal and typing the following:
#lsusb
#Note: multiple uses of the script will overwrite previous images.
CAMERA=Chicony
VIDEOx=$(grep -rH "$CAMERA" /sys/class/video4linux/*/name | cut -d/ -f5) 
ffmpeg -f video4linux2 -s 640x480 -i /dev/$VIDEOx -ss 2 -vf fps=0.5 -vframes 5 /tmp/shot-%04d.jpg
The only problem is it appears to generate images of a rather dishevelled looking individual sitting in my living room hunched over a keyboard. Ugly.

Post Reply