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.

701 lines
19KB

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