[FFmpeg-user] Take webcam picture with minimal delay

mail at stefan-kleeschulte.de mail at stefan-kleeschulte.de
Wed Sep 20 15:11:33 EEST 2017


Hi everyone!

I want to take a picture from a webcam (to send it in a http server's 
response). I already found a command to take a picture and write it to 
stdout (from where I can grab it in the http server):

ffmpeg -f video4linux2 -video_size 1920x1080 -input_format yuyv422 -i 
/dev/video0 -f image2 -frames:v 1 -qscale:v 1 pipe:1

The only drawback is that it takes about 3 seconds to get the picture. 
The delay comes from ffmpeg (not from the server/network), probably 
because it needs to wait for the webcam to initialize.

Now my idea is to somehow keep the webcam active and grab the current 
video frame whenever a http request comes in. But I do not know how to 
do this with ffmpeg (on linux). Can I use one instance of ffmpeg to 
capture the webcam video and stream it *somewhere*, and then use a 
second instance of ffmpeg to extract the current frame of that stream? 
Or is there a better way to do it?

Thanks!
Stefan Kleeschulte


More information about the ffmpeg-user mailing list