]> git.sesse.net Git - ffmpeg/blob - doc/indevs.texi
ffmpeg: Check that frames are user type before treating them as such
[ffmpeg] / 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 @command{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 dshow
59
60 Windows DirectShow input device.
61
62 DirectShow support is enabled when FFmpeg is built with mingw-w64.
63 Currently only audio and video devices are supported.
64
65 Multiple devices may be opened as separate inputs, but they may also be
66 opened on the same input, which should improve synchronism between them.
67
68 The input name should be in the format:
69
70 @example
71 @var{TYPE}=@var{NAME}[:@var{TYPE}=@var{NAME}]
72 @end example
73
74 where @var{TYPE} can be either @var{audio} or @var{video},
75 and @var{NAME} is the device's name.
76
77 @subsection Options
78
79 If no options are specified, the device's defaults are used.
80 If the device does not support the requested options, it will
81 fail to open.
82
83 @table @option
84
85 @item video_size
86 Set the video size in the captured video.
87
88 @item framerate
89 Set the framerate in the captured video.
90
91 @item sample_rate
92 Set the sample rate (in Hz) of the captured audio.
93
94 @item sample_size
95 Set the sample size (in bits) of the captured audio.
96
97 @item channels
98 Set the number of channels in the captured audio.
99
100 @item list_devices
101 If set to @option{true}, print a list of devices and exit.
102
103 @item list_options
104 If set to @option{true}, print a list of selected device's options
105 and exit.
106
107 @item video_device_number
108 Set video device number for devices with same name (starts at 0,
109 defaults to 0).
110
111 @item audio_device_number
112 Set audio device number for devices with same name (starts at 0,
113 defaults to 0).
114
115 @end table
116
117 @subsection Examples
118
119 @itemize
120
121 @item
122 Print the list of DirectShow supported devices and exit:
123 @example
124 $ ffmpeg -list_devices true -f dshow -i dummy
125 @end example
126
127 @item
128 Open video device @var{Camera}:
129 @example
130 $ ffmpeg -f dshow -i video="Camera"
131 @end example
132
133 @item
134 Open second video device with name @var{Camera}:
135 @example
136 $ ffmpeg -f dshow -video_device_number 1 -i video="Camera"
137 @end example
138
139 @item
140 Open video device @var{Camera} and audio device @var{Microphone}:
141 @example
142 $ ffmpeg -f dshow -i video="Camera":audio="Microphone"
143 @end example
144
145 @item
146 Print the list of supported options in selected device and exit:
147 @example
148 $ ffmpeg -list_options true -f dshow -i video="Camera"
149 @end example
150
151 @end itemize
152
153 @section dv1394
154
155 Linux DV 1394 input device.
156
157 @section fbdev
158
159 Linux framebuffer input device.
160
161 The Linux framebuffer is a graphic hardware-independent abstraction
162 layer to show graphics on a computer monitor, typically on the
163 console. It is accessed through a file device node, usually
164 @file{/dev/fb0}.
165
166 For more detailed information read the file
167 Documentation/fb/framebuffer.txt included in the Linux source tree.
168
169 To record from the framebuffer device @file{/dev/fb0} with
170 @command{ffmpeg}:
171 @example
172 ffmpeg -f fbdev -r 10 -i /dev/fb0 out.avi
173 @end example
174
175 You can take a single screenshot image with the command:
176 @example
177 ffmpeg -f fbdev -frames:v 1 -r 1 -i /dev/fb0 screenshot.jpeg
178 @end example
179
180 See also @url{http://linux-fbdev.sourceforge.net/}, and fbset(1).
181
182 @section jack
183
184 JACK input device.
185
186 To enable this input device during configuration you need libjack
187 installed on your system.
188
189 A JACK input device creates one or more JACK writable clients, one for
190 each audio channel, with name @var{client_name}:input_@var{N}, where
191 @var{client_name} is the name provided by the application, and @var{N}
192 is a number which identifies the channel.
193 Each writable client will send the acquired data to the FFmpeg input
194 device.
195
196 Once you have created one or more JACK readable clients, you need to
197 connect them to one or more JACK writable clients.
198
199 To connect or disconnect JACK clients you can use the
200 @file{jack_connect} and @file{jack_disconnect} programs, or do it
201 through a graphical interface, for example with @file{qjackctl}.
202
203 To list the JACK clients and their properties you can invoke the command
204 @file{jack_lsp}.
205
206 Follows an example which shows how to capture a JACK readable client
207 with @command{ffmpeg}.
208 @example
209 # Create a JACK writable client with name "ffmpeg".
210 $ ffmpeg -f jack -i ffmpeg -y out.wav
211
212 # Start the sample jack_metro readable client.
213 $ jack_metro -b 120 -d 0.2 -f 4000
214
215 # List the current JACK clients.
216 $ jack_lsp -c
217 system:capture_1
218 system:capture_2
219 system:playback_1
220 system:playback_2
221 ffmpeg:input_1
222 metro:120_bpm
223
224 # Connect metro to the ffmpeg writable client.
225 $ jack_connect metro:120_bpm ffmpeg:input_1
226 @end example
227
228 For more information read:
229 @url{http://jackaudio.org/}
230
231 @section lavfi
232
233 Libavfilter input virtual device.
234
235 This input device reads data from the open output pads of a libavfilter
236 filtergraph.
237
238 For each filtergraph open output, the input device will create a
239 corresponding stream which is mapped to the generated output. Currently
240 only video data is supported. The filtergraph is specified through the
241 option @option{graph}.
242
243 @subsection Options
244
245 @table @option
246
247 @item graph
248 Specify the filtergraph to use as input. Each video open output must be
249 labelled by a unique string of the form "out@var{N}", where @var{N} is a
250 number starting from 0 corresponding to the mapped input stream
251 generated by the device.
252 The first unlabelled output is automatically assigned to the "out0"
253 label, but all the others need to be specified explicitly.
254
255 If not specified defaults to the filename specified for the input
256 device.
257 @end table
258
259 @subsection Examples
260
261 @itemize
262 @item
263 Create a color video stream and play it back with @file{ffplay}:
264 @example
265 ffplay -f lavfi -graph "color=pink [out0]" dummy
266 @end example
267
268 @item
269 As the previous example, but use filename for specifying the graph
270 description, and omit the "out0" label:
271 @example
272 ffplay -f lavfi color=pink
273 @end example
274
275 @item
276 Create three different video test filtered sources and play them:
277 @example
278 ffplay -f lavfi -graph "testsrc [out0]; testsrc,hflip [out1]; testsrc,negate [out2]" test3
279 @end example
280
281 @item
282 Read an audio stream from a file using the amovie source and play it
283 back with @file{ffplay}:
284 @example
285 ffplay -f lavfi "amovie=test.wav"
286 @end example
287
288 @item
289 Read an audio stream and a video stream and play it back with
290 @file{ffplay}:
291 @example
292 ffplay -f lavfi "movie=test.avi[out0];amovie=test.wav[out1]"
293 @end example
294
295 @end itemize
296
297 @section libdc1394
298
299 IIDC1394 input device, based on libdc1394 and libraw1394.
300
301 @section openal
302
303 The OpenAL input device provides audio capture on all systems with a
304 working OpenAL 1.1 implementation.
305
306 To enable this input device during configuration, you need OpenAL
307 headers and libraries installed on your system, and need to configure
308 FFmpeg with @code{--enable-openal}.
309
310 OpenAL headers and libraries should be provided as part of your OpenAL
311 implementation, or as an additional download (an SDK). Depending on your
312 installation you may need to specify additional flags via the
313 @code{--extra-cflags} and @code{--extra-ldflags} for allowing the build
314 system to locate the OpenAL headers and libraries.
315
316 An incomplete list of OpenAL implementations follows:
317
318 @table @strong
319 @item Creative
320 The official Windows implementation, providing hardware acceleration
321 with supported devices and software fallback.
322 See @url{http://openal.org/}.
323 @item OpenAL Soft
324 Portable, open source (LGPL) software implementation. Includes
325 backends for the most common sound APIs on the Windows, Linux,
326 Solaris, and BSD operating systems.
327 See @url{http://kcat.strangesoft.net/openal.html}.
328 @item Apple
329 OpenAL is part of Core Audio, the official Mac OS X Audio interface.
330 See @url{http://developer.apple.com/technologies/mac/audio-and-video.html}
331 @end table
332
333 This device allows to capture from an audio input device handled
334 through OpenAL.
335
336 You need to specify the name of the device to capture in the provided
337 filename. If the empty string is provided, the device will
338 automatically select the default device. You can get the list of the
339 supported devices by using the option @var{list_devices}.
340
341 @subsection Options
342
343 @table @option
344
345 @item channels
346 Set the number of channels in the captured audio. Only the values
347 @option{1} (monaural) and @option{2} (stereo) are currently supported.
348 Defaults to @option{2}.
349
350 @item sample_size
351 Set the sample size (in bits) of the captured audio. Only the values
352 @option{8} and @option{16} are currently supported. Defaults to
353 @option{16}.
354
355 @item sample_rate
356 Set the sample rate (in Hz) of the captured audio.
357 Defaults to @option{44.1k}.
358
359 @item list_devices
360 If set to @option{true}, print a list of devices and exit.
361 Defaults to @option{false}.
362
363 @end table
364
365 @subsection Examples
366
367 Print the list of OpenAL supported devices and exit:
368 @example
369 $ ffmpeg -list_devices true -f openal -i dummy out.ogg
370 @end example
371
372 Capture from the OpenAL device @file{DR-BT101 via PulseAudio}:
373 @example
374 $ ffmpeg -f openal -i 'DR-BT101 via PulseAudio' out.ogg
375 @end example
376
377 Capture from the default device (note the empty string '' as filename):
378 @example
379 $ ffmpeg -f openal -i '' out.ogg
380 @end example
381
382 Capture from two devices simultaneously, writing to two different files,
383 within the same @file{ffmpeg} command:
384 @example
385 $ ffmpeg -f openal -i 'DR-BT101 via PulseAudio' out1.ogg -f openal -i 'ALSA Default' out2.ogg
386 @end example
387 Note: not all OpenAL implementations support multiple simultaneous capture -
388 try the latest OpenAL Soft if the above does not work.
389
390 @section oss
391
392 Open Sound System input device.
393
394 The filename to provide to the input device is the device node
395 representing the OSS input device, and is usually set to
396 @file{/dev/dsp}.
397
398 For example to grab from @file{/dev/dsp} using @command{ffmpeg} use the
399 command:
400 @example
401 ffmpeg -f oss -i /dev/dsp /tmp/oss.wav
402 @end example
403
404 For more information about OSS see:
405 @url{http://manuals.opensound.com/usersguide/dsp.html}
406
407 @section pulse
408
409 pulseaudio input device.
410
411 To enable this input device during configuration you need libpulse-simple
412 installed in your system.
413
414 The filename to provide to the input device is a source device or the
415 string "default"
416
417 To list the pulse source devices and their properties you can invoke
418 the command @file{pactl list sources}.
419
420 @example
421 ffmpeg -f pulse -i default /tmp/pulse.wav
422 @end example
423
424 @subsection @var{server} AVOption
425
426 The syntax is:
427 @example
428 -server @var{server name}
429 @end example
430
431 Connects to a specific server.
432
433 @subsection @var{name} AVOption
434
435 The syntax is:
436 @example
437 -name @var{application name}
438 @end example
439
440 Specify the application name pulse will use when showing active clients,
441 by default it is the LIBAVFORMAT_IDENT string
442
443 @subsection @var{stream_name} AVOption
444
445 The syntax is:
446 @example
447 -stream_name @var{stream name}
448 @end example
449
450 Specify the stream name pulse will use when showing active streams,
451 by default it is "record"
452
453 @subsection @var{sample_rate} AVOption
454
455 The syntax is:
456 @example
457 -sample_rate @var{samplerate}
458 @end example
459
460 Specify the samplerate in Hz, by default 48kHz is used.
461
462 @subsection @var{channels} AVOption
463
464 The syntax is:
465 @example
466 -channels @var{N}
467 @end example
468
469 Specify the channels in use, by default 2 (stereo) is set.
470
471 @subsection @var{frame_size} AVOption
472
473 The syntax is:
474 @example
475 -frame_size @var{bytes}
476 @end example
477
478 Specify the number of byte per frame, by default it is set to 1024.
479
480 @subsection @var{fragment_size} AVOption
481
482 The syntax is:
483 @example
484 -fragment_size @var{bytes}
485 @end example
486
487 Specify the minimal buffering fragment in pulseaudio, it will affect the
488 audio latency. By default it is unset.
489
490 @section sndio
491
492 sndio input device.
493
494 To enable this input device during configuration you need libsndio
495 installed on your system.
496
497 The filename to provide to the input device is the device node
498 representing the sndio input device, and is usually set to
499 @file{/dev/audio0}.
500
501 For example to grab from @file{/dev/audio0} using @command{ffmpeg} use the
502 command:
503 @example
504 ffmpeg -f sndio -i /dev/audio0 /tmp/oss.wav
505 @end example
506
507 @section video4linux and video4linux2
508
509 Video4Linux and Video4Linux2 input video devices.
510
511 The name of the device to grab is a file device node, usually Linux
512 systems tend to automatically create such nodes when the device
513 (e.g. an USB webcam) is plugged into the system, and has a name of the
514 kind @file{/dev/video@var{N}}, where @var{N} is a number associated to
515 the device.
516
517 Video4Linux and Video4Linux2 devices only support a limited set of
518 @var{width}x@var{height} sizes and frame rates. You can check which are
519 supported for example with the command @file{dov4l} for Video4Linux
520 devices and the command @file{v4l-info} for Video4Linux2 devices.
521
522 If the size for the device is set to 0x0, the input device will
523 try to auto-detect the size to use.
524 Only for the video4linux2 device, if the frame rate is set to 0/0 the
525 input device will use the frame rate value already set in the driver.
526
527 Video4Linux support is deprecated since Linux 2.6.30, and will be
528 dropped in later versions.
529
530 Note that if FFmpeg is build with v4l-utils support ("--enable-libv4l2"
531 option), it will always be used.
532
533 Follow some usage examples of the video4linux devices with the ff*
534 tools.
535 @example
536 # Grab and show the input of a video4linux device, frame rate is set
537 # to the default of 25/1.
538 ffplay -s 320x240 -f video4linux /dev/video0
539
540 # Grab and show the input of a video4linux2 device, auto-adjust size.
541 ffplay -f video4linux2 /dev/video0
542
543 # Grab and record the input of a video4linux2 device, auto-adjust size,
544 # frame rate value defaults to 0/0 so it is read from the video4linux2
545 # driver.
546 ffmpeg -f video4linux2 -i /dev/video0 out.mpeg
547 @end example
548
549 "v4l" and "v4l2" can be used as aliases for the respective "video4linux" and
550 "video4linux2".
551
552 @section vfwcap
553
554 VfW (Video for Windows) capture input device.
555
556 The filename passed as input is the capture driver number, ranging from
557 0 to 9. You may use "list" as filename to print a list of drivers. Any
558 other filename will be interpreted as device number 0.
559
560 @section x11grab
561
562 X11 video input device.
563
564 This device allows to capture a region of an X11 display.
565
566 The filename passed as input has the syntax:
567 @example
568 [@var{hostname}]:@var{display_number}.@var{screen_number}[+@var{x_offset},@var{y_offset}]
569 @end example
570
571 @var{hostname}:@var{display_number}.@var{screen_number} specifies the
572 X11 display name of the screen to grab from. @var{hostname} can be
573 omitted, and defaults to "localhost". The environment variable
574 @env{DISPLAY} contains the default display name.
575
576 @var{x_offset} and @var{y_offset} specify the offsets of the grabbed
577 area with respect to the top-left border of the X11 screen. They
578 default to 0.
579
580 Check the X11 documentation (e.g. man X) for more detailed information.
581
582 Use the @file{dpyinfo} program for getting basic information about the
583 properties of your X11 display (e.g. grep for "name" or "dimensions").
584
585 For example to grab from @file{:0.0} using @command{ffmpeg}:
586 @example
587 ffmpeg -f x11grab -r 25 -s cif -i :0.0 out.mpg
588
589 # Grab at position 10,20.
590 ffmpeg -f x11grab -r 25 -s cif -i :0.0+10,20 out.mpg
591 @end example
592
593 @subsection @var{follow_mouse} AVOption
594
595 The syntax is:
596 @example
597 -follow_mouse centered|@var{PIXELS}
598 @end example
599
600 When it is specified with "centered", the grabbing region follows the mouse
601 pointer and keeps the pointer at the center of region; otherwise, the region
602 follows only when the mouse pointer reaches within @var{PIXELS} (greater than
603 zero) to the edge of region.
604
605 For example:
606 @example
607 ffmpeg -f x11grab -follow_mouse centered -r 25 -s cif -i :0.0 out.mpg
608
609 # Follows only when the mouse pointer reaches within 100 pixels to edge
610 ffmpeg -f x11grab -follow_mouse 100 -r 25 -s cif -i :0.0 out.mpg
611 @end example
612
613 @subsection @var{show_region} AVOption
614
615 The syntax is:
616 @example
617 -show_region 1
618 @end example
619
620 If @var{show_region} AVOption is specified with @var{1}, then the grabbing
621 region will be indicated on screen. With this option, it's easy to know what is
622 being grabbed if only a portion of the screen is grabbed.
623
624 For example:
625 @example
626 ffmpeg -f x11grab -show_region 1 -r 25 -s cif -i :0.0+10,20 out.mpg
627
628 # With follow_mouse
629 ffmpeg -f x11grab -follow_mouse centered -show_region 1  -r 25 -s cif -i :0.0 out.mpg
630 @end example
631
632 @c man end INPUT DEVICES