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.

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