Using avconv
or ffmpeg
, you can capture a frame from your device as well. For example:
1 2 |
avconv -f video4linux2 -s 640x480 -i /dev/video0 -ss 0:0:2 -frames 1 /tmp/out.jpg |
or
1 2 |
ffmpeg -f video4linux2 -s 640x480 -i /dev/video0 -ss 0:0:2 -frames 1 /tmp/out.jpg |
This will open /dev/video0
as a video4linux2
compatible device, set up resolution to 640x480
, stream for 2 seconds (00:00:02
or simply 2
), then capture one
single frame, saving it to /tmp/out.jpg
.
Check if your device is /dev/video0
, as it can be different for you.
The available resolutions depend on your webcam. Mine goes up to 640×480 and I checked it with a tool called qv4l2
, which is used to configure a video4linux2 device.
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.