indevs.texi 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624
  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 @command{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 the mingw-w64 project.
  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. @command{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 -frames:v 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 @command{jack_connect}
  140. and @command{jack_disconnect} programs, or do it through a graphical interface,
  141. for example with @command{qjackctl}.
  142. To list the JACK clients and their properties you can invoke the command
  143. @command{jack_lsp}.
  144. Follows an example which shows how to capture a JACK readable client
  145. with @command{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 @command{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 @command{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. @command{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 @command{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 @command{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 @command{pactl list sources}.
  306. @example
  307. ffmpeg -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 the LIBAVFORMAT_IDENT string
  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 @command{ffmpeg} use the
  362. command:
  363. @example
  364. ffmpeg -f sndio -i /dev/audio0 /tmp/oss.wav
  365. @end example
  366. @section video4linux2
  367. Video4Linux2 input video device.
  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. Video4Linux2 devices usually support a limited set of
  374. @var{width}x@var{height} sizes and framerates. You can check which are
  375. supported using @command{-list_formats all} for Video4Linux2 devices.
  376. Some usage examples of the video4linux2 devices with ffmpeg and ffplay:
  377. The time base for the timestamps is 1 microsecond. Depending on the kernel
  378. version and configuration, the timestamps may be derived from the real time
  379. clock (origin at the Unix Epoch) or the monotonic clock (origin usually at
  380. boot time, unaffected by NTP or manual changes to the clock). The
  381. @option{-timestamps abs} or @option{-ts abs} option can be used to force
  382. conversion into the real time clock.
  383. Note that if FFmpeg is build with v4l-utils support ("--enable-libv4l2"
  384. option), it will always be used.
  385. @example
  386. # Grab and show the input of a video4linux2 device.
  387. ffplay -f video4linux2 -framerate 30 -video_size hd720 /dev/video0
  388. # Grab and record the input of a video4linux2 device, leave the
  389. framerate and size as previously set.
  390. ffmpeg -f video4linux2 -input_format mjpeg -i /dev/video0 out.mpeg
  391. @end example
  392. "v4l" and "v4l2" can be used as aliases for the respective "video4linux" and
  393. "video4linux2".
  394. @section vfwcap
  395. VfW (Video for Windows) capture input device.
  396. The filename passed as input is the capture driver number, ranging from
  397. 0 to 9. You may use "list" as filename to print a list of drivers. Any
  398. other filename will be interpreted as device number 0.
  399. @section x11grab
  400. X11 video input device.
  401. This device allows to capture a region of an X11 display.
  402. The filename passed as input has the syntax:
  403. @example
  404. [@var{hostname}]:@var{display_number}.@var{screen_number}[+@var{x_offset},@var{y_offset}]
  405. @end example
  406. @var{hostname}:@var{display_number}.@var{screen_number} specifies the
  407. X11 display name of the screen to grab from. @var{hostname} can be
  408. omitted, and defaults to "localhost". The environment variable
  409. @env{DISPLAY} contains the default display name.
  410. @var{x_offset} and @var{y_offset} specify the offsets of the grabbed
  411. area with respect to the top-left border of the X11 screen. They
  412. default to 0.
  413. Check the X11 documentation (e.g. man X) for more detailed information.
  414. Use the @command{dpyinfo} program for getting basic information about the
  415. properties of your X11 display (e.g. grep for "name" or "dimensions").
  416. For example to grab from @file{:0.0} using @command{ffmpeg}:
  417. @example
  418. ffmpeg -f x11grab -r 25 -s cif -i :0.0 out.mpg
  419. # Grab at position 10,20.
  420. ffmpeg -f x11grab -r 25 -s cif -i :0.0+10,20 out.mpg
  421. @end example
  422. @subsection @var{follow_mouse} AVOption
  423. The syntax is:
  424. @example
  425. -follow_mouse centered|@var{PIXELS}
  426. @end example
  427. When it is specified with "centered", the grabbing region follows the mouse
  428. pointer and keeps the pointer at the center of region; otherwise, the region
  429. follows only when the mouse pointer reaches within @var{PIXELS} (greater than
  430. zero) to the edge of region.
  431. For example:
  432. @example
  433. ffmpeg -f x11grab -follow_mouse centered -r 25 -s cif -i :0.0 out.mpg
  434. # Follows only when the mouse pointer reaches within 100 pixels to edge
  435. ffmpeg -f x11grab -follow_mouse 100 -r 25 -s cif -i :0.0 out.mpg
  436. @end example
  437. @subsection @var{show_region} AVOption
  438. The syntax is:
  439. @example
  440. -show_region 1
  441. @end example
  442. If @var{show_region} AVOption is specified with @var{1}, then the grabbing
  443. region will be indicated on screen. With this option, it's easy to know what is
  444. being grabbed if only a portion of the screen is grabbed.
  445. For example:
  446. @example
  447. ffmpeg -f x11grab -show_region 1 -r 25 -s cif -i :0.0+10,20 out.mpg
  448. # With follow_mouse
  449. ffmpeg -f x11grab -follow_mouse centered -show_region 1 -r 25 -s cif -i :0.0 out.mpg
  450. @end example
  451. @c man end INPUT DEVICES