Changes between Version 16 and Version 17 of Capture/Webcam
- Timestamp:
- Jun 3, 2014, 11:45:13 PM (12 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Capture/Webcam
v16 v17 1 [[PageOutline(1-3, Contents)]] 1 2 2 = = Windows ==3 = Windows = 3 4 4 == = dshow ===5 == dshow == 5 6 6 For windows you should probably use the "dshow" (DirectShow) FFmpeg input source. See DirectShow.7 Uses 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. 7 8 8 == = vfwcap ===9 == vfwcap == 9 10 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;" 11 13 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 17 Uses 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 21 To list the supported, connected capture devices: 13 22 {{{ 14 23 ffmpeg -y -f vfwcap -i list 15 24 }}} 16 25 17 That will give us the list like this:26 Example output: 18 27 {{{ 19 ... 28 … 20 29 libavutil 50.36. 0 / 50.36. 0 21 30 libavcore 0.16. 1 / 0.16. 1 … … 31 40 }}} 32 41 33 So, we can try to grab something from our camera: 42 === Encoding example === 43 44 Example to encode video from the camera: 34 45 {{{ 35 46 ffmpeg -y -f vfwcap -r 25 -i 0 out.mp4 36 47 }}} 37 48 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). 39 50 40 == Linux == 51 ---- 41 52 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 55 Uses 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 59 To 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 43 61 {{{ 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 63 USB2.0 PC CAMERA (usb-0000:00:1d.7-1): 64 /dev/video1 65 66 UVC Camera (046d:0819) (usb-0000:00:1d.7-2): 67 /dev/video0 49 68 }}} 50 69 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 === 52 71 53 You can find it in the fedora/ubuntu/debian package named '''v4l-utils'''. 72 To list available formats (supported pixel formats, video formats, and frame sizes) for a particular input device: 54 73 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 }}} 56 80 57 Also, you might want to correct brightness, zoom, focus, etc. with: 81 Alternatively you could use `v4l2-ctl --list-formats-ext` to list available formats. 82 83 === Encoding example === 84 85 Example to encode video from `/dev/video0`: 86 87 {{{ 88 ffmpeg -f v4l2 -framerate 25 -video_size 640x480 -i /dev/video0 output.mkv 89 }}} 90 91 === Adjusting camera functions === 92 93 Brightness, zoom, focus, etc, can be adjusted with `v4l2-ctl`. Display all controls and their menus: 94 58 95 {{{ 59 96 v4l2-ctl -L 60 97 }}} 61 and 98 99 Then adjust the value: 100 62 101 {{{ 63 102 v4l2-ctl -c <option>=<value> 64 103 }}} 65 104 66 == Mac == 105 ---- 67 106 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 = 71 108 72 73 === QTKit === 109 OS 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: 74 110 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 116 To list the supported, connected capture devices: 117 {{{ 118 ffmpeg -f avfoundation -list_devices true -i "" 119 }}} 120 121 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`: 122 {{{ 123 ffmpeg -f avfoundation -i "" out.mpg 124 }}} 125 or 126 {{{ 127 ffmpeg -f avfoundation -i "default" out.mpg 128 }}} 129 130 To 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. 131 Abbreviations using just the beginning of the device name are possible. Thus, to capture from a device named `Integrated iSight-camera`: 132 {{{ 133 ffmpeg -f avfoundation -i "Integrated" out.mpg 134 }}} 135 136 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: 137 138 {{{ 139 ffmpeg -f avfoundation -i "2" out.mpg 140 }}} 141 and 142 {{{ 143 ffmpeg -f avfoundation -video_device_index 2 -i "default" out.mpg 144 }}} 145 will use the device with the index `2` ignoring the default device in the second case. 146 147 == QTKit == 148 149 To list the supported, connected capture devices: 76 150 {{{ 77 151 ffmpeg -f qtkit -list_devices true -i "" 78 152 }}} 79 153 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":154 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`: 81 155 {{{ 82 156 ffmpeg -f qtkit -i "" out.mpg … … 87 161 }}} 88 162 89 To use one of these devices for capturing the user has to specif iy 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 f orm a device named "Integrated iSight-camera":163 To 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. 164 Abbreviations using just the beginning of the device name are possible. Thus, to capture from a device named `Integrated iSight-camera`: 91 165 {{{ 92 166 ffmpeg -f qtkit -i "Integrated" out.mpg 93 167 }}} 94 168 95 To use the device's index provide the index either as the input or use the -video_device_indexoption that will override any given input name:169 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: 96 170 97 So98 171 {{{ 99 172 ffmpeg -f qtkit -i "2" out.mpg … … 103 176 ffmpeg -f qtkit -video_device_index 2 -i "default" out.mpg 104 177 }}} 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. 178 will use the device with the index `2` ignoring the default device in the second case.
