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.

674 lines
18KB

  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 iec61883
  128. FireWire DV/HDV input device using libiec61883.
  129. The iec61883 capture device supports capturing from a video device
  130. connected via IEEE1394 (FireWire), using libiec61883 and the new Linux
  131. FireWire stack (juju). This is the default DV/HDV input method in Linux
  132. Kernel 2.6.37 and later, since the old FireWire stack was removed.
  133. Specify the FireWire port to be used as input file, or "auto"
  134. to choose the first port connected.
  135. @subsection Options
  136. @table @option
  137. @item dvtype
  138. Override autodetection of DV/HDV. This should only be used if auto
  139. detection does not work, or if usage of a different device type
  140. should be prohibited. Treating a DV device as HDV (or vice versa) will
  141. not work and result in undefined behavior.
  142. The values @option{auto}, @option{dv} and @option{hdv} are supported.
  143. @item dvbuffer
  144. Set maxiumum size of buffer for incoming data, in frames. For DV, this
  145. is an exact value. For HDV, it is not frame exact, since HDV does
  146. not have a fixed frame size.
  147. @end table
  148. @subsection Examples
  149. @itemize
  150. @item
  151. Grab and show the input of a FireWire DV/HDV device.
  152. @example
  153. ffplay -f iec61883 -i auto
  154. @end example
  155. @item
  156. Grab and record the input of a FireWire DV/HDV device,
  157. using a packet buffer of 100000 packets if the source is HDV.
  158. @example
  159. ffmpeg -f iec61883 -i auto -hdvbuffer 100000 out.mpg
  160. @end example
  161. @end itemize
  162. @section jack
  163. JACK input device.
  164. To enable this input device during configuration you need libjack
  165. installed on your system.
  166. A JACK input device creates one or more JACK writable clients, one for
  167. each audio channel, with name @var{client_name}:input_@var{N}, where
  168. @var{client_name} is the name provided by the application, and @var{N}
  169. is a number which identifies the channel.
  170. Each writable client will send the acquired data to the FFmpeg input
  171. device.
  172. Once you have created one or more JACK readable clients, you need to
  173. connect them to one or more JACK writable clients.
  174. To connect or disconnect JACK clients you can use the @command{jack_connect}
  175. and @command{jack_disconnect} programs, or do it through a graphical interface,
  176. for example with @command{qjackctl}.
  177. To list the JACK clients and their properties you can invoke the command
  178. @command{jack_lsp}.
  179. Follows an example which shows how to capture a JACK readable client
  180. with @command{ffmpeg}.
  181. @example
  182. # Create a JACK writable client with name "ffmpeg".
  183. $ ffmpeg -f jack -i ffmpeg -y out.wav
  184. # Start the sample jack_metro readable client.
  185. $ jack_metro -b 120 -d 0.2 -f 4000
  186. # List the current JACK clients.
  187. $ jack_lsp -c
  188. system:capture_1
  189. system:capture_2
  190. system:playback_1
  191. system:playback_2
  192. ffmpeg:input_1
  193. metro:120_bpm
  194. # Connect metro to the ffmpeg writable client.
  195. $ jack_connect metro:120_bpm ffmpeg:input_1
  196. @end example
  197. For more information read:
  198. @url{http://jackaudio.org/}
  199. @section lavfi
  200. Libavfilter input virtual device.
  201. This input device reads data from the open output pads of a libavfilter
  202. filtergraph.
  203. For each filtergraph open output, the input device will create a
  204. corresponding stream which is mapped to the generated output. Currently
  205. only video data is supported. The filtergraph is specified through the
  206. option @option{graph}.
  207. @subsection Options
  208. @table @option
  209. @item graph
  210. Specify the filtergraph to use as input. Each video open output must be
  211. labelled by a unique string of the form "out@var{N}", where @var{N} is a
  212. number starting from 0 corresponding to the mapped input stream
  213. generated by the device.
  214. The first unlabelled output is automatically assigned to the "out0"
  215. label, but all the others need to be specified explicitly.
  216. If not specified defaults to the filename specified for the input
  217. device.
  218. @end table
  219. @subsection Examples
  220. @itemize
  221. @item
  222. Create a color video stream and play it back with @command{ffplay}:
  223. @example
  224. ffplay -f lavfi -graph "color=pink [out0]" dummy
  225. @end example
  226. @item
  227. As the previous example, but use filename for specifying the graph
  228. description, and omit the "out0" label:
  229. @example
  230. ffplay -f lavfi color=pink
  231. @end example
  232. @item
  233. Create three different video test filtered sources and play them:
  234. @example
  235. ffplay -f lavfi -graph "testsrc [out0]; testsrc,hflip [out1]; testsrc,negate [out2]" test3
  236. @end example
  237. @item
  238. Read an audio stream from a file using the amovie source and play it
  239. back with @command{ffplay}:
  240. @example
  241. ffplay -f lavfi "amovie=test.wav"
  242. @end example
  243. @item
  244. Read an audio stream and a video stream and play it back with
  245. @command{ffplay}:
  246. @example
  247. ffplay -f lavfi "movie=test.avi[out0];amovie=test.wav[out1]"
  248. @end example
  249. @end itemize
  250. @section libdc1394
  251. IIDC1394 input device, based on libdc1394 and libraw1394.
  252. @section openal
  253. The OpenAL input device provides audio capture on all systems with a
  254. working OpenAL 1.1 implementation.
  255. To enable this input device during configuration, you need OpenAL
  256. headers and libraries installed on your system, and need to configure
  257. FFmpeg with @code{--enable-openal}.
  258. OpenAL headers and libraries should be provided as part of your OpenAL
  259. implementation, or as an additional download (an SDK). Depending on your
  260. installation you may need to specify additional flags via the
  261. @code{--extra-cflags} and @code{--extra-ldflags} for allowing the build
  262. system to locate the OpenAL headers and libraries.
  263. An incomplete list of OpenAL implementations follows:
  264. @table @strong
  265. @item Creative
  266. The official Windows implementation, providing hardware acceleration
  267. with supported devices and software fallback.
  268. See @url{http://openal.org/}.
  269. @item OpenAL Soft
  270. Portable, open source (LGPL) software implementation. Includes
  271. backends for the most common sound APIs on the Windows, Linux,
  272. Solaris, and BSD operating systems.
  273. See @url{http://kcat.strangesoft.net/openal.html}.
  274. @item Apple
  275. OpenAL is part of Core Audio, the official Mac OS X Audio interface.
  276. See @url{http://developer.apple.com/technologies/mac/audio-and-video.html}
  277. @end table
  278. This device allows to capture from an audio input device handled
  279. through OpenAL.
  280. You need to specify the name of the device to capture in the provided
  281. filename. If the empty string is provided, the device will
  282. automatically select the default device. You can get the list of the
  283. supported devices by using the option @var{list_devices}.
  284. @subsection Options
  285. @table @option
  286. @item channels
  287. Set the number of channels in the captured audio. Only the values
  288. @option{1} (monaural) and @option{2} (stereo) are currently supported.
  289. Defaults to @option{2}.
  290. @item sample_size
  291. Set the sample size (in bits) of the captured audio. Only the values
  292. @option{8} and @option{16} are currently supported. Defaults to
  293. @option{16}.
  294. @item sample_rate
  295. Set the sample rate (in Hz) of the captured audio.
  296. Defaults to @option{44.1k}.
  297. @item list_devices
  298. If set to @option{true}, print a list of devices and exit.
  299. Defaults to @option{false}.
  300. @end table
  301. @subsection Examples
  302. Print the list of OpenAL supported devices and exit:
  303. @example
  304. $ ffmpeg -list_devices true -f openal -i dummy out.ogg
  305. @end example
  306. Capture from the OpenAL device @file{DR-BT101 via PulseAudio}:
  307. @example
  308. $ ffmpeg -f openal -i 'DR-BT101 via PulseAudio' out.ogg
  309. @end example
  310. Capture from the default device (note the empty string '' as filename):
  311. @example
  312. $ ffmpeg -f openal -i '' out.ogg
  313. @end example
  314. Capture from two devices simultaneously, writing to two different files,
  315. within the same @command{ffmpeg} command:
  316. @example
  317. $ ffmpeg -f openal -i 'DR-BT101 via PulseAudio' out1.ogg -f openal -i 'ALSA Default' out2.ogg
  318. @end example
  319. Note: not all OpenAL implementations support multiple simultaneous capture -
  320. try the latest OpenAL Soft if the above does not work.
  321. @section oss
  322. Open Sound System input device.
  323. The filename to provide to the input device is the device node
  324. representing the OSS input device, and is usually set to
  325. @file{/dev/dsp}.
  326. For example to grab from @file{/dev/dsp} using @command{ffmpeg} use the
  327. command:
  328. @example
  329. ffmpeg -f oss -i /dev/dsp /tmp/oss.wav
  330. @end example
  331. For more information about OSS see:
  332. @url{http://manuals.opensound.com/usersguide/dsp.html}
  333. @section pulse
  334. pulseaudio input device.
  335. To enable this input device during configuration you need libpulse-simple
  336. installed in your system.
  337. The filename to provide to the input device is a source device or the
  338. string "default"
  339. To list the pulse source devices and their properties you can invoke
  340. the command @command{pactl list sources}.
  341. @example
  342. ffmpeg -f pulse -i default /tmp/pulse.wav
  343. @end example
  344. @subsection @var{server} AVOption
  345. The syntax is:
  346. @example
  347. -server @var{server name}
  348. @end example
  349. Connects to a specific server.
  350. @subsection @var{name} AVOption
  351. The syntax is:
  352. @example
  353. -name @var{application name}
  354. @end example
  355. Specify the application name pulse will use when showing active clients,
  356. by default it is the LIBAVFORMAT_IDENT string
  357. @subsection @var{stream_name} AVOption
  358. The syntax is:
  359. @example
  360. -stream_name @var{stream name}
  361. @end example
  362. Specify the stream name pulse will use when showing active streams,
  363. by default it is "record"
  364. @subsection @var{sample_rate} AVOption
  365. The syntax is:
  366. @example
  367. -sample_rate @var{samplerate}
  368. @end example
  369. Specify the samplerate in Hz, by default 48kHz is used.
  370. @subsection @var{channels} AVOption
  371. The syntax is:
  372. @example
  373. -channels @var{N}
  374. @end example
  375. Specify the channels in use, by default 2 (stereo) is set.
  376. @subsection @var{frame_size} AVOption
  377. The syntax is:
  378. @example
  379. -frame_size @var{bytes}
  380. @end example
  381. Specify the number of byte per frame, by default it is set to 1024.
  382. @subsection @var{fragment_size} AVOption
  383. The syntax is:
  384. @example
  385. -fragment_size @var{bytes}
  386. @end example
  387. Specify the minimal buffering fragment in pulseaudio, it will affect the
  388. audio latency. By default it is unset.
  389. @section sndio
  390. sndio input device.
  391. To enable this input device during configuration you need libsndio
  392. installed on your system.
  393. The filename to provide to the input device is the device node
  394. representing the sndio input device, and is usually set to
  395. @file{/dev/audio0}.
  396. For example to grab from @file{/dev/audio0} using @command{ffmpeg} use the
  397. command:
  398. @example
  399. ffmpeg -f sndio -i /dev/audio0 /tmp/oss.wav
  400. @end example
  401. @section video4linux2
  402. Video4Linux2 input video device.
  403. The name of the device to grab is a file device node, usually Linux
  404. systems tend to automatically create such nodes when the device
  405. (e.g. an USB webcam) is plugged into the system, and has a name of the
  406. kind @file{/dev/video@var{N}}, where @var{N} is a number associated to
  407. the device.
  408. Video4Linux2 devices usually support a limited set of
  409. @var{width}x@var{height} sizes and framerates. You can check which are
  410. supported using @command{-list_formats all} for Video4Linux2 devices.
  411. Some usage examples of the video4linux2 devices with ffmpeg and ffplay:
  412. The time base for the timestamps is 1 microsecond. Depending on the kernel
  413. version and configuration, the timestamps may be derived from the real time
  414. clock (origin at the Unix Epoch) or the monotonic clock (origin usually at
  415. boot time, unaffected by NTP or manual changes to the clock). The
  416. @option{-timestamps abs} or @option{-ts abs} option can be used to force
  417. conversion into the real time clock.
  418. Note that if FFmpeg is build with v4l-utils support ("--enable-libv4l2"
  419. option), it will always be used.
  420. @example
  421. # Grab and show the input of a video4linux2 device.
  422. ffplay -f video4linux2 -framerate 30 -video_size hd720 /dev/video0
  423. # Grab and record the input of a video4linux2 device, leave the
  424. framerate and size as previously set.
  425. ffmpeg -f video4linux2 -input_format mjpeg -i /dev/video0 out.mpeg
  426. @end example
  427. "v4l" and "v4l2" can be used as aliases for the respective "video4linux" and
  428. "video4linux2".
  429. @section vfwcap
  430. VfW (Video for Windows) capture input device.
  431. The filename passed as input is the capture driver number, ranging from
  432. 0 to 9. You may use "list" as filename to print a list of drivers. Any
  433. other filename will be interpreted as device number 0.
  434. @section x11grab
  435. X11 video input device.
  436. This device allows to capture a region of an X11 display.
  437. The filename passed as input has the syntax:
  438. @example
  439. [@var{hostname}]:@var{display_number}.@var{screen_number}[+@var{x_offset},@var{y_offset}]
  440. @end example
  441. @var{hostname}:@var{display_number}.@var{screen_number} specifies the
  442. X11 display name of the screen to grab from. @var{hostname} can be
  443. omitted, and defaults to "localhost". The environment variable
  444. @env{DISPLAY} contains the default display name.
  445. @var{x_offset} and @var{y_offset} specify the offsets of the grabbed
  446. area with respect to the top-left border of the X11 screen. They
  447. default to 0.
  448. Check the X11 documentation (e.g. man X) for more detailed information.
  449. Use the @command{dpyinfo} program for getting basic information about the
  450. properties of your X11 display (e.g. grep for "name" or "dimensions").
  451. For example to grab from @file{:0.0} using @command{ffmpeg}:
  452. @example
  453. ffmpeg -f x11grab -r 25 -s cif -i :0.0 out.mpg
  454. # Grab at position 10,20.
  455. ffmpeg -f x11grab -r 25 -s cif -i :0.0+10,20 out.mpg
  456. @end example
  457. @subsection @var{follow_mouse} AVOption
  458. The syntax is:
  459. @example
  460. -follow_mouse centered|@var{PIXELS}
  461. @end example
  462. When it is specified with "centered", the grabbing region follows the mouse
  463. pointer and keeps the pointer at the center of region; otherwise, the region
  464. follows only when the mouse pointer reaches within @var{PIXELS} (greater than
  465. zero) to the edge of region.
  466. For example:
  467. @example
  468. ffmpeg -f x11grab -follow_mouse centered -r 25 -s cif -i :0.0 out.mpg
  469. # Follows only when the mouse pointer reaches within 100 pixels to edge
  470. ffmpeg -f x11grab -follow_mouse 100 -r 25 -s cif -i :0.0 out.mpg
  471. @end example
  472. @subsection @var{show_region} AVOption
  473. The syntax is:
  474. @example
  475. -show_region 1
  476. @end example
  477. If @var{show_region} AVOption is specified with @var{1}, then the grabbing
  478. region will be indicated on screen. With this option, it's easy to know what is
  479. being grabbed if only a portion of the screen is grabbed.
  480. For example:
  481. @example
  482. ffmpeg -f x11grab -show_region 1 -r 25 -s cif -i :0.0+10,20 out.mpg
  483. # With follow_mouse
  484. ffmpeg -f x11grab -follow_mouse centered -show_region 1 -r 25 -s cif -i :0.0 out.mpg
  485. @end example
  486. @c man end INPUT DEVICES