indevs.texi 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925
  1. @chapter Input Devices
  2. @c man begin INPUT DEVICES
  3. Input devices are configured elements in FFmpeg which enable accessing
  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 "-devices" of the ff* tools will display the list of
  13. supported input devices.
  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 avfoundation
  39. AVFoundation input device.
  40. AVFoundation is the currently recommended framework by Apple for streamgrabbing on OSX >= 10.7 as well as on iOS.
  41. The older QTKit framework has been marked deprecated since OSX version 10.7.
  42. The filename passed as input is parsed to contain either a device name or index.
  43. The device index can also be given by using -video_device_index.
  44. A given device index will override any given device name.
  45. If the desired device consists of numbers only, use -video_device_index to identify it.
  46. The default device will be chosen if an empty string or the device name "default" is given.
  47. The available devices can be enumerated by using -list_devices.
  48. The pixel format can be set using -pixel_format.
  49. Available formats:
  50. monob, rgb555be, rgb555le, rgb565be, rgb565le, rgb24, bgr24, 0rgb, bgr0, 0bgr, rgb0,
  51. bgr48be, uyvy422, yuva444p, yuva444p16le, yuv444p, yuv422p16, yuv422p10, yuv444p10,
  52. yuv420p, nv12, yuyv422, gray
  53. @example
  54. ffmpeg -f avfoundation -i "0" out.mpg
  55. @end example
  56. @example
  57. ffmpeg -f avfoundation -video_device_index 0 -i "" out.mpg
  58. @end example
  59. @example
  60. ffmpeg -f avfoundation -pixel_format bgr0 -i "default" out.mpg
  61. @end example
  62. @example
  63. ffmpeg -f avfoundation -list_devices true -i ""
  64. @end example
  65. @section bktr
  66. BSD video input device.
  67. @section dshow
  68. Windows DirectShow input device.
  69. DirectShow support is enabled when FFmpeg is built with the mingw-w64 project.
  70. Currently only audio and video devices are supported.
  71. Multiple devices may be opened as separate inputs, but they may also be
  72. opened on the same input, which should improve synchronism between them.
  73. The input name should be in the format:
  74. @example
  75. @var{TYPE}=@var{NAME}[:@var{TYPE}=@var{NAME}]
  76. @end example
  77. where @var{TYPE} can be either @var{audio} or @var{video},
  78. and @var{NAME} is the device's name.
  79. @subsection Options
  80. If no options are specified, the device's defaults are used.
  81. If the device does not support the requested options, it will
  82. fail to open.
  83. @table @option
  84. @item video_size
  85. Set the video size in the captured video.
  86. @item framerate
  87. Set the frame rate in the captured video.
  88. @item sample_rate
  89. Set the sample rate (in Hz) of the captured audio.
  90. @item sample_size
  91. Set the sample size (in bits) of the captured audio.
  92. @item channels
  93. Set the number of channels in the captured audio.
  94. @item list_devices
  95. If set to @option{true}, print a list of devices and exit.
  96. @item list_options
  97. If set to @option{true}, print a list of selected device's options
  98. and exit.
  99. @item video_device_number
  100. Set video device number for devices with same name (starts at 0,
  101. defaults to 0).
  102. @item audio_device_number
  103. Set audio device number for devices with same name (starts at 0,
  104. defaults to 0).
  105. @item pixel_format
  106. Select pixel format to be used by DirectShow. This may only be set when
  107. the video codec is not set or set to rawvideo.
  108. @item audio_buffer_size
  109. Set audio device buffer size in milliseconds (which can directly
  110. impact latency, depending on the device).
  111. Defaults to using the audio device's
  112. default buffer size (typically some multiple of 500ms).
  113. Setting this value too low can degrade performance.
  114. See also
  115. @url{http://msdn.microsoft.com/en-us/library/windows/desktop/dd377582(v=vs.85).aspx}
  116. @end table
  117. @subsection Examples
  118. @itemize
  119. @item
  120. Print the list of DirectShow supported devices and exit:
  121. @example
  122. $ ffmpeg -list_devices true -f dshow -i dummy
  123. @end example
  124. @item
  125. Open video device @var{Camera}:
  126. @example
  127. $ ffmpeg -f dshow -i video="Camera"
  128. @end example
  129. @item
  130. Open second video device with name @var{Camera}:
  131. @example
  132. $ ffmpeg -f dshow -video_device_number 1 -i video="Camera"
  133. @end example
  134. @item
  135. Open video device @var{Camera} and audio device @var{Microphone}:
  136. @example
  137. $ ffmpeg -f dshow -i video="Camera":audio="Microphone"
  138. @end example
  139. @item
  140. Print the list of supported options in selected device and exit:
  141. @example
  142. $ ffmpeg -list_options true -f dshow -i video="Camera"
  143. @end example
  144. @end itemize
  145. @section dv1394
  146. Linux DV 1394 input device.
  147. @section fbdev
  148. Linux framebuffer input device.
  149. The Linux framebuffer is a graphic hardware-independent abstraction
  150. layer to show graphics on a computer monitor, typically on the
  151. console. It is accessed through a file device node, usually
  152. @file{/dev/fb0}.
  153. For more detailed information read the file
  154. Documentation/fb/framebuffer.txt included in the Linux source tree.
  155. To record from the framebuffer device @file{/dev/fb0} with
  156. @command{ffmpeg}:
  157. @example
  158. ffmpeg -f fbdev -r 10 -i /dev/fb0 out.avi
  159. @end example
  160. You can take a single screenshot image with the command:
  161. @example
  162. ffmpeg -f fbdev -frames:v 1 -r 1 -i /dev/fb0 screenshot.jpeg
  163. @end example
  164. See also @url{http://linux-fbdev.sourceforge.net/}, and fbset(1).
  165. @section gdigrab
  166. Win32 GDI-based screen capture device.
  167. This device allows you to capture a region of the display on Windows.
  168. There are two options for the input filename:
  169. @example
  170. desktop
  171. @end example
  172. or
  173. @example
  174. title=@var{window_title}
  175. @end example
  176. The first option will capture the entire desktop, or a fixed region of the
  177. desktop. The second option will instead capture the contents of a single
  178. window, regardless of its position on the screen.
  179. For example, to grab the entire desktop using @command{ffmpeg}:
  180. @example
  181. ffmpeg -f gdigrab -framerate 6 -i desktop out.mpg
  182. @end example
  183. Grab a 640x480 region at position @code{10,20}:
  184. @example
  185. ffmpeg -f gdigrab -framerate 6 -offset_x 10 -offset_y 20 -video_size vga -i desktop out.mpg
  186. @end example
  187. Grab the contents of the window named "Calculator"
  188. @example
  189. ffmpeg -f gdigrab -framerate 6 -i title=Calculator out.mpg
  190. @end example
  191. @subsection Options
  192. @table @option
  193. @item draw_mouse
  194. Specify whether to draw the mouse pointer. Use the value @code{0} to
  195. not draw the pointer. Default value is @code{1}.
  196. @item framerate
  197. Set the grabbing frame rate. Default value is @code{ntsc},
  198. corresponding to a frame rate of @code{30000/1001}.
  199. @item show_region
  200. Show grabbed region on screen.
  201. If @var{show_region} is specified with @code{1}, then the grabbing
  202. region will be indicated on screen. With this option, it is easy to
  203. know what is being grabbed if only a portion of the screen is grabbed.
  204. Note that @var{show_region} is incompatible with grabbing the contents
  205. of a single window.
  206. For example:
  207. @example
  208. ffmpeg -f gdigrab -show_region 1 -framerate 6 -video_size cif -offset_x 10 -offset_y 20 -i desktop out.mpg
  209. @end example
  210. @item video_size
  211. Set the video frame size. The default is to capture the full screen if @file{desktop} is selected, or the full window size if @file{title=@var{window_title}} is selected.
  212. @item offset_x
  213. When capturing a region with @var{video_size}, set the distance from the left edge of the screen or desktop.
  214. Note that the offset calculation is from the top left corner of the primary monitor on Windows. If you have a monitor positioned to the left of your primary monitor, you will need to use a negative @var{offset_x} value to move the region to that monitor.
  215. @item offset_y
  216. When capturing a region with @var{video_size}, set the distance from the top edge of the screen or desktop.
  217. Note that the offset calculation is from the top left corner of the primary monitor on Windows. If you have a monitor positioned above your primary monitor, you will need to use a negative @var{offset_y} value to move the region to that monitor.
  218. @end table
  219. @section iec61883
  220. FireWire DV/HDV input device using libiec61883.
  221. To enable this input device, you need libiec61883, libraw1394 and
  222. libavc1394 installed on your system. Use the configure option
  223. @code{--enable-libiec61883} to compile with the device enabled.
  224. The iec61883 capture device supports capturing from a video device
  225. connected via IEEE1394 (FireWire), using libiec61883 and the new Linux
  226. FireWire stack (juju). This is the default DV/HDV input method in Linux
  227. Kernel 2.6.37 and later, since the old FireWire stack was removed.
  228. Specify the FireWire port to be used as input file, or "auto"
  229. to choose the first port connected.
  230. @subsection Options
  231. @table @option
  232. @item dvtype
  233. Override autodetection of DV/HDV. This should only be used if auto
  234. detection does not work, or if usage of a different device type
  235. should be prohibited. Treating a DV device as HDV (or vice versa) will
  236. not work and result in undefined behavior.
  237. The values @option{auto}, @option{dv} and @option{hdv} are supported.
  238. @item dvbuffer
  239. Set maxiumum size of buffer for incoming data, in frames. For DV, this
  240. is an exact value. For HDV, it is not frame exact, since HDV does
  241. not have a fixed frame size.
  242. @item dvguid
  243. Select the capture device by specifying it's GUID. Capturing will only
  244. be performed from the specified device and fails if no device with the
  245. given GUID is found. This is useful to select the input if multiple
  246. devices are connected at the same time.
  247. Look at /sys/bus/firewire/devices to find out the GUIDs.
  248. @end table
  249. @subsection Examples
  250. @itemize
  251. @item
  252. Grab and show the input of a FireWire DV/HDV device.
  253. @example
  254. ffplay -f iec61883 -i auto
  255. @end example
  256. @item
  257. Grab and record the input of a FireWire DV/HDV device,
  258. using a packet buffer of 100000 packets if the source is HDV.
  259. @example
  260. ffmpeg -f iec61883 -i auto -hdvbuffer 100000 out.mpg
  261. @end example
  262. @end itemize
  263. @section jack
  264. JACK input device.
  265. To enable this input device during configuration you need libjack
  266. installed on your system.
  267. A JACK input device creates one or more JACK writable clients, one for
  268. each audio channel, with name @var{client_name}:input_@var{N}, where
  269. @var{client_name} is the name provided by the application, and @var{N}
  270. is a number which identifies the channel.
  271. Each writable client will send the acquired data to the FFmpeg input
  272. device.
  273. Once you have created one or more JACK readable clients, you need to
  274. connect them to one or more JACK writable clients.
  275. To connect or disconnect JACK clients you can use the @command{jack_connect}
  276. and @command{jack_disconnect} programs, or do it through a graphical interface,
  277. for example with @command{qjackctl}.
  278. To list the JACK clients and their properties you can invoke the command
  279. @command{jack_lsp}.
  280. Follows an example which shows how to capture a JACK readable client
  281. with @command{ffmpeg}.
  282. @example
  283. # Create a JACK writable client with name "ffmpeg".
  284. $ ffmpeg -f jack -i ffmpeg -y out.wav
  285. # Start the sample jack_metro readable client.
  286. $ jack_metro -b 120 -d 0.2 -f 4000
  287. # List the current JACK clients.
  288. $ jack_lsp -c
  289. system:capture_1
  290. system:capture_2
  291. system:playback_1
  292. system:playback_2
  293. ffmpeg:input_1
  294. metro:120_bpm
  295. # Connect metro to the ffmpeg writable client.
  296. $ jack_connect metro:120_bpm ffmpeg:input_1
  297. @end example
  298. For more information read:
  299. @url{http://jackaudio.org/}
  300. @section lavfi
  301. Libavfilter input virtual device.
  302. This input device reads data from the open output pads of a libavfilter
  303. filtergraph.
  304. For each filtergraph open output, the input device will create a
  305. corresponding stream which is mapped to the generated output. Currently
  306. only video data is supported. The filtergraph is specified through the
  307. option @option{graph}.
  308. @subsection Options
  309. @table @option
  310. @item graph
  311. Specify the filtergraph to use as input. Each video open output must be
  312. labelled by a unique string of the form "out@var{N}", where @var{N} is a
  313. number starting from 0 corresponding to the mapped input stream
  314. generated by the device.
  315. The first unlabelled output is automatically assigned to the "out0"
  316. label, but all the others need to be specified explicitly.
  317. If not specified defaults to the filename specified for the input
  318. device.
  319. @item graph_file
  320. Set the filename of the filtergraph to be read and sent to the other
  321. filters. Syntax of the filtergraph is the same as the one specified by
  322. the option @var{graph}.
  323. @end table
  324. @subsection Examples
  325. @itemize
  326. @item
  327. Create a color video stream and play it back with @command{ffplay}:
  328. @example
  329. ffplay -f lavfi -graph "color=c=pink [out0]" dummy
  330. @end example
  331. @item
  332. As the previous example, but use filename for specifying the graph
  333. description, and omit the "out0" label:
  334. @example
  335. ffplay -f lavfi color=c=pink
  336. @end example
  337. @item
  338. Create three different video test filtered sources and play them:
  339. @example
  340. ffplay -f lavfi -graph "testsrc [out0]; testsrc,hflip [out1]; testsrc,negate [out2]" test3
  341. @end example
  342. @item
  343. Read an audio stream from a file using the amovie source and play it
  344. back with @command{ffplay}:
  345. @example
  346. ffplay -f lavfi "amovie=test.wav"
  347. @end example
  348. @item
  349. Read an audio stream and a video stream and play it back with
  350. @command{ffplay}:
  351. @example
  352. ffplay -f lavfi "movie=test.avi[out0];amovie=test.wav[out1]"
  353. @end example
  354. @end itemize
  355. @section libcdio
  356. Audio-CD input device based on cdio.
  357. To enable this input device during configuration you need libcdio
  358. installed on your system. Requires the configure option
  359. @code{--enable-libcdio}.
  360. This device allows playing and grabbing from an Audio-CD.
  361. For example to copy with @command{ffmpeg} the entire Audio-CD in /dev/sr0,
  362. you may run the command:
  363. @example
  364. ffmpeg -f libcdio -i /dev/sr0 cd.wav
  365. @end example
  366. @section libdc1394
  367. IIDC1394 input device, based on libdc1394 and libraw1394.
  368. Requires the configure option @code{--enable-libdc1394}.
  369. @section openal
  370. The OpenAL input device provides audio capture on all systems with a
  371. working OpenAL 1.1 implementation.
  372. To enable this input device during configuration, you need OpenAL
  373. headers and libraries installed on your system, and need to configure
  374. FFmpeg with @code{--enable-openal}.
  375. OpenAL headers and libraries should be provided as part of your OpenAL
  376. implementation, or as an additional download (an SDK). Depending on your
  377. installation you may need to specify additional flags via the
  378. @code{--extra-cflags} and @code{--extra-ldflags} for allowing the build
  379. system to locate the OpenAL headers and libraries.
  380. An incomplete list of OpenAL implementations follows:
  381. @table @strong
  382. @item Creative
  383. The official Windows implementation, providing hardware acceleration
  384. with supported devices and software fallback.
  385. See @url{http://openal.org/}.
  386. @item OpenAL Soft
  387. Portable, open source (LGPL) software implementation. Includes
  388. backends for the most common sound APIs on the Windows, Linux,
  389. Solaris, and BSD operating systems.
  390. See @url{http://kcat.strangesoft.net/openal.html}.
  391. @item Apple
  392. OpenAL is part of Core Audio, the official Mac OS X Audio interface.
  393. See @url{http://developer.apple.com/technologies/mac/audio-and-video.html}
  394. @end table
  395. This device allows one to capture from an audio input device handled
  396. through OpenAL.
  397. You need to specify the name of the device to capture in the provided
  398. filename. If the empty string is provided, the device will
  399. automatically select the default device. You can get the list of the
  400. supported devices by using the option @var{list_devices}.
  401. @subsection Options
  402. @table @option
  403. @item channels
  404. Set the number of channels in the captured audio. Only the values
  405. @option{1} (monaural) and @option{2} (stereo) are currently supported.
  406. Defaults to @option{2}.
  407. @item sample_size
  408. Set the sample size (in bits) of the captured audio. Only the values
  409. @option{8} and @option{16} are currently supported. Defaults to
  410. @option{16}.
  411. @item sample_rate
  412. Set the sample rate (in Hz) of the captured audio.
  413. Defaults to @option{44.1k}.
  414. @item list_devices
  415. If set to @option{true}, print a list of devices and exit.
  416. Defaults to @option{false}.
  417. @end table
  418. @subsection Examples
  419. Print the list of OpenAL supported devices and exit:
  420. @example
  421. $ ffmpeg -list_devices true -f openal -i dummy out.ogg
  422. @end example
  423. Capture from the OpenAL device @file{DR-BT101 via PulseAudio}:
  424. @example
  425. $ ffmpeg -f openal -i 'DR-BT101 via PulseAudio' out.ogg
  426. @end example
  427. Capture from the default device (note the empty string '' as filename):
  428. @example
  429. $ ffmpeg -f openal -i '' out.ogg
  430. @end example
  431. Capture from two devices simultaneously, writing to two different files,
  432. within the same @command{ffmpeg} command:
  433. @example
  434. $ ffmpeg -f openal -i 'DR-BT101 via PulseAudio' out1.ogg -f openal -i 'ALSA Default' out2.ogg
  435. @end example
  436. Note: not all OpenAL implementations support multiple simultaneous capture -
  437. try the latest OpenAL Soft if the above does not work.
  438. @section oss
  439. Open Sound System input device.
  440. The filename to provide to the input device is the device node
  441. representing the OSS input device, and is usually set to
  442. @file{/dev/dsp}.
  443. For example to grab from @file{/dev/dsp} using @command{ffmpeg} use the
  444. command:
  445. @example
  446. ffmpeg -f oss -i /dev/dsp /tmp/oss.wav
  447. @end example
  448. For more information about OSS see:
  449. @url{http://manuals.opensound.com/usersguide/dsp.html}
  450. @section pulse
  451. PulseAudio input device.
  452. To enable this output device you need to configure FFmpeg with @code{--enable-libpulse}.
  453. The filename to provide to the input device is a source device or the
  454. string "default"
  455. To list the PulseAudio source devices and their properties you can invoke
  456. the command @command{pactl list sources}.
  457. More information about PulseAudio can be found on @url{http://www.pulseaudio.org}.
  458. @subsection Options
  459. @table @option
  460. @item server
  461. Connect to a specific PulseAudio server, specified by an IP address.
  462. Default server is used when not provided.
  463. @item name
  464. Specify the application name PulseAudio will use when showing active clients,
  465. by default it is the @code{LIBAVFORMAT_IDENT} string.
  466. @item stream_name
  467. Specify the stream name PulseAudio will use when showing active streams,
  468. by default it is "record".
  469. @item sample_rate
  470. Specify the samplerate in Hz, by default 48kHz is used.
  471. @item channels
  472. Specify the channels in use, by default 2 (stereo) is set.
  473. @item frame_size
  474. Specify the number of bytes per frame, by default it is set to 1024.
  475. @item fragment_size
  476. Specify the minimal buffering fragment in PulseAudio, it will affect the
  477. audio latency. By default it is unset.
  478. @end table
  479. @subsection Examples
  480. Record a stream from default device:
  481. @example
  482. ffmpeg -f pulse -i default /tmp/pulse.wav
  483. @end example
  484. @section qtkit
  485. QTKit input device.
  486. The filename passed as input is parsed to contain either a device name or index.
  487. The device index can also be given by using -video_device_index.
  488. A given device index will override any given device name.
  489. If the desired device consists of numbers only, use -video_device_index to identify it.
  490. The default device will be chosen if an empty string or the device name "default" is given.
  491. The available devices can be enumerated by using -list_devices.
  492. @example
  493. ffmpeg -f qtkit -i "0" out.mpg
  494. @end example
  495. @example
  496. ffmpeg -f qtkit -video_device_index 0 -i "" out.mpg
  497. @end example
  498. @example
  499. ffmpeg -f qtkit -i "default" out.mpg
  500. @end example
  501. @example
  502. ffmpeg -f qtkit -list_devices true -i ""
  503. @end example
  504. @section sndio
  505. sndio input device.
  506. To enable this input device during configuration you need libsndio
  507. installed on your system.
  508. The filename to provide to the input device is the device node
  509. representing the sndio input device, and is usually set to
  510. @file{/dev/audio0}.
  511. For example to grab from @file{/dev/audio0} using @command{ffmpeg} use the
  512. command:
  513. @example
  514. ffmpeg -f sndio -i /dev/audio0 /tmp/oss.wav
  515. @end example
  516. @section video4linux2, v4l2
  517. Video4Linux2 input video device.
  518. "v4l2" can be used as alias for "video4linux2".
  519. If FFmpeg is built with v4l-utils support (by using the
  520. @code{--enable-libv4l2} configure option), it is possible to use it with the
  521. @code{-use_libv4l2} input device option.
  522. The name of the device to grab is a file device node, usually Linux
  523. systems tend to automatically create such nodes when the device
  524. (e.g. an USB webcam) is plugged into the system, and has a name of the
  525. kind @file{/dev/video@var{N}}, where @var{N} is a number associated to
  526. the device.
  527. Video4Linux2 devices usually support a limited set of
  528. @var{width}x@var{height} sizes and frame rates. You can check which are
  529. supported using @command{-list_formats all} for Video4Linux2 devices.
  530. Some devices, like TV cards, support one or more standards. It is possible
  531. to list all the supported standards using @command{-list_standards all}.
  532. The time base for the timestamps is 1 microsecond. Depending on the kernel
  533. version and configuration, the timestamps may be derived from the real time
  534. clock (origin at the Unix Epoch) or the monotonic clock (origin usually at
  535. boot time, unaffected by NTP or manual changes to the clock). The
  536. @option{-timestamps abs} or @option{-ts abs} option can be used to force
  537. conversion into the real time clock.
  538. Some usage examples of the video4linux2 device with @command{ffmpeg}
  539. and @command{ffplay}:
  540. @itemize
  541. @item
  542. Grab and show the input of a video4linux2 device:
  543. @example
  544. ffplay -f video4linux2 -framerate 30 -video_size hd720 /dev/video0
  545. @end example
  546. @item
  547. Grab and record the input of a video4linux2 device, leave the
  548. frame rate and size as previously set:
  549. @example
  550. ffmpeg -f video4linux2 -input_format mjpeg -i /dev/video0 out.mpeg
  551. @end example
  552. @end itemize
  553. For more information about Video4Linux, check @url{http://linuxtv.org/}.
  554. @subsection Options
  555. @table @option
  556. @item standard
  557. Set the standard. Must be the name of a supported standard. To get a
  558. list of the supported standards, use the @option{list_standards}
  559. option.
  560. @item channel
  561. Set the input channel number. Default to -1, which means using the
  562. previously selected channel.
  563. @item video_size
  564. Set the video frame size. The argument must be a string in the form
  565. @var{WIDTH}x@var{HEIGHT} or a valid size abbreviation.
  566. @item pixel_format
  567. Select the pixel format (only valid for raw video input).
  568. @item input_format
  569. Set the preferred pixel format (for raw video) or a codec name.
  570. This option allows one to select the input format, when several are
  571. available.
  572. @item framerate
  573. Set the preferred video frame rate.
  574. @item list_formats
  575. List available formats (supported pixel formats, codecs, and frame
  576. sizes) and exit.
  577. Available values are:
  578. @table @samp
  579. @item all
  580. Show all available (compressed and non-compressed) formats.
  581. @item raw
  582. Show only raw video (non-compressed) formats.
  583. @item compressed
  584. Show only compressed formats.
  585. @end table
  586. @item list_standards
  587. List supported standards and exit.
  588. Available values are:
  589. @table @samp
  590. @item all
  591. Show all supported standards.
  592. @end table
  593. @item timestamps, ts
  594. Set type of timestamps for grabbed frames.
  595. Available values are:
  596. @table @samp
  597. @item default
  598. Use timestamps from the kernel.
  599. @item abs
  600. Use absolute timestamps (wall clock).
  601. @item mono2abs
  602. Force conversion from monotonic to absolute timestamps.
  603. @end table
  604. Default value is @code{default}.
  605. @end table
  606. @section vfwcap
  607. VfW (Video for Windows) capture input device.
  608. The filename passed as input is the capture driver number, ranging from
  609. 0 to 9. You may use "list" as filename to print a list of drivers. Any
  610. other filename will be interpreted as device number 0.
  611. @section x11grab
  612. X11 video input device.
  613. Depends on X11, Xext, and Xfixes. Requires the configure option
  614. @code{--enable-x11grab}.
  615. This device allows one to capture a region of an X11 display.
  616. The filename passed as input has the syntax:
  617. @example
  618. [@var{hostname}]:@var{display_number}.@var{screen_number}[+@var{x_offset},@var{y_offset}]
  619. @end example
  620. @var{hostname}:@var{display_number}.@var{screen_number} specifies the
  621. X11 display name of the screen to grab from. @var{hostname} can be
  622. omitted, and defaults to "localhost". The environment variable
  623. @env{DISPLAY} contains the default display name.
  624. @var{x_offset} and @var{y_offset} specify the offsets of the grabbed
  625. area with respect to the top-left border of the X11 screen. They
  626. default to 0.
  627. Check the X11 documentation (e.g. man X) for more detailed information.
  628. Use the @command{dpyinfo} program for getting basic information about the
  629. properties of your X11 display (e.g. grep for "name" or "dimensions").
  630. For example to grab from @file{:0.0} using @command{ffmpeg}:
  631. @example
  632. ffmpeg -f x11grab -framerate 25 -video_size cif -i :0.0 out.mpg
  633. @end example
  634. Grab at position @code{10,20}:
  635. @example
  636. ffmpeg -f x11grab -framerate 25 -video_size cif -i :0.0+10,20 out.mpg
  637. @end example
  638. @subsection Options
  639. @table @option
  640. @item draw_mouse
  641. Specify whether to draw the mouse pointer. A value of @code{0} specify
  642. not to draw the pointer. Default value is @code{1}.
  643. @item follow_mouse
  644. Make the grabbed area follow the mouse. The argument can be
  645. @code{centered} or a number of pixels @var{PIXELS}.
  646. When it is specified with "centered", the grabbing region follows the mouse
  647. pointer and keeps the pointer at the center of region; otherwise, the region
  648. follows only when the mouse pointer reaches within @var{PIXELS} (greater than
  649. zero) to the edge of region.
  650. For example:
  651. @example
  652. ffmpeg -f x11grab -follow_mouse centered -framerate 25 -video_size cif -i :0.0 out.mpg
  653. @end example
  654. To follow only when the mouse pointer reaches within 100 pixels to edge:
  655. @example
  656. ffmpeg -f x11grab -follow_mouse 100 -framerate 25 -video_size cif -i :0.0 out.mpg
  657. @end example
  658. @item framerate
  659. Set the grabbing frame rate. Default value is @code{ntsc},
  660. corresponding to a frame rate of @code{30000/1001}.
  661. @item show_region
  662. Show grabbed region on screen.
  663. If @var{show_region} is specified with @code{1}, then the grabbing
  664. region will be indicated on screen. With this option, it is easy to
  665. know what is being grabbed if only a portion of the screen is grabbed.
  666. For example:
  667. @example
  668. ffmpeg -f x11grab -show_region 1 -framerate 25 -video_size cif -i :0.0+10,20 out.mpg
  669. @end example
  670. With @var{follow_mouse}:
  671. @example
  672. ffmpeg -f x11grab -follow_mouse centered -show_region 1 -framerate 25 -video_size cif -i :0.0 out.mpg
  673. @end example
  674. @item video_size
  675. Set the video frame size. Default value is @code{vga}.
  676. @item use_shm
  677. Use the MIT-SHM extension for shared memory. Default value is @code{1}.
  678. It may be necessary to disable it for remote displays.
  679. @end table
  680. @c man end INPUT DEVICES