indevs.texi 17 KB

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