Changes between Version 16 and Version 17 of Capture/Webcam


Ignore:
Timestamp:
Jun 4, 2014, 2:45:13 AM (5 years ago)
Author:
llogan
Comment:

nits, cleanup, and formatting

Legend:

Unmodified
Added
Removed
Modified
  • Capture/Webcam

    v16 v17  
     1[[PageOutline(1-3, Contents)]]
    12
    2 == Windows ==
     3= Windows =
    34
    4 === dshow ===
     5== dshow ==
    56
    6 For windows you should probably use the "dshow" (DirectShow) FFmpeg input source.  See DirectShow.
     7Uses the `dshow` (!DirectShow) input device which is the preferred option for Windows users. See the wiki article about DirectShow and the [https://ffmpeg.org/ffmpeg-devices.html#dshow dshow input device documentation] for more information.
    78
    8 === vfwcap ===
     9== vfwcap ==
    910
    10 Windows users that can't use DirectShow can possibly use the (now out dated) '''[http://ffmpeg.org/ffmpeg-all.html#vfwcap vfwcap]''' input device, like this:
     11{{{
     12#!div style="border: 1pt dotted; margin: 1em; background-color: #fdd;"
    1113
    12 To list the supported capture devices, connected to the machine (remember--this method [vfwcap] is outdated!):
     14'''Warning:''' `vfwcap` is outdated. Use `dshow` instead if possible. See DirectShow for more information.
     15}}}
     16
     17Uses the outdated `vfwcap` input device. See the [https://ffmpeg.org/ffmpeg-all.html#vfwcap vfwcap input device documentation] for more information.
     18
     19=== List devices ===
     20
     21To list the supported, connected capture devices:
    1322{{{
    1423ffmpeg -y -f vfwcap -i list
    1524}}}
    1625
    17 That will give us the list like this:
     26Example output:
    1827{{{
    19 ...
     28
    2029libavutil     50.36. 0 / 50.36. 0
    2130libavcore      0.16. 1 /  0.16. 1
     
    3140}}}
    3241
    33 So, we can try to grab something from our camera:
     42=== Encoding example ===
     43
     44Example to encode video from the camera:
    3445{{{
    3546ffmpeg -y -f vfwcap -r 25 -i 0 out.mp4
    3647}}}
    3748
    38 Where "'''-i 0'''" is the index (zero based) in the list of present capture devices ("'''Driver 0'''" in this instance).
     49`-i 0` is the index (zero based) in the list of present capture devices (`Driver 0` in this instance).
    3950
    40 == Linux ==
     51----
    4152
    42 On Linux, we can use '''[http://ffmpeg.org/ffmpeg-all.html#video4linux2_002c-v4l2 video4linux2]''' (or shortly "v4l2") input device to capture live input (such as web camera), like this:
     53= Linux =
     54
     55Uses the `video4linux2` (or simply `v4l2`) input device to capture live input such as from a webcam. See the [https://ffmpeg.org/ffmpeg-all.html#video4linux2_002c-v4l2 v4l2 input device documentation] for more information.
     56
     57=== List devices ===
     58
     59To list the supported, connected capture devices you can use the `v4l-ctl` tool. This example shows two connected webcams: `/dev/video0` and `/dev/video1`.
     60
    4361{{{
    44 ffmpeg -f video4linux2 -r 25 -s 640x480 -i /dev/video0 out.avi
    45 }}}
    46 or
    47 {{{
    48 ffmpeg -f v4l2 -r 25 -s 640x480 -i /dev/video0 out.avi
     62$ v4l2-ctl --list-devices
     63USB2.0 PC CAMERA (usb-0000:00:1d.7-1):
     64        /dev/video1
     65
     66UVC Camera (046d:0819) (usb-0000:00:1d.7-2):
     67        /dev/video0
    4968}}}
    5069
    51 If you need to set some specific parameters of your camera, you can do that using [http://ivtvdriver.org/index.php/V4l2-ctl v4l2-ctl tool].
     70=== List device capabilities ===
    5271
    53 You can find it in the fedora/ubuntu/debian package named '''v4l-utils'''.
     72To list available formats (supported pixel formats, video formats, and frame sizes) for a particular input device:
    5473
    55 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'''
     74{{{
     75$ ffmpeg -f v4l2 -list_formats all -i /dev/video0
     76
     77[video4linux2,v4l2 @ 0xf07d80] Raw       :   yuyv422 :     YUV 4:2:2 (YUYV) : 640x480 160x120 176x144 320x176 320x240 352x288 432x240 544x288 640x360
     78[video4linux2,v4l2 @ 0xf07d80] Compressed:     mjpeg :                MJPEG : 640x480 160x120 176x144 320x176 320x240 352x288 432x240 544x288 640x360
     79}}}
    5680
    57 Also, you might want to correct brightness, zoom, focus, etc. with:
     81Alternatively you could use `v4l2-ctl --list-formats-ext` to list available formats.
     82
     83=== Encoding example ===
     84
     85Example to encode video from `/dev/video0`:
     86
     87{{{
     88ffmpeg -f v4l2 -framerate 25 -video_size 640x480 -i /dev/video0 output.mkv
     89}}}
     90
     91=== Adjusting camera functions ===
     92
     93Brightness, zoom, focus, etc, can be adjusted with `v4l2-ctl`. Display all controls and their menus:
     94
    5895{{{
    5996v4l2-ctl -L
    6097}}}
    61 and
     98
     99Then adjust the value:
     100
    62101{{{
    63102v4l2-ctl -c <option>=<value>
    64103}}}
    65104
    66 == Mac ==
     105----
    67106
    68 Mac users can use the "qtkit" and "avfoundation" input devices for grabbing integrated iSight cameras as well as cameras connected via USB or !FireWire.
    69 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.
    70 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.
     107= OS X =
    71108
    72  
    73 === QTKit ===
     109OS X users can use the [https://ffmpeg.org/ffmpeg-devices.html#avfoundation avfoundation] and [https://ffmpeg.org/ffmpeg-devices.html#qtkit qtkit] input devices for grabbing integrated iSight cameras as well as cameras connected via USB or !FireWire:
    74110
    75 To list the supported capture devices, connected to the machine:
     111* 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.
     112* QTKit is available on Mac OS X 10.4 (Tiger) and later. QTKit has been marked deprecated since OS X 10.7 (Lion) and may not be available on future releases.
     113
     114== AVFoundation ==
     115
     116To list the supported, connected capture devices:
     117{{{
     118ffmpeg -f avfoundation -list_devices true -i ""
     119}}}
     120
     121To use the default device which is usually the first device in the listing the user can either use an empty name string or `default`:
     122{{{
     123ffmpeg -f avfoundation -i "" out.mpg
     124}}}
     125or
     126{{{
     127ffmpeg -f avfoundation -i "default" out.mpg
     128}}}
     129
     130To use one of these devices for capturing the user has to specify either the name of the device or the index shown in the device listing.
     131Abbreviations using just the beginning of the device name are possible. Thus, to capture from a device named `Integrated iSight-camera`:
     132{{{
     133ffmpeg -f avfoundation -i "Integrated" out.mpg
     134}}}
     135
     136To 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:
     137
     138{{{
     139ffmpeg -f avfoundation -i "2" out.mpg
     140}}}
     141and
     142{{{
     143ffmpeg -f avfoundation -video_device_index 2 -i "default" out.mpg
     144}}}
     145will use the device with the index `2` ignoring the default device in the second case.
     146
     147== QTKit ==
     148
     149To list the supported, connected capture devices:
    76150{{{
    77151ffmpeg -f qtkit -list_devices true -i ""
    78152}}}
    79153
    80 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":
     154To use the default device which is usually the first device in the listing the user can either use an empty name string or `default`:
    81155{{{
    82156ffmpeg -f qtkit -i "" out.mpg
     
    87161}}}
    88162
    89 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.
    90 Abbreviations using just the beginning of the device name are possible. Thus, to capture form a device named "Integrated iSight-camera":
     163To use one of these devices for capturing the user has to specify either the name of the device or the index shown in the device listing.
     164Abbreviations using just the beginning of the device name are possible. Thus, to capture from a device named `Integrated iSight-camera`:
    91165{{{
    92166ffmpeg -f qtkit -i "Integrated" out.mpg
    93167}}}
    94168
    95 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:
     169To 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:
    96170
    97 So
    98171{{{
    99172ffmpeg -f qtkit -i "2" out.mpg
     
    103176ffmpeg -f qtkit -video_device_index 2 -i "default" out.mpg
    104177}}}
    105 will use the device with the index 2 ignoring the default device in the second case.
    106 
    107 === AVFoundation ===
    108 
    109 To list the supported capture devices, connected to the machine:
    110 {{{
    111 ffmpeg -f avfoundation -list_devices true -i ""
    112 }}}
    113 
    114 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":
    115 {{{
    116 ffmpeg -f avfoundation -i "" out.mpg
    117 }}}
    118 or
    119 {{{
    120 ffmpeg -f avfoundation -i "default" out.mpg
    121 }}}
    122 
    123 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.
    124 Abbreviations using just the beginning of the device name are possible. Thus, to capture form a device named "Integrated iSight-camera":
    125 {{{
    126 ffmpeg -f avfoundation -i "Integrated" out.mpg
    127 }}}
    128 
    129 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:
    130 
    131 So
    132 {{{
    133 ffmpeg -f avfoundation -i "2" out.mpg
    134 }}}
    135 and
    136 {{{
    137 ffmpeg -f avfoundation -video_device_index 2 -i "default" out.mpg
    138 }}}
    139 will use the device with the index 2 ignoring the default device in the second case.
     178will use the device with the index `2` ignoring the default device in the second case.