indevs.texi 17 KB

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