You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

518 lines
15KB

  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. To enable this input device, you need to configure your build with
  162. @code{--enable-libavfilter}.
  163. @subsection Options
  164. @table @option
  165. @item graph
  166. Specify the filtergraph to use as input. Each video open output must be
  167. labelled by a unique string of the form "out@var{N}", where @var{N} is a
  168. number starting from 0 corresponding to the mapped input stream
  169. generated by the device.
  170. The first unlabelled output is automatically assigned to the "out0"
  171. label, but all the others need to be specified explicitely.
  172. If not specified defaults to the filename specified for the input
  173. device.
  174. @end table
  175. @subsection Examples
  176. @itemize
  177. @item
  178. Create a color video stream and play it back with @file{ffplay}:
  179. @example
  180. ffplay -f lavfi -graph "color=pink [out0]" dummy
  181. @end example
  182. @item
  183. As the previous example, but use filename for specifying the graph
  184. description, and omit the "out0" label:
  185. @example
  186. ffplay -f lavfi color=pink
  187. @end example
  188. @item
  189. Create three different video test filtered sources and play them:
  190. @example
  191. ffplay -f lavfi -graph "testsrc [out0]; testsrc,hflip [out1]; testsrc,negate [out2]" test3
  192. @end example
  193. @end itemize
  194. @section libdc1394
  195. IIDC1394 input device, based on libdc1394 and libraw1394.
  196. @section openal
  197. The OpenAL input device provides audio capture on all systems with a
  198. working OpenAL 1.1 implementation.
  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. OpenAL headers and libraries should be provided as part of your OpenAL
  203. implementation, or as an additional download (an SDK). Depending on your
  204. installation you may need to specify additional flags via the
  205. @code{--extra-cflags} and @code{--extra-ldflags} for allowing the build
  206. system to locate the OpenAL headers and libraries.
  207. An incomplete list of OpenAL implementations follows:
  208. @table @strong
  209. @item Creative
  210. The official Windows implementation, providing hardware acceleration
  211. with supported devices and software fallback.
  212. See @url{http://openal.org/}.
  213. @item OpenAL Soft
  214. Portable, open source (LGPL) software implementation. Includes
  215. backends for the most common sound APIs on the Windows, Linux,
  216. Solaris, and BSD operating systems.
  217. See @url{http://kcat.strangesoft.net/openal.html}.
  218. @item Apple
  219. OpenAL is part of Core Audio, the official Mac OS X Audio interface.
  220. See @url{http://developer.apple.com/technologies/mac/audio-and-video.html}
  221. @end table
  222. This device allows to capture from an audio input device handled
  223. through OpenAL.
  224. You need to specify the name of the device to capture in the provided
  225. filename. If the empty string is provided, the device will
  226. automatically select the default device. You can get the list of the
  227. supported devices by using the option @var{list_devices}.
  228. @subsection Options
  229. @table @option
  230. @item channels
  231. Set the number of channels in the captured audio. Only the values
  232. @option{1} (monaural) and @option{2} (stereo) are currently supported.
  233. Defaults to @option{2}.
  234. @item sample_size
  235. Set the sample size (in bits) of the captured audio. Only the values
  236. @option{8} and @option{16} are currently supported. Defaults to
  237. @option{16}.
  238. @item sample_rate
  239. Set the sample rate (in Hz) of the captured audio.
  240. Defaults to @option{44.1k}.
  241. @item list_devices
  242. If set to @option{true}, print a list of devices and exit.
  243. Defaults to @option{false}.
  244. @end table
  245. @subsection Examples
  246. Print the list of OpenAL supported devices and exit:
  247. @example
  248. $ ffmpeg -list_devices true -f openal -i dummy out.ogg
  249. @end example
  250. Capture from the OpenAL device @file{DR-BT101 via PulseAudio}:
  251. @example
  252. $ ffmpeg -f openal -i 'DR-BT101 via PulseAudio' out.ogg
  253. @end example
  254. Capture from the default device (note the empty string '' as filename):
  255. @example
  256. $ ffmpeg -f openal -i '' out.ogg
  257. @end example
  258. Capture from two devices simultaneously, writing to two different files,
  259. within the same @file{ffmpeg} command:
  260. @example
  261. $ ffmpeg -f openal -i 'DR-BT101 via PulseAudio' out1.ogg -f openal -i 'ALSA Default' out2.ogg
  262. @end example
  263. Note: not all OpenAL implementations support multiple simultaneous capture -
  264. try the latest OpenAL Soft if the above does not work.
  265. @section oss
  266. Open Sound System input device.
  267. The filename to provide to the input device is the device node
  268. representing the OSS input device, and is usually set to
  269. @file{/dev/dsp}.
  270. For example to grab from @file{/dev/dsp} using @file{ffmpeg} use the
  271. command:
  272. @example
  273. ffmpeg -f oss -i /dev/dsp /tmp/oss.wav
  274. @end example
  275. For more information about OSS see:
  276. @url{http://manuals.opensound.com/usersguide/dsp.html}
  277. @section sndio
  278. sndio input device.
  279. To enable this input device during configuration you need libsndio
  280. installed on your system.
  281. The filename to provide to the input device is the device node
  282. representing the sndio input device, and is usually set to
  283. @file{/dev/audio0}.
  284. For example to grab from @file{/dev/audio0} using @file{ffmpeg} use the
  285. command:
  286. @example
  287. ffmpeg -f sndio -i /dev/audio0 /tmp/oss.wav
  288. @end example
  289. @section video4linux and video4linux2
  290. Video4Linux and Video4Linux2 input video devices.
  291. The name of the device to grab is a file device node, usually Linux
  292. systems tend to automatically create such nodes when the device
  293. (e.g. an USB webcam) is plugged into the system, and has a name of the
  294. kind @file{/dev/video@var{N}}, where @var{N} is a number associated to
  295. the device.
  296. Video4Linux and Video4Linux2 devices only support a limited set of
  297. @var{width}x@var{height} sizes and framerates. You can check which are
  298. supported for example with the command @file{dov4l} for Video4Linux
  299. devices and the command @file{v4l-info} for Video4Linux2 devices.
  300. If the size for the device is set to 0x0, the input device will
  301. try to autodetect the size to use.
  302. Only for the video4linux2 device, if the frame rate is set to 0/0 the
  303. input device will use the frame rate value already set in the driver.
  304. Video4Linux support is deprecated since Linux 2.6.30, and will be
  305. dropped in later versions.
  306. Follow some usage examples of the video4linux devices with the ff*
  307. tools.
  308. @example
  309. # Grab and show the input of a video4linux device, frame rate is set
  310. # to the default of 25/1.
  311. ffplay -s 320x240 -f video4linux /dev/video0
  312. # Grab and show the input of a video4linux2 device, autoadjust size.
  313. ffplay -f video4linux2 /dev/video0
  314. # Grab and record the input of a video4linux2 device, autoadjust size,
  315. # frame rate value defaults to 0/0 so it is read from the video4linux2
  316. # driver.
  317. ffmpeg -f video4linux2 -i /dev/video0 out.mpeg
  318. @end example
  319. @section vfwcap
  320. VfW (Video for Windows) capture input device.
  321. The filename passed as input is the capture driver number, ranging from
  322. 0 to 9. You may use "list" as filename to print a list of drivers. Any
  323. other filename will be interpreted as device number 0.
  324. @section x11grab
  325. X11 video input device.
  326. This device allows to capture a region of an X11 display.
  327. The filename passed as input has the syntax:
  328. @example
  329. [@var{hostname}]:@var{display_number}.@var{screen_number}[+@var{x_offset},@var{y_offset}]
  330. @end example
  331. @var{hostname}:@var{display_number}.@var{screen_number} specifies the
  332. X11 display name of the screen to grab from. @var{hostname} can be
  333. ommitted, and defaults to "localhost". The environment variable
  334. @env{DISPLAY} contains the default display name.
  335. @var{x_offset} and @var{y_offset} specify the offsets of the grabbed
  336. area with respect to the top-left border of the X11 screen. They
  337. default to 0.
  338. Check the X11 documentation (e.g. man X) for more detailed information.
  339. Use the @file{dpyinfo} program for getting basic information about the
  340. properties of your X11 display (e.g. grep for "name" or "dimensions").
  341. For example to grab from @file{:0.0} using @file{ffmpeg}:
  342. @example
  343. ffmpeg -f x11grab -r 25 -s cif -i :0.0 out.mpg
  344. # Grab at position 10,20.
  345. ffmpeg -f x11grab -r 25 -s cif -i :0.0+10,20 out.mpg
  346. @end example
  347. @subsection @var{follow_mouse} AVOption
  348. The syntax is:
  349. @example
  350. -follow_mouse centered|@var{PIXELS}
  351. @end example
  352. When it is specified with "centered", the grabbing region follows the mouse
  353. pointer and keeps the pointer at the center of region; otherwise, the region
  354. follows only when the mouse pointer reaches within @var{PIXELS} (greater than
  355. zero) to the edge of region.
  356. For example:
  357. @example
  358. ffmpeg -f x11grab -follow_mouse centered -r 25 -s cif -i :0.0 out.mpg
  359. # Follows only when the mouse pointer reaches within 100 pixels to edge
  360. ffmpeg -f x11grab -follow_mouse 100 -r 25 -s cif -i :0.0 out.mpg
  361. @end example
  362. @subsection @var{show_region} AVOption
  363. The syntax is:
  364. @example
  365. -show_region 1
  366. @end example
  367. If @var{show_region} AVOption is specified with @var{1}, then the grabbing
  368. region will be indicated on screen. With this option, it's easy to know what is
  369. being grabbed if only a portion of the screen is grabbed.
  370. For example:
  371. @example
  372. ffmpeg -f x11grab -show_region 1 -r 25 -s cif -i :0.0+10,20 out.mpg
  373. # With follow_mouse
  374. ffmpeg -f x11grab -follow_mouse centered -show_region 1 -r 25 -s cif -i :0.0 out.mpg
  375. @end example
  376. @c man end INPUT DEVICES