indevs.texi 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382
  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 libdc1394
  98. IIDC1394 input device, based on libdc1394 and libraw1394.
  99. @section openal
  100. The OpenAL input device provides audio capture on all systems with a
  101. working OpenAL 1.1 implementation.
  102. To enable this input device during configuration, you need OpenAL
  103. headers and libraries installed on your system, and need to configure
  104. FFmpeg with @code{--enable-openal}.
  105. OpenAL headers and libraries should be provided as part of your OpenAL
  106. implementation, or as an additional download (an SDK). Depending on your
  107. installation you may need to specify additional flags via the
  108. @code{--extra-cflags} and @code{--extra-ldflags} for allowing the build
  109. system to locate the OpenAL headers and libraries.
  110. An incomplete list of OpenAL implementations follows:
  111. @table @strong
  112. @item Creative
  113. The official Windows implementation, providing hardware acceleration
  114. with supported devices and software fallback.
  115. See @url{http://openal.org/}.
  116. @item OpenAL Soft
  117. Portable, open source (LGPL) software implementation. Includes
  118. backends for the most common sound APIs on the Windows, Linux,
  119. Solaris, and BSD operating systems.
  120. See @url{http://kcat.strangesoft.net/openal.html}.
  121. @item Apple
  122. OpenAL is part of Core Audio, the official Mac OS X Audio interface.
  123. See @url{http://developer.apple.com/technologies/mac/audio-and-video.html}
  124. @end table
  125. This device allows to capture from an audio input device handled
  126. through OpenAL.
  127. You need to specify the name of the device to capture in the provided
  128. filename. If the empty string is provided, the device will
  129. automatically select the default device. You can get the list of the
  130. supported devices by using the option @var{list_devices}.
  131. @subsection Options
  132. @table @option
  133. @item channels
  134. Set the number of channels in the captured audio. Only the values
  135. @option{1} (monaural) and @option{2} (stereo) are currently supported.
  136. Defaults to @option{2}.
  137. @item sample_size
  138. Set the sample size (in bits) of the captured audio. Only the values
  139. @option{8} and @option{16} are currently supported. Defaults to
  140. @option{16}.
  141. @item sample_rate
  142. Set the sample rate (in Hz) of the captured audio.
  143. Defaults to @option{44.1k}.
  144. @item list_devices
  145. If set to @option{true}, print a list of devices and exit.
  146. Defaults to @option{false}.
  147. @end table
  148. @subsection Examples
  149. Print the list of OpenAL supported devices and exit:
  150. @example
  151. $ ffmpeg -list_devices true -f openal -i dummy out.ogg
  152. @end example
  153. Capture from the OpenAL device @file{DR-BT101 via PulseAudio}:
  154. @example
  155. $ ffmpeg -f openal -i 'DR-BT101 via PulseAudio' out.ogg
  156. @end example
  157. Capture from the default device (note the empty string '' as filename):
  158. @example
  159. $ ffmpeg -f openal -i '' out.ogg
  160. @end example
  161. Capture from two devices simultaneously, writing to two different files,
  162. within the same @file{ffmpeg} command:
  163. @example
  164. $ ffmpeg -f openal -i 'DR-BT101 via PulseAudio' out1.ogg -f openal -i 'ALSA Default' out2.ogg
  165. @end example
  166. Note: not all OpenAL implementations support multiple simultaneous capture -
  167. try the latest OpenAL Soft if the above does not work.
  168. @section oss
  169. Open Sound System input device.
  170. The filename to provide to the input device is the device node
  171. representing the OSS input device, and is usually set to
  172. @file{/dev/dsp}.
  173. For example to grab from @file{/dev/dsp} using @file{ffmpeg} use the
  174. command:
  175. @example
  176. ffmpeg -f oss -i /dev/dsp /tmp/oss.wav
  177. @end example
  178. For more information about OSS see:
  179. @url{http://manuals.opensound.com/usersguide/dsp.html}
  180. @section sndio
  181. sndio input device.
  182. To enable this input device during configuration you need libsndio
  183. installed on your system.
  184. The filename to provide to the input device is the device node
  185. representing the sndio input device, and is usually set to
  186. @file{/dev/audio0}.
  187. For example to grab from @file{/dev/audio0} using @file{ffmpeg} use the
  188. command:
  189. @example
  190. ffmpeg -f sndio -i /dev/audio0 /tmp/oss.wav
  191. @end example
  192. @section video4linux and video4linux2
  193. Video4Linux and Video4Linux2 input video devices.
  194. The name of the device to grab is a file device node, usually Linux
  195. systems tend to automatically create such nodes when the device
  196. (e.g. an USB webcam) is plugged into the system, and has a name of the
  197. kind @file{/dev/video@var{N}}, where @var{N} is a number associated to
  198. the device.
  199. Video4Linux and Video4Linux2 devices only support a limited set of
  200. @var{width}x@var{height} sizes and framerates. You can check which are
  201. supported for example with the command @file{dov4l} for Video4Linux
  202. devices and the command @file{v4l-info} for Video4Linux2 devices.
  203. If the size for the device is set to 0x0, the input device will
  204. try to autodetect the size to use.
  205. Only for the video4linux2 device, if the frame rate is set to 0/0 the
  206. input device will use the frame rate value already set in the driver.
  207. Video4Linux support is deprecated since Linux 2.6.30, and will be
  208. dropped in later versions.
  209. Follow some usage examples of the video4linux devices with the ff*
  210. tools.
  211. @example
  212. # Grab and show the input of a video4linux device, frame rate is set
  213. # to the default of 25/1.
  214. ffplay -s 320x240 -f video4linux /dev/video0
  215. # Grab and show the input of a video4linux2 device, autoadjust size.
  216. ffplay -f video4linux2 /dev/video0
  217. # Grab and record the input of a video4linux2 device, autoadjust size,
  218. # frame rate value defaults to 0/0 so it is read from the video4linux2
  219. # driver.
  220. ffmpeg -f video4linux2 -i /dev/video0 out.mpeg
  221. @end example
  222. @section vfwcap
  223. VfW (Video for Windows) capture input device.
  224. The filename passed as input is the capture driver number, ranging from
  225. 0 to 9. You may use "list" as filename to print a list of drivers. Any
  226. other filename will be interpreted as device number 0.
  227. @section x11grab
  228. X11 video input device.
  229. This device allows to capture a region of an X11 display.
  230. The filename passed as input has the syntax:
  231. @example
  232. [@var{hostname}]:@var{display_number}.@var{screen_number}[+@var{x_offset},@var{y_offset}]
  233. @end example
  234. @var{hostname}:@var{display_number}.@var{screen_number} specifies the
  235. X11 display name of the screen to grab from. @var{hostname} can be
  236. ommitted, and defaults to "localhost". The environment variable
  237. @env{DISPLAY} contains the default display name.
  238. @var{x_offset} and @var{y_offset} specify the offsets of the grabbed
  239. area with respect to the top-left border of the X11 screen. They
  240. default to 0.
  241. Check the X11 documentation (e.g. man X) for more detailed information.
  242. Use the @file{dpyinfo} program for getting basic information about the
  243. properties of your X11 display (e.g. grep for "name" or "dimensions").
  244. For example to grab from @file{:0.0} using @file{ffmpeg}:
  245. @example
  246. ffmpeg -f x11grab -r 25 -s cif -i :0.0 out.mpg
  247. # Grab at position 10,20.
  248. ffmpeg -f x11grab -r 25 -s cif -i :0.0+10,20 out.mpg
  249. @end example
  250. @subsection @var{follow_mouse} AVOption
  251. The syntax is:
  252. @example
  253. -follow_mouse centered|@var{PIXELS}
  254. @end example
  255. When it is specified with "centered", the grabbing region follows the mouse
  256. pointer and keeps the pointer at the center of region; otherwise, the region
  257. follows only when the mouse pointer reaches within @var{PIXELS} (greater than
  258. zero) to the edge of region.
  259. For example:
  260. @example
  261. ffmpeg -f x11grab -follow_mouse centered -r 25 -s cif -i :0.0 out.mpg
  262. # Follows only when the mouse pointer reaches within 100 pixels to edge
  263. ffmpeg -f x11grab -follow_mouse 100 -r 25 -s cif -i :0.0 out.mpg
  264. @end example
  265. @subsection @var{show_region} AVOption
  266. The syntax is:
  267. @example
  268. -show_region 1
  269. @end example
  270. If @var{show_region} AVOption is specified with @var{1}, then the grabbing
  271. region will be indicated on screen. With this option, it's easy to know what is
  272. being grabbed if only a portion of the screen is grabbed.
  273. For example:
  274. @example
  275. ffmpeg -f x11grab -show_region 1 -r 25 -s cif -i :0.0+10,20 out.mpg
  276. # With follow_mouse
  277. ffmpeg -f x11grab -follow_mouse centered -show_region 1 -r 25 -s cif -i :0.0 out.mpg
  278. @end example
  279. @c man end INPUT DEVICES