wiki:

Capture

/

Webcam


Version 16 (modified by rogerdpack, 5 years ago) (diff)

even more dire warning for vfwcap

Windows

dshow

For windows you should probably use the "dshow" (DirectShow) FFmpeg input source. See DirectShow.

vfwcap

Windows users that can't use DirectShow can possibly use the (now out dated) vfwcap input device, like this:

To list the supported capture devices, connected to the machine (remember--this method [vfwcap] is outdated!):

ffmpeg -y -f vfwcap -i list

That will give us the list like this:

...
libavutil     50.36. 0 / 50.36. 0
libavcore      0.16. 1 /  0.16. 1
libavcodec    52.108. 0 / 52.108. 0
libavformat   52.93. 0 / 52.93. 0
libavdevice   52. 2. 3 / 52. 2. 3
libavfilter    1.74. 0 /  1.74. 0
libswscale     0.12. 0 /  0.12. 0
[vfwcap @ 01c6d150] Driver 0
[vfwcap @ 01c6d150]  Microsoft WDM Image Capture (Win32)
[vfwcap @ 01c6d150]  Version:  5.1.2600.5512
list: Input/output error

So, we can try to grab something from our camera:

ffmpeg -y -f vfwcap -r 25 -i 0 out.mp4

Where "-i 0" is the index (zero based) in the list of present capture devices ("Driver 0" in this instance).

Linux

On Linux, we can use video4linux2 (or shortly "v4l2") input device to capture live input (such as web camera), like this:

ffmpeg -f video4linux2 -r 25 -s 640x480 -i /dev/video0 out.avi

or

ffmpeg -f v4l2 -r 25 -s 640x480 -i /dev/video0 out.avi

If you need to set some specific parameters of your camera, you can do that using v4l2-ctl tool.

You can find it in the fedora/ubuntu/debian package named v4l-utils.

Most probably you'll want to know what frame sizes / frame rates your camera supports and you can do that using: v4l2-ctl --list-formats-ext

Also, you might want to correct brightness, zoom, focus, etc. with:

v4l2-ctl -L

and

v4l2-ctl -c <option>=<value>

Mac

Mac users can use the "qtkit" and "avfoundation" input devices for grabbing integrated iSight cameras as well as cameras connected via USB or FireWire. QTKit is available on Mac OS X 10.4 (Tiger) and later. QTKit has been marked depricated since OS X 10.7 (Lion) and may not be available anymore on future releases of OS X. AVFoundation is available on Mac OS X 10.7 (Lion) and later. Since then, Apple recommends AVFoundation for stream grabbing on OS X and iOS devices.

QTKit

To list the supported capture devices, connected to the machine:

ffmpeg -f qtkit -list_devices true -i ""

To use the default device which is usually the first device in the listing the user can either use an empty name string or "default":

ffmpeg -f qtkit -i "" out.mpg

or

ffmpeg -f qtkit -i "default" out.mpg

To use one of these devices for capturing the user has to specifiy either the name of the device or the index shown in the device listing. Abbreviations using just the beginning of the device name are possible. Thus, to capture form a device named "Integrated iSight-camera":

ffmpeg -f qtkit -i "Integrated" out.mpg

To use the device's index provide the index either as the input or use the -video_device_index option that will override any given input name:

So

ffmpeg -f qtkit -i "2" out.mpg

and

ffmpeg -f qtkit -video_device_index 2 -i "default" out.mpg

will use the device with the index 2 ignoring the default device in the second case.

AVFoundation

To list the supported capture devices, connected to the machine:

ffmpeg -f avfoundation -list_devices true -i ""

To use the default device which is usually the first device in the listing the user can either use an empty name string or "default":

ffmpeg -f avfoundation -i "" out.mpg

or

ffmpeg -f avfoundation -i "default" out.mpg

To use one of these devices for capturing the user has to specifiy either the name of the device or the index shown in the device listing. Abbreviations using just the beginning of the device name are possible. Thus, to capture form a device named "Integrated iSight-camera":

ffmpeg -f avfoundation -i "Integrated" out.mpg

To use the device's index provide the index either as the input or use the -video_device_index option that will override any given input name:

So

ffmpeg -f avfoundation -i "2" out.mpg

and

ffmpeg -f avfoundation -video_device_index 2 -i "default" out.mpg

will use the device with the index 2 ignoring the default device in the second case.