Skip to content

Instantly share code, notes, and snippets.

@rye
Created February 12, 2015 02:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rye/8b2249fd6828dd271dd0 to your computer and use it in GitHub Desktop.
Save rye/8b2249fd6828dd271dd0 to your computer and use it in GitHub Desktop.
An example command to grab images from a webcam.

Example Command

This is the example command that will take pictures periodically:

$ ffmpeg -f v4l2 -i {{device, e.g. /dev/video1}} -ss 0:0:2 -s 120x90 -vsync 2 -r 4 -updatefirst 1 stream.png
  • -f v4l2 uses the standard linux /dev/video decoder thing.

  • -i {{device}} uses the given {{device}} as the input device.

  • -ss 0:0:2 streams the webcam for 2 seconds prior to starting the stream. This will enable the webcam to warm up; in the case of the RZ406AA, there is a 2-second warmup period in which the R and B channels must be slowly brought up for some stpid reason.

  • -s 120x90 sets the output size. This can be changed according to the whims of the programmers.

  • -vsync 2 synchronizes the output buffer (removes some bulky watchdogs) and drastically decreases CPU utilization.

  • -r 4 specifies the rate at which the output is updated.

  • -updatefirst 1 and stream.png are used for a singular-file streaming setup. FFMpeg will update the file as it reads new image data from the webcam. Alternatively, one can use stream%5d.png to write out to enumerated files, and then can programmatically determine the latest file, but this consumes more space and is silly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment