OSDN Git Service

Merge remote-tracking branch 'qatar/master'
[coroid/ffmpeg_saccubus.git] / doc / indevs.texi
1 @chapter Input Devices
2 @c man begin INPUT DEVICES
3
4 Input devices are configured elements in FFmpeg which allow to access
5 the data coming from a multimedia device attached to your system.
6
7 When you configure your FFmpeg build, all the supported input devices
8 are enabled by default. You can list all available ones using the
9 configure option "--list-indevs".
10
11 You can disable all the input devices using the configure option
12 "--disable-indevs", and selectively enable an input device using the
13 option "--enable-indev=@var{INDEV}", or you can disable a particular
14 input device using the option "--disable-indev=@var{INDEV}".
15
16 The option "-formats" of the ff* tools will display the list of
17 supported input devices (amongst the demuxers).
18
19 A description of the currently available input devices follows.
20
21 @section alsa
22
23 ALSA (Advanced Linux Sound Architecture) input device.
24
25 To enable this input device during configuration you need libasound
26 installed on your system.
27
28 This device allows capturing from an ALSA device. The name of the
29 device to capture has to be an ALSA card identifier.
30
31 An ALSA identifier has the syntax:
32 @example
33 hw:@var{CARD}[,@var{DEV}[,@var{SUBDEV}]]
34 @end example
35
36 where the @var{DEV} and @var{SUBDEV} components are optional.
37
38 The three arguments (in order: @var{CARD},@var{DEV},@var{SUBDEV})
39 specify card number or identifier, device number and subdevice number
40 (-1 means any).
41
42 To see the list of cards currently recognized by your system check the
43 files @file{/proc/asound/cards} and @file{/proc/asound/devices}.
44
45 For example to capture with @file{ffmpeg} from an ALSA device with
46 card id 0, you may run the command:
47 @example
48 ffmpeg -f alsa -i hw:0 alsaout.wav
49 @end example
50
51 For more information see:
52 @url{http://www.alsa-project.org/alsa-doc/alsa-lib/pcm.html}
53
54 @section bktr
55
56 BSD video input device.
57
58 @section dv1394
59
60 Linux DV 1394 input device.
61
62 @section fbdev
63
64 Linux framebuffer input device.
65
66 The Linux framebuffer is a graphic hardware-independent abstraction
67 layer to show graphics on a computer monitor, typically on the
68 console. It is accessed through a file device node, usually
69 @file{/dev/fb0}.
70
71 For more detailed information read the file
72 Documentation/fb/framebuffer.txt included in the Linux source tree.
73
74 To record from the framebuffer device @file{/dev/fb0} with
75 @file{ffmpeg}:
76 @example
77 ffmpeg -f fbdev -r 10 -i /dev/fb0 out.avi
78 @end example
79
80 You can take a single screenshot image with the command:
81 @example
82 ffmpeg -f fbdev -vframes 1 -r 1 -i /dev/fb0 screenshot.jpeg
83 @end example
84
85 See also @url{http://linux-fbdev.sourceforge.net/}, and fbset(1).
86
87 @section jack
88
89 JACK input device.
90
91 To enable this input device during configuration you need libjack
92 installed on your system.
93
94 A JACK input device creates one or more JACK writable clients, one for
95 each audio channel, with name @var{client_name}:input_@var{N}, where
96 @var{client_name} is the name provided by the application, and @var{N}
97 is a number which identifies the channel.
98 Each writable client will send the acquired data to the FFmpeg input
99 device.
100
101 Once you have created one or more JACK readable clients, you need to
102 connect them to one or more JACK writable clients.
103
104 To connect or disconnect JACK clients you can use the
105 @file{jack_connect} and @file{jack_disconnect} programs, or do it
106 through a graphical interface, for example with @file{qjackctl}.
107
108 To list the JACK clients and their properties you can invoke the command
109 @file{jack_lsp}.
110
111 Follows an example which shows how to capture a JACK readable client
112 with @file{ffmpeg}.
113 @example
114 # Create a JACK writable client with name "ffmpeg".
115 $ ffmpeg -f jack -i ffmpeg -y out.wav
116
117 # Start the sample jack_metro readable client.
118 $ jack_metro -b 120 -d 0.2 -f 4000
119
120 # List the current JACK clients.
121 $ jack_lsp -c
122 system:capture_1
123 system:capture_2
124 system:playback_1
125 system:playback_2
126 ffmpeg:input_1
127 metro:120_bpm
128
129 # Connect metro to the ffmpeg writable client.
130 $ jack_connect metro:120_bpm ffmpeg:input_1
131 @end example
132
133 For more information read:
134 @url{http://jackaudio.org/}
135
136 @section lavfi
137
138 Libavfilter input virtual device.
139
140 This input device reads data from the open output pads of a libavfilter
141 filtergraph.
142
143 For each filtergraph open output, the input device will create a
144 corresponding stream which is mapped to the generated output. Currently
145 only video data is supported. The filtergraph is specified through the
146 option @option{graph}.
147
148 To enable this input device, you need to configure your build with
149 @code{--enable-libavfilter}.
150
151 @subsection Options
152
153 @table @option
154
155 @item graph
156 Specify the filtergraph to use as input. Each video open output must be
157 labelled by a unique string of the form "out@var{N}", where @var{N} is a
158 number starting from 0 corresponding to the mapped input stream
159 generated by the device.
160 The first unlabelled output is automatically assigned to the "out0"
161 label, but all the others need to be specified explicitely.
162
163 If not specified defaults to the filename specified for the input
164 device.
165 @end table
166
167 @subsection Examples
168
169 @itemize
170 @item
171 Create a color video stream and play it back with @file{ffplay}:
172 @example
173 ffplay -f lavfi -graph "color=pink [out0]" dummy
174 @end example
175
176 @item
177 As the previous example, but use filename for specifying the graph
178 description, and omit the "out0" label:
179 @example
180 ffplay -f lavfi color=pink
181 @end example
182
183 @item
184 Create three different video test filtered sources and play them:
185 @example
186 ffplay -f lavfi -graph "testsrc [out0]; testsrc,hflip [out1]; testsrc,negate [out2]" test3
187 @end example
188 @end itemize
189
190 @section libdc1394
191
192 IIDC1394 input device, based on libdc1394 and libraw1394.
193
194 @section openal
195
196 The OpenAL input device provides audio capture on all systems with a
197 working OpenAL 1.1 implementation.
198
199 To enable this input device during configuration, you need OpenAL
200 headers and libraries installed on your system, and need to configure
201 FFmpeg with @code{--enable-openal}.
202
203 OpenAL headers and libraries should be provided as part of your OpenAL
204 implementation, or as an additional download (an SDK). Depending on your
205 installation you may need to specify additional flags via the
206 @code{--extra-cflags} and @code{--extra-ldflags} for allowing the build
207 system to locate the OpenAL headers and libraries.
208
209 An incomplete list of OpenAL implementations follows:
210
211 @table @strong
212 @item Creative
213 The official Windows implementation, providing hardware acceleration
214 with supported devices and software fallback.
215 See @url{http://openal.org/}.
216 @item OpenAL Soft
217 Portable, open source (LGPL) software implementation. Includes
218 backends for the most common sound APIs on the Windows, Linux,
219 Solaris, and BSD operating systems.
220 See @url{http://kcat.strangesoft.net/openal.html}.
221 @item Apple
222 OpenAL is part of Core Audio, the official Mac OS X Audio interface.
223 See @url{http://developer.apple.com/technologies/mac/audio-and-video.html}
224 @end table
225
226 This device allows to capture from an audio input device handled
227 through OpenAL.
228
229 You need to specify the name of the device to capture in the provided
230 filename. If the empty string is provided, the device will
231 automatically select the default device. You can get the list of the
232 supported devices by using the option @var{list_devices}.
233
234 @subsection Options
235
236 @table @option
237
238 @item channels
239 Set the number of channels in the captured audio. Only the values
240 @option{1} (monaural) and @option{2} (stereo) are currently supported.
241 Defaults to @option{2}.
242
243 @item sample_size
244 Set the sample size (in bits) of the captured audio. Only the values
245 @option{8} and @option{16} are currently supported. Defaults to
246 @option{16}.
247
248 @item sample_rate
249 Set the sample rate (in Hz) of the captured audio.
250 Defaults to @option{44.1k}.
251
252 @item list_devices
253 If set to @option{true}, print a list of devices and exit.
254 Defaults to @option{false}.
255
256 @end table
257
258 @subsection Examples
259
260 Print the list of OpenAL supported devices and exit:
261 @example
262 $ ffmpeg -list_devices true -f openal -i dummy out.ogg
263 @end example
264
265 Capture from the OpenAL device @file{DR-BT101 via PulseAudio}:
266 @example
267 $ ffmpeg -f openal -i 'DR-BT101 via PulseAudio' out.ogg
268 @end example
269
270 Capture from the default device (note the empty string '' as filename):
271 @example
272 $ ffmpeg -f openal -i '' out.ogg
273 @end example
274
275 Capture from two devices simultaneously, writing to two different files,
276 within the same @file{ffmpeg} command:
277 @example
278 $ ffmpeg -f openal -i 'DR-BT101 via PulseAudio' out1.ogg -f openal -i 'ALSA Default' out2.ogg
279 @end example
280 Note: not all OpenAL implementations support multiple simultaneous capture -
281 try the latest OpenAL Soft if the above does not work.
282
283 @section oss
284
285 Open Sound System input device.
286
287 The filename to provide to the input device is the device node
288 representing the OSS input device, and is usually set to
289 @file{/dev/dsp}.
290
291 For example to grab from @file{/dev/dsp} using @file{ffmpeg} use the
292 command:
293 @example
294 ffmpeg -f oss -i /dev/dsp /tmp/oss.wav
295 @end example
296
297 For more information about OSS see:
298 @url{http://manuals.opensound.com/usersguide/dsp.html}
299
300 @section sndio
301
302 sndio input device.
303
304 To enable this input device during configuration you need libsndio
305 installed on your system.
306
307 The filename to provide to the input device is the device node
308 representing the sndio input device, and is usually set to
309 @file{/dev/audio0}.
310
311 For example to grab from @file{/dev/audio0} using @file{ffmpeg} use the
312 command:
313 @example
314 ffmpeg -f sndio -i /dev/audio0 /tmp/oss.wav
315 @end example
316
317 @section video4linux and video4linux2
318
319 Video4Linux and Video4Linux2 input video devices.
320
321 The name of the device to grab is a file device node, usually Linux
322 systems tend to automatically create such nodes when the device
323 (e.g. an USB webcam) is plugged into the system, and has a name of the
324 kind @file{/dev/video@var{N}}, where @var{N} is a number associated to
325 the device.
326
327 Video4Linux and Video4Linux2 devices only support a limited set of
328 @var{width}x@var{height} sizes and framerates. You can check which are
329 supported for example with the command @file{dov4l} for Video4Linux
330 devices and the command @file{v4l-info} for Video4Linux2 devices.
331
332 If the size for the device is set to 0x0, the input device will
333 try to autodetect the size to use.
334 Only for the video4linux2 device, if the frame rate is set to 0/0 the
335 input device will use the frame rate value already set in the driver.
336
337 Video4Linux support is deprecated since Linux 2.6.30, and will be
338 dropped in later versions.
339
340 Follow some usage examples of the video4linux devices with the ff*
341 tools.
342 @example
343 # Grab and show the input of a video4linux device, frame rate is set
344 # to the default of 25/1.
345 ffplay -s 320x240 -f video4linux /dev/video0
346
347 # Grab and show the input of a video4linux2 device, autoadjust size.
348 ffplay -f video4linux2 /dev/video0
349
350 # Grab and record the input of a video4linux2 device, autoadjust size,
351 # frame rate value defaults to 0/0 so it is read from the video4linux2
352 # driver.
353 ffmpeg -f video4linux2 -i /dev/video0 out.mpeg
354 @end example
355
356 @section vfwcap
357
358 VfW (Video for Windows) capture input device.
359
360 The filename passed as input is the capture driver number, ranging from
361 0 to 9. You may use "list" as filename to print a list of drivers. Any
362 other filename will be interpreted as device number 0.
363
364 @section x11grab
365
366 X11 video input device.
367
368 This device allows to capture a region of an X11 display.
369
370 The filename passed as input has the syntax:
371 @example
372 [@var{hostname}]:@var{display_number}.@var{screen_number}[+@var{x_offset},@var{y_offset}]
373 @end example
374
375 @var{hostname}:@var{display_number}.@var{screen_number} specifies the
376 X11 display name of the screen to grab from. @var{hostname} can be
377 ommitted, and defaults to "localhost". The environment variable
378 @env{DISPLAY} contains the default display name.
379
380 @var{x_offset} and @var{y_offset} specify the offsets of the grabbed
381 area with respect to the top-left border of the X11 screen. They
382 default to 0.
383
384 Check the X11 documentation (e.g. man X) for more detailed information.
385
386 Use the @file{dpyinfo} program for getting basic information about the
387 properties of your X11 display (e.g. grep for "name" or "dimensions").
388
389 For example to grab from @file{:0.0} using @file{ffmpeg}:
390 @example
391 ffmpeg -f x11grab -r 25 -s cif -i :0.0 out.mpg
392
393 # Grab at position 10,20.
394 ffmpeg -f x11grab -r 25 -s cif -i :0.0+10,20 out.mpg
395 @end example
396
397 @subsection @var{follow_mouse} AVOption
398
399 The syntax is:
400 @example
401 -follow_mouse centered|@var{PIXELS}
402 @end example
403
404 When it is specified with "centered", the grabbing region follows the mouse
405 pointer and keeps the pointer at the center of region; otherwise, the region
406 follows only when the mouse pointer reaches within @var{PIXELS} (greater than
407 zero) to the edge of region.
408
409 For example:
410 @example
411 ffmpeg -f x11grab -follow_mouse centered -r 25 -s cif -i :0.0 out.mpg
412
413 # Follows only when the mouse pointer reaches within 100 pixels to edge
414 ffmpeg -f x11grab -follow_mouse 100 -r 25 -s cif -i :0.0 out.mpg
415 @end example
416
417 @subsection @var{show_region} AVOption
418
419 The syntax is:
420 @example
421 -show_region 1
422 @end example
423
424 If @var{show_region} AVOption is specified with @var{1}, then the grabbing
425 region will be indicated on screen. With this option, it's easy to know what is
426 being grabbed if only a portion of the screen is grabbed.
427
428 For example:
429 @example
430 ffmpeg -f x11grab -show_region 1 -r 25 -s cif -i :0.0+10,20 out.mpg
431
432 # With follow_mouse
433 ffmpeg -f x11grab -follow_mouse centered -show_region 1  -r 25 -s cif -i :0.0 out.mpg
434 @end example
435
436 @c man end INPUT DEVICES