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.

437 lines
13KB

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