5

I'm trying to take a picture from the terminal using ffmpeg with command:

ffmpeg -f video4linux2 -s 4208x3120 -i /dev/video1 -qscale:v 2 -frames 1 -ss 00:00:20 out.png

However it seems to ignore the -ss option. My idea is to wait for certain amount of time to let the camera autofocus. That option is simply ignored, no matter what the value is and the picture is saved immediately, resulting often out of focus. Autofocus is present in the camera (See3cam 130), if I use cheese it goes on focus almost immediately. Any hints?

EDIT

Putting -ss parameter before -i doens't help. Also tried with a different camera, with the same behavior.

rok
  • 945
  • Try putting your - ss... before your - i... – doug Nov 11 '19 at 14:16
  • not working, ss parameter before input is to seek the input, won't work for live streaming device.. it throws this error: "/dev/video0: could not seek to position 35102.077" – rok Nov 11 '19 at 17:53

1 Answers1

3

I suspect that what you are after is a --delay 5 type option for FFmpeg which at the moment does not exist except as a feature request. However there is an older utility called fswebcam which I have tested comprehensively on my system that will accomplish exactly what you are after. Install with:

sudo apt-get install fswebcam

and run a simple command line something like the following:

fswebcam --delay 5 --skip 200 --png 5 testing.png

A more elaborate command line plus full terminal output can be seen below as it runs on my own system:

andrew@ilium~$ fswebcam --device /dev/video0 \
>          --input "Camera 1" \
>          --resolution 800x600 --delay 5 \
>          --skip 200 --png 5 \
>           testing.png
--- Opening /dev/video0...
Trying source module v4l2...
/dev/video0 opened.
Delaying 5 seconds.
--- Capturing frame...
Skipping 200 frames...
Capturing 1 frames...
Captured 201 frames in 6.64 seconds. (30 fps)
--- Processing captured image...
Setting output format to PNG, quality 5
Writing PNG image to 'testing.png'.
andrew@ilium~$ 

The option --delay 5 gives the webcam a chance to initialize while the option --skip 200 delays the screen capture after the stream is open for about 6 seconds. You will need to experiment a little with this to allow for your specific camera's autofocus time.

How cool is the Linux command line :)

andrew.46
  • 39,479
  • This is nice, but seems to me that just add a delay to the shot without actuall opening the stream.. so won't solve the focus problem. Isn't it? I'm running other tests and today ffmpeg with -ss (which according to the documentation is set after the input source and before the output serve the purpose to open stream and discard the output unitl the time is reached.. so exactly what I need) seems to work! Very weird.. unfortunately I have no more the camera I was using yesterday and cannot test with it, but I suspect it was something related to that camera or my usb port.. I don't know! – rok Nov 12 '19 at 11:52
  • 1
    @rok OIC. I have modified my answer to include the --skip xx option which is a workaround for what you are after. The example I have given allows for a 5-6 second delay which may be what you are after. Mind you testing will be difficult if you don't have the camera any more :) – andrew.46 Nov 12 '19 at 21:12