logo

oasis-root

Compiled tree of Oasis Linux based on own branch at <https://hacktivis.me/git/oasis/> git clone https://anongit.hacktivis.me/git/oasis-root.git

ffmpeg.1 (121187B)


  1. .Dd August 2, 2024
  2. .Dt FFMPEG 7
  3. .Os
  4. .Sh NAME
  5. .Nm ffmpeg
  6. .Nd ffmpeg Documentation
  7. .Sh
  8. .Sh Synopsis
  9. ffmpeg [
  10. .Va global_options
  11. ] {[
  12. .Va input_file_options
  13. ] -i
  14. .Pa input_url
  15. }\&... {[
  16. .Va output_file_options
  17. ]
  18. .Pa output_url
  19. }\&...
  20. .Pp
  21. .Sh Description
  22. .Xr ffmpeg
  23. is a universal media converter. It can read a wide variety of inputs - including
  24. live grabbing/recording devices - filter, and transcode them into a plethora
  25. of output formats.
  26. .Pp
  27. .Xr ffmpeg
  28. reads from an arbitrary number of input "files" (which can be regular files,
  29. pipes, network streams, grabbing devices, etc.), specified by the
  30. .Li -i
  31. option, and writes to an arbitrary number of output "files", which are specified
  32. by a plain output url. Anything found on the command line which cannot be
  33. interpreted as an option is considered to be an output url.
  34. .Pp
  35. Each input or output url can, in principle, contain any number of streams
  36. of different types (video/audio/subtitle/attachment/data). The allowed number
  37. and/or types of streams may be limited by the container format. Selecting
  38. which streams from which inputs will go into which output is either done automatically
  39. or with the
  40. .Li -map
  41. option (see the Stream selection chapter).
  42. .Pp
  43. To refer to input files in options, you must use their indices (0-based).
  44. E.g. the first input file is
  45. .Li 0 ,
  46. the second is
  47. .Li 1 ,
  48. etc. Similarly, streams within a file are referred to by their indices. E.g.
  49. .Li 2:3
  50. refers to the fourth stream in the third input file. Also see the Stream specifiers
  51. chapter.
  52. .Pp
  53. As a general rule, options are applied to the next specified file. Therefore,
  54. order is important, and you can have the same option on the command line multiple
  55. times. Each occurrence is then applied to the next input or output file. Exceptions
  56. from this rule are the global options (e.g. verbosity level), which should
  57. be specified first.
  58. .Pp
  59. Do not mix input and output files -- first specify all input files, then all
  60. output files. Also do not mix options which belong to different files. All
  61. options apply ONLY to the next input or output file and are reset between
  62. files.
  63. .Pp
  64. Some simple examples follow.
  65. .Pp
  66. .Bl -bullet
  67. .It
  68. Convert an input media file to a different format, by re-encoding media streams:
  69. .Bd -literal -offset indent
  70. ffmpeg -i input.avi output.mp4
  71. .Ed
  72. .Pp
  73. .It
  74. Set the video bitrate of the output file to 64 kbit/s:
  75. .Bd -literal -offset indent
  76. ffmpeg -i input.avi -b:v 64k -bufsize 64k output.mp4
  77. .Ed
  78. .Pp
  79. .It
  80. Force the frame rate of the output file to 24 fps:
  81. .Bd -literal -offset indent
  82. ffmpeg -i input.avi -r 24 output.mp4
  83. .Ed
  84. .Pp
  85. .It
  86. Force the frame rate of the input file (valid for raw formats only) to 1 fps
  87. and the frame rate of the output file to 24 fps:
  88. .Bd -literal -offset indent
  89. ffmpeg -r 1 -i input.m2v -r 24 output.mp4
  90. .Ed
  91. .El
  92. .Pp
  93. The format option may be needed for raw input files.
  94. .Pp
  95. .Sh Detailed description
  96. The transcoding process in
  97. .Xr ffmpeg
  98. for each output can be described by the following diagram:
  99. .Pp
  100. .Bd -literal -offset indent
  101. _______ ______________
  102. | | | |
  103. | input | demuxer | encoded data | decoder
  104. | file | ---------> | packets | -----+
  105. |_______| |______________| |
  106. v
  107. _________
  108. | |
  109. | decoded |
  110. | frames |
  111. |_________|
  112. ________ ______________ |
  113. | | | | |
  114. | output | <-------- | encoded data | <----+
  115. | file | muxer | packets | encoder
  116. |________| |______________|
  117. .Ed
  118. .Pp
  119. .Xr ffmpeg
  120. calls the libavformat library (containing demuxers) to read input files and
  121. get packets containing encoded data from them. When there are multiple input
  122. files,
  123. .Xr ffmpeg
  124. tries to keep them synchronized by tracking lowest timestamp on any active
  125. input stream.
  126. .Pp
  127. Encoded packets are then passed to the decoder (unless streamcopy is selected
  128. for the stream, see further for a description). The decoder produces uncompressed
  129. frames (raw video/PCM audio/...) which can be processed further by filtering
  130. (see next section). After filtering, the frames are passed to the encoder,
  131. which encodes them and outputs encoded packets. Finally, those are passed
  132. to the muxer, which writes the encoded packets to the output file.
  133. .Pp
  134. .Ss Filtering
  135. Before encoding,
  136. .Xr ffmpeg
  137. can process raw audio and video frames using filters from the libavfilter
  138. library. Several chained filters form a filter graph.
  139. .Xr ffmpeg
  140. distinguishes between two types of filtergraphs: simple and complex.
  141. .Pp
  142. .Em Simple filtergraphs
  143. .Pp
  144. Simple filtergraphs are those that have exactly one input and output, both
  145. of the same type. In the above diagram they can be represented by simply inserting
  146. an additional step between decoding and encoding:
  147. .Pp
  148. .Bd -literal -offset indent
  149. _________ ______________
  150. | | | |
  151. | decoded | | encoded data |
  152. | frames |\e _ | packets |
  153. |_________| \e /||______________|
  154. \e __________ /
  155. simple _\e|| | / encoder
  156. filtergraph | filtered |/
  157. | frames |
  158. |__________|
  159. .Ed
  160. .Pp
  161. Simple filtergraphs are configured with the per-stream
  162. .Op -filter
  163. option (with
  164. .Op -vf
  165. and
  166. .Op -af
  167. aliases for video and audio respectively). A simple filtergraph for video
  168. can look for example like this:
  169. .Pp
  170. .Bd -literal -offset indent
  171. _______ _____________ _______ ________
  172. | | | | | | | |
  173. | input | ---> | deinterlace | ---> | scale | ---> | output |
  174. |_______| |_____________| |_______| |________|
  175. .Ed
  176. .Pp
  177. Note that some filters change frame properties but not frame contents. E.g.
  178. the
  179. .Li fps
  180. filter in the example above changes number of frames, but does not touch the
  181. frame contents. Another example is the
  182. .Li setpts
  183. filter, which only sets timestamps and otherwise passes the frames unchanged.
  184. .Pp
  185. .Em Complex filtergraphs
  186. .Pp
  187. Complex filtergraphs are those which cannot be described as simply a linear
  188. processing chain applied to one stream. This is the case, for example, when
  189. the graph has more than one input and/or output, or when output stream type
  190. is different from input. They can be represented with the following diagram:
  191. .Pp
  192. .Bd -literal -offset indent
  193. _________
  194. | |
  195. | input 0 |\e __________
  196. |_________| \e | |
  197. \e _________ /| output 0 |
  198. \e | | / |__________|
  199. _________ \e| complex | /
  200. | | | |/
  201. | input 1 |---->| filter |\e
  202. |_________| | | \e __________
  203. /| graph | \e | |
  204. / | | \e| output 1 |
  205. _________ / |_________| |__________|
  206. | | /
  207. | input 2 |/
  208. |_________|
  209. .Ed
  210. .Pp
  211. Complex filtergraphs are configured with the
  212. .Op -filter_complex
  213. option. Note that this option is global, since a complex filtergraph, by its
  214. nature, cannot be unambiguously associated with a single stream or file.
  215. .Pp
  216. The
  217. .Op -lavfi
  218. option is equivalent to
  219. .Op -filter_complex .
  220. .Pp
  221. A trivial example of a complex filtergraph is the
  222. .Li overlay
  223. filter, which has two video inputs and one video output, containing one video
  224. overlaid on top of the other. Its audio counterpart is the
  225. .Li amix
  226. filter.
  227. .Pp
  228. .Ss Stream copy
  229. Stream copy is a mode selected by supplying the
  230. .Li copy
  231. parameter to the
  232. .Op -codec
  233. option. It makes
  234. .Xr ffmpeg
  235. omit the decoding and encoding step for the specified stream, so it does only
  236. demuxing and muxing. It is useful for changing the container format or modifying
  237. container-level metadata. The diagram above will, in this case, simplify to
  238. this:
  239. .Pp
  240. .Bd -literal -offset indent
  241. _______ ______________ ________
  242. | | | | | |
  243. | input | demuxer | encoded data | muxer | output |
  244. | file | ---------> | packets | -------> | file |
  245. |_______| |______________| |________|
  246. .Ed
  247. .Pp
  248. Since there is no decoding or encoding, it is very fast and there is no quality
  249. loss. However, it might not work in some cases because of many factors. Applying
  250. filters is obviously also impossible, since filters work on uncompressed data.
  251. .Pp
  252. .Ss Loopback decoders
  253. While decoders are normally associated with demuxer streams, it is also possible
  254. to create "loopback" decoders that decode the output from some encoder and
  255. allow it to be fed back to complex filtergraphs. This is done with the
  256. .Li -dec
  257. directive, which takes as a parameter the index of the output stream that
  258. should be decoded. Every such directive creates a new loopback decoder, indexed
  259. with successive integers starting at zero. These indices should then be used
  260. to refer to loopback decoders in complex filtergraph link labels, as described
  261. in the documentation for
  262. .Op -filter_complex .
  263. .Pp
  264. E.g. the following example:
  265. .Pp
  266. .Bd -literal -offset indent
  267. ffmpeg -i INPUT \e
  268. -map 0:v:0 -c:v libx264 -crf 45 -f null - \e
  269. -dec 0:0 -filter_complex '[0:v][dec:0]hstack[stack]' \e
  270. -map '[stack]' -c:v ffv1 OUTPUT
  271. .Ed
  272. .Pp
  273. reads an input video and
  274. .Bl -bullet
  275. .It
  276. (line 2) encodes it with
  277. .Li libx264
  278. at low quality;
  279. .Pp
  280. .It
  281. (line 3) decodes this encoded stream and places it side by side with the original
  282. input video;
  283. .Pp
  284. .It
  285. (line 4) combined video is then losslessly encoded and written into
  286. .Pa OUTPUT .
  287. .Pp
  288. .El
  289. .Sh Stream selection
  290. .Xr ffmpeg
  291. provides the
  292. .Li -map
  293. option for manual control of stream selection in each output file. Users can
  294. skip
  295. .Li -map
  296. and let ffmpeg perform automatic stream selection as described below. The
  297. .Li -vn / -an / -sn / -dn
  298. options can be used to skip inclusion of video, audio, subtitle and data streams
  299. respectively, whether manually mapped or automatically selected, except for
  300. those streams which are outputs of complex filtergraphs.
  301. .Pp
  302. .Ss Description
  303. The sub-sections that follow describe the various rules that are involved
  304. in stream selection. The examples that follow next show how these rules are
  305. applied in practice.
  306. .Pp
  307. While every effort is made to accurately reflect the behavior of the program,
  308. FFmpeg is under continuous development and the code may have changed since
  309. the time of this writing.
  310. .Pp
  311. .Em Automatic stream selection
  312. .Pp
  313. In the absence of any map options for a particular output file, ffmpeg inspects
  314. the output format to check which type of streams can be included in it, viz.
  315. video, audio and/or subtitles. For each acceptable stream type, ffmpeg will
  316. pick one stream, when available, from among all the inputs.
  317. .Pp
  318. It will select that stream based upon the following criteria:
  319. .Bl -bullet
  320. .It
  321. for video, it is the stream with the highest resolution,
  322. .It
  323. for audio, it is the stream with the most channels,
  324. .It
  325. for subtitles, it is the first subtitle stream found but there's a caveat.
  326. The output format's default subtitle encoder can be either text-based or image-based,
  327. and only a subtitle stream of the same type will be chosen.
  328. .El
  329. .Pp
  330. In the case where several streams of the same type rate equally, the stream
  331. with the lowest index is chosen.
  332. .Pp
  333. Data or attachment streams are not automatically selected and can only be
  334. included using
  335. .Li -map .
  336. .Pp
  337. .Em Manual stream selection
  338. .Pp
  339. When
  340. .Li -map
  341. is used, only user-mapped streams are included in that output file, with one
  342. possible exception for filtergraph outputs described below.
  343. .Pp
  344. .Em Complex filtergraphs
  345. .Pp
  346. If there are any complex filtergraph output streams with unlabeled pads, they
  347. will be added to the first output file. This will lead to a fatal error if
  348. the stream type is not supported by the output format. In the absence of the
  349. map option, the inclusion of these streams leads to the automatic stream selection
  350. of their types being skipped. If map options are present, these filtergraph
  351. streams are included in addition to the mapped streams.
  352. .Pp
  353. Complex filtergraph output streams with labeled pads must be mapped once and
  354. exactly once.
  355. .Pp
  356. .Em Stream handling
  357. .Pp
  358. Stream handling is independent of stream selection, with an exception for
  359. subtitles described below. Stream handling is set via the
  360. .Li -codec
  361. option addressed to streams within a specific
  362. .Em output
  363. file. In particular, codec options are applied by ffmpeg after the stream
  364. selection process and thus do not influence the latter. If no
  365. .Li -codec
  366. option is specified for a stream type, ffmpeg will select the default encoder
  367. registered by the output file muxer.
  368. .Pp
  369. An exception exists for subtitles. If a subtitle encoder is specified for
  370. an output file, the first subtitle stream found of any type, text or image,
  371. will be included. ffmpeg does not validate if the specified encoder can convert
  372. the selected stream or if the converted stream is acceptable within the output
  373. format. This applies generally as well: when the user sets an encoder manually,
  374. the stream selection process cannot check if the encoded stream can be muxed
  375. into the output file. If it cannot, ffmpeg will abort and
  376. .Em all
  377. output files will fail to be processed.
  378. .Pp
  379. .Ss Examples
  380. The following examples illustrate the behavior, quirks and limitations of
  381. ffmpeg's stream selection methods.
  382. .Pp
  383. They assume the following three input files.
  384. .Pp
  385. .Bd -literal -offset indent
  386. input file 'A.avi'
  387. stream 0: video 640x360
  388. stream 1: audio 2 channels
  389. input file 'B.mp4'
  390. stream 0: video 1920x1080
  391. stream 1: audio 2 channels
  392. stream 2: subtitles (text)
  393. stream 3: audio 5.1 channels
  394. stream 4: subtitles (text)
  395. input file 'C.mkv'
  396. stream 0: video 1280x720
  397. stream 1: audio 2 channels
  398. stream 2: subtitles (image)
  399. .Ed
  400. .Pp
  401. .No Example: automatic stream selection
  402. .Pp
  403. .Bd -literal -offset indent
  404. ffmpeg -i A.avi -i B.mp4 out1.mkv out2.wav -map 1:a -c:a copy out3.mov
  405. .Ed
  406. There are three output files specified, and for the first two, no
  407. .Li -map
  408. options are set, so ffmpeg will select streams for these two files automatically.
  409. .Pp
  410. .Pa out1.mkv
  411. is a Matroska container file and accepts video, audio and subtitle streams,
  412. so ffmpeg will try to select one of each type. For video, it will select
  413. .Li stream 0
  414. from
  415. .Pa B.mp4 ,
  416. which has the highest resolution among all the input video streams. For audio,
  417. it will select
  418. .Li stream 3
  419. from
  420. .Pa B.mp4 ,
  421. since it has the greatest number of channels. For subtitles, it will select
  422. .Li stream 2
  423. from
  424. .Pa B.mp4 ,
  425. which is the first subtitle stream from among
  426. .Pa A.avi
  427. and
  428. .Pa B.mp4 .
  429. .Pp
  430. .Pa out2.wav
  431. accepts only audio streams, so only
  432. .Li stream 3
  433. from
  434. .Pa B.mp4
  435. is selected.
  436. .Pp
  437. For
  438. .Pa out3.mov ,
  439. since a
  440. .Li -map
  441. option is set, no automatic stream selection will occur. The
  442. .Li -map 1:a
  443. option will select all audio streams from the second input
  444. .Pa B.mp4 .
  445. No other streams will be included in this output file.
  446. .Pp
  447. For the first two outputs, all included streams will be transcoded. The encoders
  448. chosen will be the default ones registered by each output format, which may
  449. not match the codec of the selected input streams.
  450. .Pp
  451. For the third output, codec option for audio streams has been set to
  452. .Li copy ,
  453. so no decoding-filtering-encoding operations will occur, or
  454. .Em can
  455. occur. Packets of selected streams shall be conveyed from the input file and
  456. muxed within the output file.
  457. .Pp
  458. .No Example: automatic subtitles selection
  459. .Pp
  460. .Bd -literal -offset indent
  461. ffmpeg -i C.mkv out1.mkv -c:s dvdsub -an out2.mkv
  462. .Ed
  463. Although
  464. .Pa out1.mkv
  465. is a Matroska container file which accepts subtitle streams, only a video
  466. and audio stream shall be selected. The subtitle stream of
  467. .Pa C.mkv
  468. is image-based and the default subtitle encoder of the Matroska muxer is text-based,
  469. so a transcode operation for the subtitles is expected to fail and hence the
  470. stream isn't selected. However, in
  471. .Pa out2.mkv ,
  472. a subtitle encoder is specified in the command and so, the subtitle stream
  473. is selected, in addition to the video stream. The presence of
  474. .Li -an
  475. disables audio stream selection for
  476. .Pa out2.mkv .
  477. .Pp
  478. .No Example: unlabeled filtergraph outputs
  479. .Pp
  480. .Bd -literal -offset indent
  481. ffmpeg -i A.avi -i C.mkv -i B.mp4 -filter_complex "overlay" out1.mp4 out2.srt
  482. .Ed
  483. A filtergraph is setup here using the
  484. .Li -filter_complex
  485. option and consists of a single video filter. The
  486. .Li overlay
  487. filter requires exactly two video inputs, but none are specified, so the first
  488. two available video streams are used, those of
  489. .Pa A.avi
  490. and
  491. .Pa C.mkv .
  492. The output pad of the filter has no label and so is sent to the first output
  493. file
  494. .Pa out1.mp4 .
  495. Due to this, automatic selection of the video stream is skipped, which would
  496. have selected the stream in
  497. .Pa B.mp4 .
  498. The audio stream with most channels viz.
  499. .Li stream 3
  500. in
  501. .Pa B.mp4 ,
  502. is chosen automatically. No subtitle stream is chosen however, since the MP4
  503. format has no default subtitle encoder registered, and the user hasn't specified
  504. a subtitle encoder.
  505. .Pp
  506. The 2nd output file,
  507. .Pa out2.srt ,
  508. only accepts text-based subtitle streams. So, even though the first subtitle
  509. stream available belongs to
  510. .Pa C.mkv ,
  511. it is image-based and hence skipped. The selected stream,
  512. .Li stream 2
  513. in
  514. .Pa B.mp4 ,
  515. is the first text-based subtitle stream.
  516. .Pp
  517. .No Example: labeled filtergraph outputs
  518. .Pp
  519. .Bd -literal -offset indent
  520. ffmpeg -i A.avi -i B.mp4 -i C.mkv -filter_complex "[1:v]hue=s=0[outv];overlay;aresample" \e
  521. -map '[outv]' -an out1.mp4 \e
  522. out2.mkv \e
  523. -map '[outv]' -map 1:a:0 out3.mkv
  524. .Ed
  525. .Pp
  526. The above command will fail, as the output pad labelled
  527. .Li [outv]
  528. has been mapped twice. None of the output files shall be processed.
  529. .Pp
  530. .Bd -literal -offset indent
  531. ffmpeg -i A.avi -i B.mp4 -i C.mkv -filter_complex "[1:v]hue=s=0[outv];overlay;aresample" \e
  532. -an out1.mp4 \e
  533. out2.mkv \e
  534. -map 1:a:0 out3.mkv
  535. .Ed
  536. .Pp
  537. This command above will also fail as the hue filter output has a label,
  538. .Li [outv] ,
  539. and hasn't been mapped anywhere.
  540. .Pp
  541. The command should be modified as follows,
  542. .Bd -literal -offset indent
  543. ffmpeg -i A.avi -i B.mp4 -i C.mkv -filter_complex "[1:v]hue=s=0,split=2[outv1][outv2];overlay;aresample" \e
  544. -map '[outv1]' -an out1.mp4 \e
  545. out2.mkv \e
  546. -map '[outv2]' -map 1:a:0 out3.mkv
  547. .Ed
  548. The video stream from
  549. .Pa B.mp4
  550. is sent to the hue filter, whose output is cloned once using the split filter,
  551. and both outputs labelled. Then a copy each is mapped to the first and third
  552. output files.
  553. .Pp
  554. The overlay filter, requiring two video inputs, uses the first two unused
  555. video streams. Those are the streams from
  556. .Pa A.avi
  557. and
  558. .Pa C.mkv .
  559. The overlay output isn't labelled, so it is sent to the first output file
  560. .Pa out1.mp4 ,
  561. regardless of the presence of the
  562. .Li -map
  563. option.
  564. .Pp
  565. The aresample filter is sent the first unused audio stream, that of
  566. .Pa A.avi .
  567. Since this filter output is also unlabelled, it too is mapped to the first
  568. output file. The presence of
  569. .Li -an
  570. only suppresses automatic or manual stream selection of audio streams, not
  571. outputs sent from filtergraphs. Both these mapped streams shall be ordered
  572. before the mapped stream in
  573. .Pa out1.mp4 .
  574. .Pp
  575. The video, audio and subtitle streams mapped to
  576. .Li out2.mkv
  577. are entirely determined by automatic stream selection.
  578. .Pp
  579. .Pa out3.mkv
  580. consists of the cloned video output from the hue filter and the first audio
  581. stream from
  582. .Pa B.mp4 .
  583. .Pp
  584. .Sh Options
  585. All the numerical options, if not specified otherwise, accept a string representing
  586. a number as input, which may be followed by one of the SI unit prefixes, for
  587. example: 'K', 'M', or 'G'.
  588. .Pp
  589. If 'i' is appended to the SI unit prefix, the complete prefix will be interpreted
  590. as a unit prefix for binary multiples, which are based on powers of 1024 instead
  591. of powers of 1000. Appending 'B' to the SI unit prefix multiplies the value
  592. by 8. This allows using, for example: 'KB', 'MiB', 'G' and 'B' as number suffixes.
  593. .Pp
  594. Options which do not take arguments are boolean options, and set the corresponding
  595. value to true. They can be set to false by prefixing the option name with
  596. "no". For example using "-nofoo" will set the boolean option with name "foo"
  597. to false.
  598. .Pp
  599. Options that take arguments support a special syntax where the argument given
  600. on the command line is interpreted as a path to the file from which the actual
  601. argument value is loaded. To use this feature, add a forward slash '/' immediately
  602. before the option name (after the leading dash). E.g.
  603. .Bd -literal -offset indent
  604. ffmpeg -i INPUT -/filter:v filter.script OUTPUT
  605. .Ed
  606. will load a filtergraph description from the file named
  607. .Pa filter.script .
  608. .Pp
  609. .Ss Stream specifiers
  610. Some options are applied per-stream, e.g. bitrate or codec. Stream specifiers
  611. are used to precisely specify which stream(s) a given option belongs to.
  612. .Pp
  613. A stream specifier is a string generally appended to the option name and separated
  614. from it by a colon. E.g.
  615. .Li -codec:a:1 ac3
  616. contains the
  617. .Li a:1
  618. stream specifier, which matches the second audio stream. Therefore, it would
  619. select the ac3 codec for the second audio stream.
  620. .Pp
  621. A stream specifier can match several streams, so that the option is applied
  622. to all of them. E.g. the stream specifier in
  623. .Li -b:a 128k
  624. matches all audio streams.
  625. .Pp
  626. An empty stream specifier matches all streams. For example,
  627. .Li -codec copy
  628. or
  629. .Li -codec: copy
  630. would copy all the streams without reencoding.
  631. .Pp
  632. Possible forms of stream specifiers are:
  633. .Bl -tag -width Ds
  634. .It Va stream_index
  635. Matches the stream with this index. E.g.
  636. .Li -threads:1 4
  637. would set the thread count for the second stream to 4. If
  638. .Va stream_index
  639. is used as an additional stream specifier (see below), then it selects stream
  640. number
  641. .Va stream_index
  642. from the matching streams. Stream numbering is based on the order of the streams
  643. as detected by libavformat except when a stream group specifier or program
  644. ID is also specified. In this case it is based on the ordering of the streams
  645. in the group or program.
  646. .It Va stream_type[: Va additional_stream_specifier]
  647. .Va stream_type
  648. is one of following: 'v' or 'V' for video, 'a' for audio, 's' for subtitle,
  649. \&'d' for data, and 't' for attachments. 'v' matches all video streams, 'V'
  650. only matches video streams which are not attached pictures, video thumbnails
  651. or cover arts. If
  652. .Va additional_stream_specifier
  653. is used, then it matches streams which both have this type and match the
  654. .Va additional_stream_specifier .
  655. Otherwise, it matches all streams of the specified type.
  656. .It g: Va group_specifier[: Va additional_stream_specifier]
  657. Matches streams which are in the group with the specifier
  658. .Va group_specifier .
  659. if
  660. .Va additional_stream_specifier
  661. is used, then it matches streams which both are part of the group and match
  662. the
  663. .Va additional_stream_specifier .
  664. .Va group_specifier
  665. may be one of the following:
  666. .Bl -tag -width Ds
  667. .It Va group_index
  668. Match the stream with this group index.
  669. .It # Va group_id or i: Va group_id
  670. Match the stream with this group id.
  671. .El
  672. .It p: Va program_id[: Va additional_stream_specifier]
  673. Matches streams which are in the program with the id
  674. .Va program_id .
  675. If
  676. .Va additional_stream_specifier
  677. is used, then it matches streams which both are part of the program and match
  678. the
  679. .Va additional_stream_specifier .
  680. .Pp
  681. .It # Va stream_id or i: Va stream_id
  682. Match the stream by stream id (e.g. PID in MPEG-TS container).
  683. .It m: Va key[: Va value]
  684. Matches streams with the metadata tag
  685. .Va key
  686. having the specified value. If
  687. .Va value
  688. is not given, matches streams that contain the given tag with any value.
  689. .It u
  690. Matches streams with usable configuration, the codec must be defined and the
  691. essential information such as video dimension or audio sample rate must be
  692. present.
  693. .Pp
  694. Note that in
  695. .Xr ffmpeg ,
  696. matching by metadata will only work properly for input files.
  697. .El
  698. .Pp
  699. .Ss Generic options
  700. These options are shared amongst the ff* tools.
  701. .Pp
  702. .Bl -tag -width Ds
  703. .It -L
  704. Show license.
  705. .Pp
  706. .It -h, -?, -help, --help [ Va arg]
  707. Show help. An optional parameter may be specified to print help about a specific
  708. item. If no argument is specified, only basic (non advanced) tool options
  709. are shown.
  710. .Pp
  711. Possible values of
  712. .Va arg
  713. are:
  714. .Bl -tag -width Ds
  715. .It long
  716. Print advanced tool options in addition to the basic tool options.
  717. .Pp
  718. .It full
  719. Print complete list of options, including shared and private options for encoders,
  720. decoders, demuxers, muxers, filters, etc.
  721. .Pp
  722. .It decoder= Va decoder_name
  723. Print detailed information about the decoder named
  724. .Va decoder_name .
  725. Use the
  726. .Op -decoders
  727. option to get a list of all decoders.
  728. .Pp
  729. .It encoder= Va encoder_name
  730. Print detailed information about the encoder named
  731. .Va encoder_name .
  732. Use the
  733. .Op -encoders
  734. option to get a list of all encoders.
  735. .Pp
  736. .It demuxer= Va demuxer_name
  737. Print detailed information about the demuxer named
  738. .Va demuxer_name .
  739. Use the
  740. .Op -formats
  741. option to get a list of all demuxers and muxers.
  742. .Pp
  743. .It muxer= Va muxer_name
  744. Print detailed information about the muxer named
  745. .Va muxer_name .
  746. Use the
  747. .Op -formats
  748. option to get a list of all muxers and demuxers.
  749. .Pp
  750. .It filter= Va filter_name
  751. Print detailed information about the filter named
  752. .Va filter_name .
  753. Use the
  754. .Op -filters
  755. option to get a list of all filters.
  756. .Pp
  757. .It bsf= Va bitstream_filter_name
  758. Print detailed information about the bitstream filter named
  759. .Va bitstream_filter_name .
  760. Use the
  761. .Op -bsfs
  762. option to get a list of all bitstream filters.
  763. .Pp
  764. .It protocol= Va protocol_name
  765. Print detailed information about the protocol named
  766. .Va protocol_name .
  767. Use the
  768. .Op -protocols
  769. option to get a list of all protocols.
  770. .El
  771. .Pp
  772. .It -version
  773. Show version.
  774. .Pp
  775. .It -buildconf
  776. Show the build configuration, one option per line.
  777. .Pp
  778. .It -formats
  779. Show available formats (including devices).
  780. .Pp
  781. .It -demuxers
  782. Show available demuxers.
  783. .Pp
  784. .It -muxers
  785. Show available muxers.
  786. .Pp
  787. .It -devices
  788. Show available devices.
  789. .Pp
  790. .It -codecs
  791. Show all codecs known to libavcodec.
  792. .Pp
  793. Note that the term 'codec' is used throughout this documentation as a shortcut
  794. for what is more correctly called a media bitstream format.
  795. .Pp
  796. .It -decoders
  797. Show available decoders.
  798. .Pp
  799. .It -encoders
  800. Show all available encoders.
  801. .Pp
  802. .It -bsfs
  803. Show available bitstream filters.
  804. .Pp
  805. .It -protocols
  806. Show available protocols.
  807. .Pp
  808. .It -filters
  809. Show available libavfilter filters.
  810. .Pp
  811. .It -pix_fmts
  812. Show available pixel formats.
  813. .Pp
  814. .It -sample_fmts
  815. Show available sample formats.
  816. .Pp
  817. .It -layouts
  818. Show channel names and standard channel layouts.
  819. .Pp
  820. .It -dispositions
  821. Show stream dispositions.
  822. .Pp
  823. .It -colors
  824. Show recognized color names.
  825. .Pp
  826. .It -sources Va device[, Va opt1= Va val1[, Va opt2= Va val2]...]
  827. Show autodetected sources of the input device. Some devices may provide system-dependent
  828. source names that cannot be autodetected. The returned list cannot be assumed
  829. to be always complete.
  830. .Bd -literal -offset indent
  831. ffmpeg -sources pulse,server=192.168.0.4
  832. .Ed
  833. .Pp
  834. .It -sinks Va device[, Va opt1= Va val1[, Va opt2= Va val2]...]
  835. Show autodetected sinks of the output device. Some devices may provide system-dependent
  836. sink names that cannot be autodetected. The returned list cannot be assumed
  837. to be always complete.
  838. .Bd -literal -offset indent
  839. ffmpeg -sinks pulse,server=192.168.0.4
  840. .Ed
  841. .Pp
  842. .It -loglevel [ Va flags+] Va loglevel | -v [ Va flags+] Va loglevel
  843. Set logging level and flags used by the library.
  844. .Pp
  845. The optional
  846. .Va flags
  847. prefix can consist of the following values:
  848. .Bl -tag -width Ds
  849. .It repeat
  850. Indicates that repeated log output should not be compressed to the first line
  851. and the "Last message repeated n times" line will be omitted.
  852. .It level
  853. Indicates that log output should add a
  854. .Li [level]
  855. prefix to each message line. This can be used as an alternative to log coloring,
  856. e.g. when dumping the log to file.
  857. .El
  858. Flags can also be used alone by adding a '+'/'-' prefix to set/reset a single
  859. flag without affecting other
  860. .Va flags
  861. or changing
  862. .Va loglevel .
  863. When setting both
  864. .Va flags
  865. and
  866. .Va loglevel ,
  867. a '+' separator is expected between the last
  868. .Va flags
  869. value and before
  870. .Va loglevel .
  871. .Pp
  872. .Va loglevel
  873. is a string or a number containing one of the following values:
  874. .Bl -tag -width Ds
  875. .It quiet, -8
  876. Show nothing at all; be silent.
  877. .It panic, 0
  878. Only show fatal errors which could lead the process to crash, such as an assertion
  879. failure. This is not currently used for anything.
  880. .It fatal, 8
  881. Only show fatal errors. These are errors after which the process absolutely
  882. cannot continue.
  883. .It error, 16
  884. Show all errors, including ones which can be recovered from.
  885. .It warning, 24
  886. Show all warnings and errors. Any message related to possibly incorrect or
  887. unexpected events will be shown.
  888. .It info, 32
  889. Show informative messages during processing. This is in addition to warnings
  890. and errors. This is the default value.
  891. .It verbose, 40
  892. Same as
  893. .Li info ,
  894. except more verbose.
  895. .It debug, 48
  896. Show everything, including debugging information.
  897. .It trace, 56
  898. .El
  899. .Pp
  900. For example to enable repeated log output, add the
  901. .Li level
  902. prefix, and set
  903. .Va loglevel
  904. to
  905. .Li verbose :
  906. .Bd -literal -offset indent
  907. ffmpeg -loglevel repeat+level+verbose -i input output
  908. .Ed
  909. Another example that enables repeated log output without affecting current
  910. state of
  911. .Li level
  912. prefix flag or
  913. .Va loglevel :
  914. .Bd -literal -offset indent
  915. ffmpeg [...] -loglevel +repeat
  916. .Ed
  917. .Pp
  918. By default the program logs to stderr. If coloring is supported by the terminal,
  919. colors are used to mark errors and warnings. Log coloring can be disabled
  920. setting the environment variable
  921. .Ev AV_LOG_FORCE_NOCOLOR ,
  922. or can be forced setting the environment variable
  923. .Ev AV_LOG_FORCE_COLOR .
  924. .Pp
  925. .It -report
  926. Dump full command line and log output to a file named
  927. .Li Va program- Va YYYYMMDD- Va HHMMSS.log
  928. in the current directory. This file can be useful for bug reports. It also
  929. implies
  930. .Li -loglevel debug .
  931. .Pp
  932. Setting the environment variable
  933. .Ev FFREPORT
  934. to any value has the same effect. If the value is a ':'-separated key=value
  935. sequence, these options will affect the report; option values must be escaped
  936. if they contain special characters or the options delimiter ':' (see the \(lqQuoting
  937. and escaping\(rq section in the ffmpeg-utils manual).
  938. .Pp
  939. The following options are recognized:
  940. .Bl -tag -width Ds
  941. .It file
  942. set the file name to use for the report;
  943. .Li %p
  944. is expanded to the name of the program,
  945. .Li %t
  946. is expanded to a timestamp,
  947. .Li %%
  948. is expanded to a plain
  949. .Li %
  950. .It level
  951. set the log verbosity level using a numerical value (see
  952. .Li -loglevel ) .
  953. .El
  954. .Pp
  955. For example, to output a report to a file named
  956. .Pa ffreport.log
  957. using a log level of
  958. .Li 32
  959. (alias for log level
  960. .Li info ) :
  961. .Pp
  962. .Bd -literal -offset indent
  963. FFREPORT=file=ffreport.log:level=32 ffmpeg -i input output
  964. .Ed
  965. .Pp
  966. Errors in parsing the environment variable are not fatal, and will not appear
  967. in the report.
  968. .Pp
  969. .It -hide_banner
  970. Suppress printing banner.
  971. .Pp
  972. All FFmpeg tools will normally show a copyright notice, build options and
  973. library versions. This option can be used to suppress printing this information.
  974. .Pp
  975. .It -cpuflags flags ( Em global)
  976. Allows setting and clearing cpu flags. This option is intended for testing.
  977. Do not use it unless you know what you're doing.
  978. .Bd -literal -offset indent
  979. ffmpeg -cpuflags -sse+mmx ...
  980. ffmpeg -cpuflags mmx ...
  981. ffmpeg -cpuflags 0 ...
  982. .Ed
  983. Possible flags for this option are:
  984. .Bl -tag -width Ds
  985. .It x86
  986. .Bl -tag -width Ds
  987. .It mmx
  988. .It mmxext
  989. .It sse
  990. .It sse2
  991. .It sse2slow
  992. .It sse3
  993. .It sse3slow
  994. .It ssse3
  995. .It atom
  996. .It sse4.1
  997. .It sse4.2
  998. .It avx
  999. .It avx2
  1000. .It xop
  1001. .It fma3
  1002. .It fma4
  1003. .It 3dnow
  1004. .It 3dnowext
  1005. .It bmi1
  1006. .It bmi2
  1007. .It cmov
  1008. .El
  1009. .It ARM
  1010. .Bl -tag -width Ds
  1011. .It armv5te
  1012. .It armv6
  1013. .It armv6t2
  1014. .It vfp
  1015. .It vfpv3
  1016. .It neon
  1017. .It setend
  1018. .El
  1019. .It AArch64
  1020. .Bl -tag -width Ds
  1021. .It armv8
  1022. .It vfp
  1023. .It neon
  1024. .El
  1025. .It PowerPC
  1026. .Bl -tag -width Ds
  1027. .It altivec
  1028. .El
  1029. .It Specific Processors
  1030. .Bl -tag -width Ds
  1031. .It pentium2
  1032. .It pentium3
  1033. .It pentium4
  1034. .It k6
  1035. .It k62
  1036. .It athlon
  1037. .It athlonxp
  1038. .It k8
  1039. .El
  1040. .El
  1041. .Pp
  1042. .It -cpucount Va count ( Em global)
  1043. Override detection of CPU count. This option is intended for testing. Do not
  1044. use it unless you know what you're doing.
  1045. .Bd -literal -offset indent
  1046. ffmpeg -cpucount 2
  1047. .Ed
  1048. .Pp
  1049. .It -max_alloc Va bytes
  1050. Set the maximum size limit for allocating a block on the heap by ffmpeg's
  1051. family of malloc functions. Exercise
  1052. .Sy extreme caution
  1053. when using this option. Don't use if you do not understand the full consequence
  1054. of doing so. Default is INT_MAX.
  1055. .El
  1056. .Pp
  1057. .Ss AVOptions
  1058. These options are provided directly by the libavformat, libavdevice and libavcodec
  1059. libraries. To see the list of available AVOptions, use the
  1060. .Op -help
  1061. option. They are separated into two categories:
  1062. .Bl -tag -width Ds
  1063. .It generic
  1064. These options can be set for any container, codec or device. Generic options
  1065. are listed under AVFormatContext options for containers/devices and under
  1066. AVCodecContext options for codecs.
  1067. .It private
  1068. These options are specific to the given container, device or codec. Private
  1069. options are listed under their corresponding containers/devices/codecs.
  1070. .El
  1071. .Pp
  1072. For example to write an ID3v2.3 header instead of a default ID3v2.4 to an
  1073. MP3 file, use the
  1074. .Op id3v2_version
  1075. private option of the MP3 muxer:
  1076. .Bd -literal -offset indent
  1077. ffmpeg -i input.flac -id3v2_version 3 out.mp3
  1078. .Ed
  1079. .Pp
  1080. All codec AVOptions are per-stream, and thus a stream specifier should be
  1081. attached to them:
  1082. .Bd -literal -offset indent
  1083. ffmpeg -i multichannel.mxf -map 0:v:0 -map 0:a:0 -map 0:a:0 -c:a:0 ac3 -b:a:0 640k -ac:a:1 2 -c:a:1 aac -b:2 128k out.mp4
  1084. .Ed
  1085. .Pp
  1086. In the above example, a multichannel audio stream is mapped twice for output.
  1087. The first instance is encoded with codec ac3 and bitrate 640k. The second
  1088. instance is downmixed to 2 channels and encoded with codec aac. A bitrate
  1089. of 128k is specified for it using absolute index of the output stream.
  1090. .Pp
  1091. Note: the
  1092. .Op -nooption
  1093. syntax cannot be used for boolean AVOptions, use
  1094. .Op -option 0
  1095. /
  1096. .Op -option 1 .
  1097. .Pp
  1098. Note: the old undocumented way of specifying per-stream AVOptions by prepending
  1099. v/a/s to the options name is now obsolete and will be removed soon.
  1100. .Pp
  1101. .Ss Main options
  1102. .Bl -tag -width Ds
  1103. .It -f Va fmt ( Em input/output)
  1104. Force input or output file format. The format is normally auto detected for
  1105. input files and guessed from the file extension for output files, so this
  1106. option is not needed in most cases.
  1107. .Pp
  1108. .It -i Va url ( Em input)
  1109. input file url
  1110. .Pp
  1111. .It -y ( Em global)
  1112. Overwrite output files without asking.
  1113. .Pp
  1114. .It -n ( Em global)
  1115. Do not overwrite output files, and exit immediately if a specified output
  1116. file already exists.
  1117. .Pp
  1118. .It -stream_loop Va number ( Em input)
  1119. Set number of times input stream shall be looped. Loop 0 means no loop, loop
  1120. -1 means infinite loop.
  1121. .Pp
  1122. .It -recast_media ( Em global)
  1123. Allow forcing a decoder of a different media type than the one detected or
  1124. designated by the demuxer. Useful for decoding media data muxed as data streams.
  1125. .Pp
  1126. .It -c[: Va stream_specifier] Va codec ( Em input/output,per-stream)
  1127. .It -codec[: Va stream_specifier] Va codec ( Em input/output,per-stream)
  1128. Select an encoder (when used before an output file) or a decoder (when used
  1129. before an input file) for one or more streams.
  1130. .Va codec
  1131. is the name of a decoder/encoder or a special value
  1132. .Li copy
  1133. (output only) to indicate that the stream is not to be re-encoded.
  1134. .Pp
  1135. For example
  1136. .Bd -literal -offset indent
  1137. ffmpeg -i INPUT -map 0 -c:v libx264 -c:a copy OUTPUT
  1138. .Ed
  1139. encodes all video streams with libx264 and copies all audio streams.
  1140. .Pp
  1141. For each stream, the last matching
  1142. .Li c
  1143. option is applied, so
  1144. .Bd -literal -offset indent
  1145. ffmpeg -i INPUT -map 0 -c copy -c:v:1 libx264 -c:a:137 libvorbis OUTPUT
  1146. .Ed
  1147. will copy all the streams except the second video, which will be encoded with
  1148. libx264, and the 138th audio, which will be encoded with libvorbis.
  1149. .Pp
  1150. .It -t Va duration ( Em input/output)
  1151. When used as an input option (before
  1152. .Li -i ) ,
  1153. limit the
  1154. .Va duration
  1155. of data read from the input file.
  1156. .Pp
  1157. When used as an output option (before an output url), stop writing the output
  1158. after its duration reaches
  1159. .Va duration .
  1160. .Pp
  1161. .Va duration
  1162. must be a time duration specification, see time duration syntax,,the Time
  1163. duration section in the ffmpeg-utils(1) manual,ffmpeg-utils.
  1164. .Pp
  1165. -to and -t are mutually exclusive and -t has priority.
  1166. .Pp
  1167. .It -to Va position ( Em input/output)
  1168. Stop writing the output or reading the input at
  1169. .Va position .
  1170. .Va position
  1171. must be a time duration specification, see time duration syntax,,the Time
  1172. duration section in the ffmpeg-utils(1) manual,ffmpeg-utils.
  1173. .Pp
  1174. -to and -t are mutually exclusive and -t has priority.
  1175. .Pp
  1176. .It -fs Va limit_size ( Em output)
  1177. Set the file size limit, expressed in bytes. No further chunk of bytes is
  1178. written after the limit is exceeded. The size of the output file is slightly
  1179. more than the requested file size.
  1180. .Pp
  1181. .It -ss Va position ( Em input/output)
  1182. When used as an input option (before
  1183. .Li -i ) ,
  1184. seeks in this input file to
  1185. .Va position .
  1186. Note that in most formats it is not possible to seek exactly, so
  1187. .Xr ffmpeg
  1188. will seek to the closest seek point before
  1189. .Va position .
  1190. When transcoding and
  1191. .Op -accurate_seek
  1192. is enabled (the default), this extra segment between the seek point and
  1193. .Va position
  1194. will be decoded and discarded. When doing stream copy or when
  1195. .Op -noaccurate_seek
  1196. is used, it will be preserved.
  1197. .Pp
  1198. When used as an output option (before an output url), decodes but discards
  1199. input until the timestamps reach
  1200. .Va position .
  1201. .Pp
  1202. .Va position
  1203. must be a time duration specification, see time duration syntax,,the Time
  1204. duration section in the ffmpeg-utils(1) manual,ffmpeg-utils.
  1205. .Pp
  1206. .It -sseof Va position ( Em input)
  1207. .Pp
  1208. Like the
  1209. .Li -ss
  1210. option but relative to the "end of file". That is negative values are earlier
  1211. in the file, 0 is at EOF.
  1212. .Pp
  1213. .It -isync Va input_index ( Em input)
  1214. Assign an input as a sync source.
  1215. .Pp
  1216. This will take the difference between the start times of the target and reference
  1217. inputs and offset the timestamps of the target file by that difference. The
  1218. source timestamps of the two inputs should derive from the same clock source
  1219. for expected results. If
  1220. .Li copyts
  1221. is set then
  1222. .Li start_at_zero
  1223. must also be set. If either of the inputs has no starting timestamp then no
  1224. sync adjustment is made.
  1225. .Pp
  1226. Acceptable values are those that refer to a valid ffmpeg input index. If the
  1227. sync reference is the target index itself or
  1228. .Va -1 ,
  1229. then no adjustment is made to target timestamps. A sync reference may not
  1230. itself be synced to any other input.
  1231. .Pp
  1232. Default value is
  1233. .Va -1 .
  1234. .Pp
  1235. .It -itsoffset Va offset ( Em input)
  1236. Set the input time offset.
  1237. .Pp
  1238. .Va offset
  1239. must be a time duration specification, see time duration syntax,,the Time
  1240. duration section in the ffmpeg-utils(1) manual,ffmpeg-utils.
  1241. .Pp
  1242. The offset is added to the timestamps of the input files. Specifying a positive
  1243. offset means that the corresponding streams are delayed by the time duration
  1244. specified in
  1245. .Va offset .
  1246. .Pp
  1247. .It -itsscale Va scale ( Em input,per-stream)
  1248. Rescale input timestamps.
  1249. .Va scale
  1250. should be a floating point number.
  1251. .Pp
  1252. .It -timestamp Va date ( Em output)
  1253. Set the recording timestamp in the container.
  1254. .Pp
  1255. .Va date
  1256. must be a date specification, see date syntax,,the Date section in the ffmpeg-utils(1)
  1257. manual,ffmpeg-utils.
  1258. .Pp
  1259. .It -metadata[:metadata_specifier] Va key= Va value ( Em output,per-metadata)
  1260. Set a metadata key/value pair.
  1261. .Pp
  1262. An optional
  1263. .Va metadata_specifier
  1264. may be given to set metadata on streams, chapters or programs. See
  1265. .Li -map_metadata
  1266. documentation for details.
  1267. .Pp
  1268. This option overrides metadata set with
  1269. .Li -map_metadata .
  1270. It is also possible to delete metadata by using an empty value.
  1271. .Pp
  1272. For example, for setting the title in the output file:
  1273. .Bd -literal -offset indent
  1274. ffmpeg -i in.avi -metadata title="my title" out.flv
  1275. .Ed
  1276. .Pp
  1277. To set the language of the first audio stream:
  1278. .Bd -literal -offset indent
  1279. ffmpeg -i INPUT -metadata:s:a:0 language=eng OUTPUT
  1280. .Ed
  1281. .Pp
  1282. .It -disposition[:stream_specifier] Va value ( Em output,per-stream)
  1283. Sets the disposition for a stream.
  1284. .Pp
  1285. By default, the disposition is copied from the input stream, unless the output
  1286. stream this option applies to is fed by a complex filtergraph - in that case
  1287. the disposition is unset by default.
  1288. .Pp
  1289. .Va value
  1290. is a sequence of items separated by '+' or '-'. The first item may also be
  1291. prefixed with '+' or '-', in which case this option modifies the default value.
  1292. Otherwise (the first item is not prefixed) this options overrides the default
  1293. value. A '+' prefix adds the given disposition, '-' removes it. It is also
  1294. possible to clear the disposition by setting it to 0.
  1295. .Pp
  1296. If no
  1297. .Li -disposition
  1298. options were specified for an output file, ffmpeg will automatically set the
  1299. \&'default' disposition on the first stream of each type, when there are multiple
  1300. streams of this type in the output file and no stream of that type is already
  1301. marked as default.
  1302. .Pp
  1303. The
  1304. .Li -dispositions
  1305. option lists the known dispositions.
  1306. .Pp
  1307. For example, to make the second audio stream the default stream:
  1308. .Bd -literal -offset indent
  1309. ffmpeg -i in.mkv -c copy -disposition:a:1 default out.mkv
  1310. .Ed
  1311. .Pp
  1312. To make the second subtitle stream the default stream and remove the default
  1313. disposition from the first subtitle stream:
  1314. .Bd -literal -offset indent
  1315. ffmpeg -i in.mkv -c copy -disposition:s:0 0 -disposition:s:1 default out.mkv
  1316. .Ed
  1317. .Pp
  1318. To add an embedded cover/thumbnail:
  1319. .Bd -literal -offset indent
  1320. ffmpeg -i in.mp4 -i IMAGE -map 0 -map 1 -c copy -c:v:1 png -disposition:v:1 attached_pic out.mp4
  1321. .Ed
  1322. .Pp
  1323. Not all muxers support embedded thumbnails, and those who do, only support
  1324. a few formats, like JPEG or PNG.
  1325. .Pp
  1326. .It -program [title= Va title:][program_num= Va program_num:]st= Va stream[:st= Va stream...] ( Em output)
  1327. .Pp
  1328. Creates a program with the specified
  1329. .Va title ,
  1330. .Va program_num
  1331. and adds the specified
  1332. .Va stream
  1333. (s) to it.
  1334. .Pp
  1335. .It -stream_group type= Va type:st= Va stream[:st= Va stream][:stg= Va stream_group][:id= Va stream_group_id...] ( Em output)
  1336. .Pp
  1337. Creates a stream group of the specified
  1338. .Va type ,
  1339. .Va stream_group_id
  1340. and adds the specified
  1341. .Va stream
  1342. (s) and/or previously defined
  1343. .Va stream_group
  1344. (s) to it.
  1345. .Pp
  1346. .Va type
  1347. can be one of the following:
  1348. .Bl -tag -width Ds
  1349. .It iamf_audio_element
  1350. Groups
  1351. .Va stream
  1352. s that belong to the same IAMF Audio Element
  1353. .Pp
  1354. For this group
  1355. .Va type ,
  1356. the following options are available
  1357. .Bl -tag -width Ds
  1358. .It audio_element_type
  1359. The Audio Element type. The following values are supported:
  1360. .Pp
  1361. .Bl -tag -width Ds
  1362. .It channel
  1363. Scalable channel audio representation
  1364. .It scene
  1365. Ambisonics representation
  1366. .El
  1367. .Pp
  1368. .It demixing
  1369. Demixing information used to reconstruct a scalable channel audio representation.
  1370. This option must be separated from the rest with a ',', and takes the following
  1371. key=value options
  1372. .Pp
  1373. .Bl -tag -width Ds
  1374. .It parameter_id
  1375. An identifier parameters blocks in frames may refer to
  1376. .It dmixp_mode
  1377. A pre-defined combination of demixing parameters
  1378. .El
  1379. .Pp
  1380. .It recon_gain
  1381. Recon gain information used to reconstruct a scalable channel audio representation.
  1382. This option must be separated from the rest with a ',', and takes the following
  1383. key=value options
  1384. .Pp
  1385. .Bl -tag -width Ds
  1386. .It parameter_id
  1387. An identifier parameters blocks in frames may refer to
  1388. .El
  1389. .Pp
  1390. .It layer
  1391. A layer defining a Channel Layout in the Audio Element. This option must be
  1392. separated from the rest with a ','. Several ',' separated entries can be defined,
  1393. and at least one must be set.
  1394. .Pp
  1395. It takes the following ":"-separated key=value options
  1396. .Pp
  1397. .Bl -tag -width Ds
  1398. .It ch_layout
  1399. The layer's channel layout
  1400. .It flags
  1401. The following flags are available:
  1402. .Pp
  1403. .Bl -tag -width Ds
  1404. .It recon_gain
  1405. Wether to signal if recon_gain is present as metadata in parameter blocks
  1406. within frames
  1407. .El
  1408. .Pp
  1409. .It output_gain
  1410. .It output_gain_flags
  1411. Which channels output_gain applies to. The following flags are available:
  1412. .Pp
  1413. .Bl -tag -width Ds
  1414. .It FL
  1415. .It FR
  1416. .It BL
  1417. .It BR
  1418. .It TFL
  1419. .It TFR
  1420. .El
  1421. .Pp
  1422. .It ambisonics_mode
  1423. The ambisonics mode. This has no effect if audio_element_type is set to channel.
  1424. .Pp
  1425. The following values are supported:
  1426. .Pp
  1427. .Bl -tag -width Ds
  1428. .It mono
  1429. Each ambisonics channel is coded as an individual mono stream in the group
  1430. .El
  1431. .Pp
  1432. .El
  1433. .It default_w
  1434. Default weight value
  1435. .Pp
  1436. .El
  1437. .It iamf_mix_presentation
  1438. Groups
  1439. .Va stream
  1440. s that belong to all IAMF Audio Element the same IAMF Mix Presentation references
  1441. .Pp
  1442. For this group
  1443. .Va type ,
  1444. the following options are available
  1445. .Pp
  1446. .Bl -tag -width Ds
  1447. .It submix
  1448. A sub-mix within the Mix Presentation. This option must be separated from
  1449. the rest with a ','. Several ',' separated entries can be defined, and at
  1450. least one must be set.
  1451. .Pp
  1452. It takes the following ":"-separated key=value options
  1453. .Pp
  1454. .Bl -tag -width Ds
  1455. .It parameter_id
  1456. An identifier parameters blocks in frames may refer to, for post-processing
  1457. the mixed audio signal to generate the audio signal for playback
  1458. .It parameter_rate
  1459. The sample rate duration fields in parameters blocks in frames that refer
  1460. to this
  1461. .Va parameter_id
  1462. are expressed as
  1463. .It default_mix_gain
  1464. Default mix gain value to apply when there are no parameter blocks sharing
  1465. the same
  1466. .Va parameter_id
  1467. for a given frame
  1468. .Pp
  1469. .It element
  1470. References an Audio Element used in this Mix Presentation to generate the
  1471. final output audio signal for playback. This option must be separated from
  1472. the rest with a '|'. Several '|' separated entries can be defined, and at
  1473. least one must be set.
  1474. .Pp
  1475. It takes the following ":"-separated key=value options:
  1476. .Pp
  1477. .Bl -tag -width Ds
  1478. .It stg
  1479. The
  1480. .Va stream_group_id
  1481. for an Audio Element which this sub-mix refers to
  1482. .It parameter_id
  1483. An identifier parameters blocks in frames may refer to, for applying any processing
  1484. to the referenced and rendered Audio Element before being summed with other
  1485. processed Audio Elements
  1486. .It parameter_rate
  1487. The sample rate duration fields in parameters blocks in frames that refer
  1488. to this
  1489. .Va parameter_id
  1490. are expressed as
  1491. .It default_mix_gain
  1492. Default mix gain value to apply when there are no parameter blocks sharing
  1493. the same
  1494. .Va parameter_id
  1495. for a given frame
  1496. .It annotations
  1497. A key=value string describing the sub-mix element where "key" is a string
  1498. conforming to BCP-47 that specifies the language for the "value" string. "key"
  1499. must be the same as the one in the mix's
  1500. .Va annotations
  1501. .It headphones_rendering_mode
  1502. Indicates whether the input channel-based Audio Element is rendered to stereo
  1503. loudspeakers or spatialized with a binaural renderer when played back on headphones.
  1504. This has no effect if the referenced Audio Element's
  1505. .Va audio_element_type
  1506. is set to channel.
  1507. .Pp
  1508. The following values are supported:
  1509. .Pp
  1510. .Bl -tag -width Ds
  1511. .It stereo
  1512. .It binaural
  1513. .El
  1514. .Pp
  1515. .El
  1516. .It layout
  1517. Specifies the layouts for this sub-mix on which the loudness information was
  1518. measured. This option must be separated from the rest with a '|'. Several
  1519. \&'|' separated entries can be defined, and at least one must be set.
  1520. .Pp
  1521. It takes the following ":"-separated key=value options:
  1522. .Pp
  1523. .Bl -tag -width Ds
  1524. .It layout_type
  1525. .Pp
  1526. .Bl -tag -width Ds
  1527. .It loudspeakers
  1528. The layout follows the loudspeaker sound system convention of ITU-2051-3.
  1529. .It binaural
  1530. The layout is binaural.
  1531. .El
  1532. .Pp
  1533. .It sound_system
  1534. Channel layout matching one of Sound Systems A to J of ITU-2051-3, plus 7.1.2
  1535. and 3.1.2 This has no effect if
  1536. .Va layout_type
  1537. is set to binaural.
  1538. .It integrated_loudness
  1539. The program integrated loudness information, as defined in ITU-1770-4.
  1540. .It digital_peak
  1541. The digital (sampled) peak value of the audio signal, as defined in ITU-1770-4.
  1542. .It true_peak
  1543. The true peak of the audio signal, as defined in ITU-1770-4.
  1544. .It dialog_anchored_loudness
  1545. The Dialogue loudness information, as defined in ITU-1770-4.
  1546. .It album_anchored_loudness
  1547. The Album loudness information, as defined in ITU-1770-4.
  1548. .El
  1549. .Pp
  1550. .El
  1551. .It annotations
  1552. A key=value string string describing the mix where "key" is a string conforming
  1553. to BCP-47 that specifies the language for the "value" string. "key" must be
  1554. the same as the ones in all sub-mix element's
  1555. .Va annotations
  1556. s
  1557. .El
  1558. .Pp
  1559. .El
  1560. .It -target Va type ( Em output)
  1561. Specify target file type (
  1562. .Li vcd ,
  1563. .Li svcd ,
  1564. .Li dvd ,
  1565. .Li dv ,
  1566. .Li dv50 ) .
  1567. .Va type
  1568. may be prefixed with
  1569. .Li pal- ,
  1570. .Li ntsc-
  1571. or
  1572. .Li film-
  1573. to use the corresponding standard. All the format options (bitrate, codecs,
  1574. buffer sizes) are then set automatically. You can just type:
  1575. .Pp
  1576. .Bd -literal -offset indent
  1577. ffmpeg -i myfile.avi -target vcd /tmp/vcd.mpg
  1578. .Ed
  1579. .Pp
  1580. Nevertheless you can specify additional options as long as you know they do
  1581. not conflict with the standard, as in:
  1582. .Pp
  1583. .Bd -literal -offset indent
  1584. ffmpeg -i myfile.avi -target vcd -bf 2 /tmp/vcd.mpg
  1585. .Ed
  1586. .Pp
  1587. The parameters set for each target are as follows.
  1588. .Pp
  1589. .Sy VCD
  1590. .Bd -literal -offset indent
  1591. pal:
  1592. -f vcd -muxrate 1411200 -muxpreload 0.44 -packetsize 2324
  1593. -s 352x288 -r 25
  1594. -codec:v mpeg1video -g 15 -b:v 1150k -maxrate:v 1150k -minrate:v 1150k -bufsize:v 327680
  1595. -ar 44100 -ac 2
  1596. -codec:a mp2 -b:a 224k
  1597. ntsc:
  1598. -f vcd -muxrate 1411200 -muxpreload 0.44 -packetsize 2324
  1599. -s 352x240 -r 30000/1001
  1600. -codec:v mpeg1video -g 18 -b:v 1150k -maxrate:v 1150k -minrate:v 1150k -bufsize:v 327680
  1601. -ar 44100 -ac 2
  1602. -codec:a mp2 -b:a 224k
  1603. film:
  1604. -f vcd -muxrate 1411200 -muxpreload 0.44 -packetsize 2324
  1605. -s 352x240 -r 24000/1001
  1606. -codec:v mpeg1video -g 18 -b:v 1150k -maxrate:v 1150k -minrate:v 1150k -bufsize:v 327680
  1607. -ar 44100 -ac 2
  1608. -codec:a mp2 -b:a 224k
  1609. .Ed
  1610. .Pp
  1611. .Sy SVCD
  1612. .Bd -literal -offset indent
  1613. pal:
  1614. -f svcd -packetsize 2324
  1615. -s 480x576 -pix_fmt yuv420p -r 25
  1616. -codec:v mpeg2video -g 15 -b:v 2040k -maxrate:v 2516k -minrate:v 0 -bufsize:v 1835008 -scan_offset 1
  1617. -ar 44100
  1618. -codec:a mp2 -b:a 224k
  1619. ntsc:
  1620. -f svcd -packetsize 2324
  1621. -s 480x480 -pix_fmt yuv420p -r 30000/1001
  1622. -codec:v mpeg2video -g 18 -b:v 2040k -maxrate:v 2516k -minrate:v 0 -bufsize:v 1835008 -scan_offset 1
  1623. -ar 44100
  1624. -codec:a mp2 -b:a 224k
  1625. film:
  1626. -f svcd -packetsize 2324
  1627. -s 480x480 -pix_fmt yuv420p -r 24000/1001
  1628. -codec:v mpeg2video -g 18 -b:v 2040k -maxrate:v 2516k -minrate:v 0 -bufsize:v 1835008 -scan_offset 1
  1629. -ar 44100
  1630. -codec:a mp2 -b:a 224k
  1631. .Ed
  1632. .Pp
  1633. .Sy DVD
  1634. .Bd -literal -offset indent
  1635. pal:
  1636. -f dvd -muxrate 10080k -packetsize 2048
  1637. -s 720x576 -pix_fmt yuv420p -r 25
  1638. -codec:v mpeg2video -g 15 -b:v 6000k -maxrate:v 9000k -minrate:v 0 -bufsize:v 1835008
  1639. -ar 48000
  1640. -codec:a ac3 -b:a 448k
  1641. ntsc:
  1642. -f dvd -muxrate 10080k -packetsize 2048
  1643. -s 720x480 -pix_fmt yuv420p -r 30000/1001
  1644. -codec:v mpeg2video -g 18 -b:v 6000k -maxrate:v 9000k -minrate:v 0 -bufsize:v 1835008
  1645. -ar 48000
  1646. -codec:a ac3 -b:a 448k
  1647. film:
  1648. -f dvd -muxrate 10080k -packetsize 2048
  1649. -s 720x480 -pix_fmt yuv420p -r 24000/1001
  1650. -codec:v mpeg2video -g 18 -b:v 6000k -maxrate:v 9000k -minrate:v 0 -bufsize:v 1835008
  1651. -ar 48000
  1652. -codec:a ac3 -b:a 448k
  1653. .Ed
  1654. .Pp
  1655. .Sy DV
  1656. .Bd -literal -offset indent
  1657. pal:
  1658. -f dv
  1659. -s 720x576 -pix_fmt yuv420p -r 25
  1660. -ar 48000 -ac 2
  1661. ntsc:
  1662. -f dv
  1663. -s 720x480 -pix_fmt yuv411p -r 30000/1001
  1664. -ar 48000 -ac 2
  1665. film:
  1666. -f dv
  1667. -s 720x480 -pix_fmt yuv411p -r 24000/1001
  1668. -ar 48000 -ac 2
  1669. .Ed
  1670. The
  1671. .Li dv50
  1672. target is identical to the
  1673. .Li dv
  1674. target except that the pixel format set is
  1675. .Li yuv422p
  1676. for all three standards.
  1677. .Pp
  1678. Any user-set value for a parameter above will override the target preset value.
  1679. In that case, the output may not comply with the target standard.
  1680. .Pp
  1681. .It -dn ( Em input/output)
  1682. As an input option, blocks all data streams of a file from being filtered
  1683. or being automatically selected or mapped for any output. See
  1684. .Li -discard
  1685. option to disable streams individually.
  1686. .Pp
  1687. As an output option, disables data recording i.e. automatic selection or mapping
  1688. of any data stream. For full manual control see the
  1689. .Li -map
  1690. option.
  1691. .Pp
  1692. .It -dframes Va number ( Em output)
  1693. Set the number of data frames to output. This is an obsolete alias for
  1694. .Li -frames:d ,
  1695. which you should use instead.
  1696. .Pp
  1697. .It -frames[: Va stream_specifier] Va framecount ( Em output,per-stream)
  1698. Stop writing to the stream after
  1699. .Va framecount
  1700. frames.
  1701. .Pp
  1702. .It -q[: Va stream_specifier] Va q ( Em output,per-stream)
  1703. .It -qscale[: Va stream_specifier] Va q ( Em output,per-stream)
  1704. Use fixed quality scale (VBR). The meaning of
  1705. .Va q
  1706. /
  1707. .Va qscale
  1708. is codec-dependent. If
  1709. .Va qscale
  1710. is used without a
  1711. .Va stream_specifier
  1712. then it applies only to the video stream, this is to maintain compatibility
  1713. with previous behavior and as specifying the same codec specific value to
  1714. 2 different codecs that is audio and video generally is not what is intended
  1715. when no stream_specifier is used.
  1716. .Pp
  1717. .It -filter[: Va stream_specifier] Va filtergraph ( Em output,per-stream)
  1718. Create the filtergraph specified by
  1719. .Va filtergraph
  1720. and use it to filter the stream.
  1721. .Pp
  1722. .Va filtergraph
  1723. is a description of the filtergraph to apply to the stream, and must have
  1724. a single input and a single output of the same type of the stream. In the
  1725. filtergraph, the input is associated to the label
  1726. .Li in ,
  1727. and the output to the label
  1728. .Li out .
  1729. See the ffmpeg-filters manual for more information about the filtergraph syntax.
  1730. .Pp
  1731. See the filter_complex_option,,-filter_complex option if you want to create
  1732. filtergraphs with multiple inputs and/or outputs.
  1733. .Pp
  1734. .It -reinit_filter[: Va stream_specifier] Va integer ( Em input,per-stream)
  1735. This boolean option determines if the filtergraph(s) to which this stream
  1736. is fed gets reinitialized when input frame parameters change mid-stream. This
  1737. option is enabled by default as most video and all audio filters cannot handle
  1738. deviation in input frame properties. Upon reinitialization, existing filter
  1739. state is lost, like e.g. the frame count
  1740. .Li n
  1741. reference available in some filters. Any frames buffered at time of reinitialization
  1742. are lost. The properties where a change triggers reinitialization are, for
  1743. video, frame resolution or pixel format; for audio, sample format, sample
  1744. rate, channel count or channel layout.
  1745. .Pp
  1746. .It -filter_threads Va nb_threads ( Em global)
  1747. Defines how many threads are used to process a filter pipeline. Each pipeline
  1748. will produce a thread pool with this many threads available for parallel processing.
  1749. The default is the number of available CPUs.
  1750. .Pp
  1751. .It -pre[: Va stream_specifier] Va preset_name ( Em output,per-stream)
  1752. Specify the preset for matching stream(s).
  1753. .Pp
  1754. .It -stats ( Em global)
  1755. Print encoding progress/statistics. It is on by default, to explicitly disable
  1756. it you need to specify
  1757. .Li -nostats .
  1758. .Pp
  1759. .It -stats_period Va time ( Em global)
  1760. Set period at which encoding progress/statistics are updated. Default is 0.5
  1761. seconds.
  1762. .Pp
  1763. .It -progress Va url ( Em global)
  1764. Send program-friendly progress information to
  1765. .Va url .
  1766. .Pp
  1767. Progress information is written periodically and at the end of the encoding
  1768. process. It is made of "
  1769. .Va key
  1770. =
  1771. .Va value "
  1772. lines.
  1773. .Va key
  1774. consists of only alphanumeric characters. The last key of a sequence of progress
  1775. information is always "progress".
  1776. .Pp
  1777. The update period is set using
  1778. .Li -stats_period .
  1779. .Pp
  1780. .It -stdin
  1781. Enable interaction on standard input. On by default unless standard input
  1782. is used as an input. To explicitly disable interaction you need to specify
  1783. .Li -nostdin .
  1784. .Pp
  1785. Disabling interaction on standard input is useful, for example, if ffmpeg
  1786. is in the background process group. Roughly the same result can be achieved
  1787. with
  1788. .Li ffmpeg ... < /dev/null
  1789. but it requires a shell.
  1790. .Pp
  1791. .It -debug_ts ( Em global)
  1792. Print timestamp/latency information. It is off by default. This option is
  1793. mostly useful for testing and debugging purposes, and the output format may
  1794. change from one version to another, so it should not be employed by portable
  1795. scripts.
  1796. .Pp
  1797. See also the option
  1798. .Li -fdebug ts .
  1799. .Pp
  1800. .It -attach Va filename ( Em output)
  1801. Add an attachment to the output file. This is supported by a few formats like
  1802. Matroska for e.g. fonts used in rendering subtitles. Attachments are implemented
  1803. as a specific type of stream, so this option will add a new stream to the
  1804. file. It is then possible to use per-stream options on this stream in the
  1805. usual way. Attachment streams created with this option will be created after
  1806. all the other streams (i.e. those created with
  1807. .Li -map
  1808. or automatic mappings).
  1809. .Pp
  1810. Note that for Matroska you also have to set the mimetype metadata tag:
  1811. .Bd -literal -offset indent
  1812. ffmpeg -i INPUT -attach DejaVuSans.ttf -metadata:s:2 mimetype=application/x-truetype-font out.mkv
  1813. .Ed
  1814. (assuming that the attachment stream will be third in the output file).
  1815. .Pp
  1816. .It -dump_attachment[: Va stream_specifier] Va filename ( Em input,per-stream)
  1817. Extract the matching attachment stream into a file named
  1818. .Va filename .
  1819. If
  1820. .Va filename
  1821. is empty, then the value of the
  1822. .Li filename
  1823. metadata tag will be used.
  1824. .Pp
  1825. E.g. to extract the first attachment to a file named 'out.ttf':
  1826. .Bd -literal -offset indent
  1827. ffmpeg -dump_attachment:t:0 out.ttf -i INPUT
  1828. .Ed
  1829. To extract all attachments to files determined by the
  1830. .Li filename
  1831. tag:
  1832. .Bd -literal -offset indent
  1833. ffmpeg -dump_attachment:t "" -i INPUT
  1834. .Ed
  1835. .Pp
  1836. Technical note -- attachments are implemented as codec extradata, so this
  1837. option can actually be used to extract extradata from any stream, not just
  1838. attachments.
  1839. .El
  1840. .Pp
  1841. .Ss Video Options
  1842. .Bl -tag -width Ds
  1843. .It -vframes Va number ( Em output)
  1844. Set the number of video frames to output. This is an obsolete alias for
  1845. .Li -frames:v ,
  1846. which you should use instead.
  1847. .It -r[: Va stream_specifier] Va fps ( Em input/output,per-stream)
  1848. Set frame rate (Hz value, fraction or abbreviation).
  1849. .Pp
  1850. As an input option, ignore any timestamps stored in the file and instead generate
  1851. timestamps assuming constant frame rate
  1852. .Va fps .
  1853. This is not the same as the
  1854. .Op -framerate
  1855. option used for some input formats like image2 or v4l2 (it used to be the
  1856. same in older versions of FFmpeg). If in doubt use
  1857. .Op -framerate
  1858. instead of the input option
  1859. .Op -r .
  1860. .Pp
  1861. As an output option:
  1862. .Bl -tag -width Ds
  1863. .It video encoding
  1864. Duplicate or drop frames right before encoding them to achieve constant output
  1865. frame rate
  1866. .Va fps .
  1867. .Pp
  1868. .It video streamcopy
  1869. Indicate to the muxer that
  1870. .Va fps
  1871. is the stream frame rate. No data is dropped or duplicated in this case. This
  1872. may produce invalid files if
  1873. .Va fps
  1874. does not match the actual stream frame rate as determined by packet timestamps.
  1875. See also the
  1876. .Li setts
  1877. bitstream filter.
  1878. .Pp
  1879. .El
  1880. .It -fpsmax[: Va stream_specifier] Va fps ( Em output,per-stream)
  1881. Set maximum frame rate (Hz value, fraction or abbreviation).
  1882. .Pp
  1883. Clamps output frame rate when output framerate is auto-set and is higher than
  1884. this value. Useful in batch processing or when input framerate is wrongly
  1885. detected as very high. It cannot be set together with
  1886. .Li -r .
  1887. It is ignored during streamcopy.
  1888. .Pp
  1889. .It -s[: Va stream_specifier] Va size ( Em input/output,per-stream)
  1890. Set frame size.
  1891. .Pp
  1892. As an input option, this is a shortcut for the
  1893. .Op video_size
  1894. private option, recognized by some demuxers for which the frame size is either
  1895. not stored in the file or is configurable -- e.g. raw video or video grabbers.
  1896. .Pp
  1897. As an output option, this inserts the
  1898. .Li scale
  1899. video filter to the
  1900. .Em end
  1901. of the corresponding filtergraph. Please use the
  1902. .Li scale
  1903. filter directly to insert it at the beginning or some other place.
  1904. .Pp
  1905. The format is
  1906. .Li wxh
  1907. (default - same as source).
  1908. .Pp
  1909. .It -aspect[: Va stream_specifier] Va aspect ( Em output,per-stream)
  1910. Set the video display aspect ratio specified by
  1911. .Va aspect .
  1912. .Pp
  1913. .Va aspect
  1914. can be a floating point number string, or a string of the form
  1915. .Va num
  1916. :
  1917. .Va den ,
  1918. where
  1919. .Va num
  1920. and
  1921. .Va den
  1922. are the numerator and denominator of the aspect ratio. For example "4:3",
  1923. "16:9", "1.3333", and "1.7777" are valid argument values.
  1924. .Pp
  1925. If used together with
  1926. .Op -vcodec copy ,
  1927. it will affect the aspect ratio stored at container level, but not the aspect
  1928. ratio stored in encoded frames, if it exists.
  1929. .Pp
  1930. .It -display_rotation[: Va stream_specifier] Va rotation ( Em input,per-stream)
  1931. Set video rotation metadata.
  1932. .Pp
  1933. .Va rotation
  1934. is a decimal number specifying the amount in degree by which the video should
  1935. be rotated counter-clockwise before being displayed.
  1936. .Pp
  1937. This option overrides the rotation/display transform metadata stored in the
  1938. file, if any. When the video is being transcoded (rather than copied) and
  1939. .Li -autorotate
  1940. is enabled, the video will be rotated at the filtering stage. Otherwise, the
  1941. metadata will be written into the output file if the muxer supports it.
  1942. .Pp
  1943. If the
  1944. .Li -display_hflip
  1945. and/or
  1946. .Li -display_vflip
  1947. options are given, they are applied after the rotation specified by this option.
  1948. .Pp
  1949. .It -display_hflip[: Va stream_specifier] ( Em input,per-stream)
  1950. Set whether on display the image should be horizontally flipped.
  1951. .Pp
  1952. See the
  1953. .Li -display_rotation
  1954. option for more details.
  1955. .Pp
  1956. .It -display_vflip[: Va stream_specifier] ( Em input,per-stream)
  1957. Set whether on display the image should be vertically flipped.
  1958. .Pp
  1959. See the
  1960. .Li -display_rotation
  1961. option for more details.
  1962. .Pp
  1963. .It -vn ( Em input/output)
  1964. As an input option, blocks all video streams of a file from being filtered
  1965. or being automatically selected or mapped for any output. See
  1966. .Li -discard
  1967. option to disable streams individually.
  1968. .Pp
  1969. As an output option, disables video recording i.e. automatic selection or
  1970. mapping of any video stream. For full manual control see the
  1971. .Li -map
  1972. option.
  1973. .Pp
  1974. .It -vcodec Va codec ( Em output)
  1975. Set the video codec. This is an alias for
  1976. .Li -codec:v .
  1977. .Pp
  1978. .It -pass[: Va stream_specifier] Va n ( Em output,per-stream)
  1979. Select the pass number (1 or 2). It is used to do two-pass video encoding.
  1980. The statistics of the video are recorded in the first pass into a log file
  1981. (see also the option -passlogfile), and in the second pass that log file is
  1982. used to generate the video at the exact requested bitrate. On pass 1, you
  1983. may just deactivate audio and set output to null, examples for Windows and
  1984. Unix:
  1985. .Bd -literal -offset indent
  1986. ffmpeg -i foo.mov -c:v libxvid -pass 1 -an -f rawvideo -y NUL
  1987. ffmpeg -i foo.mov -c:v libxvid -pass 1 -an -f rawvideo -y /dev/null
  1988. .Ed
  1989. .Pp
  1990. .It -passlogfile[: Va stream_specifier] Va prefix ( Em output,per-stream)
  1991. Set two-pass log file name prefix to
  1992. .Va prefix ,
  1993. the default file name prefix is \(lqffmpeg2pass\(rq. The complete file name will be
  1994. .Pa PREFIX-N.log ,
  1995. where N is a number specific to the output stream
  1996. .Pp
  1997. .It -vf Va filtergraph ( Em output)
  1998. Create the filtergraph specified by
  1999. .Va filtergraph
  2000. and use it to filter the stream.
  2001. .Pp
  2002. This is an alias for
  2003. .Li -filter:v ,
  2004. see the filter_option,,-filter option.
  2005. .Pp
  2006. .It -autorotate
  2007. Automatically rotate the video according to file metadata. Enabled by default,
  2008. use
  2009. .Op -noautorotate
  2010. to disable it.
  2011. .Pp
  2012. .It -autoscale
  2013. Automatically scale the video according to the resolution of first frame.
  2014. Enabled by default, use
  2015. .Op -noautoscale
  2016. to disable it. When autoscale is disabled, all output frames of filter graph
  2017. might not be in the same resolution and may be inadequate for some encoder/muxer.
  2018. Therefore, it is not recommended to disable it unless you really know what
  2019. you are doing. Disable autoscale at your own risk.
  2020. .El
  2021. .Pp
  2022. .Ss Advanced Video options
  2023. .Bl -tag -width Ds
  2024. .It -pix_fmt[: Va stream_specifier] Va format ( Em input/output,per-stream)
  2025. Set pixel format. Use
  2026. .Li -pix_fmts
  2027. to show all the supported pixel formats. If the selected pixel format can
  2028. not be selected, ffmpeg will print a warning and select the best pixel format
  2029. supported by the encoder. If
  2030. .Va pix_fmt
  2031. is prefixed by a
  2032. .Li + ,
  2033. ffmpeg will exit with an error if the requested pixel format can not be selected,
  2034. and automatic conversions inside filtergraphs are disabled. If
  2035. .Va pix_fmt
  2036. is a single
  2037. .Li + ,
  2038. ffmpeg selects the same pixel format as the input (or graph output) and automatic
  2039. conversions are disabled.
  2040. .Pp
  2041. .It -sws_flags Va flags ( Em input/output)
  2042. Set default flags for the libswscale library. These flags are used by automatically
  2043. inserted
  2044. .Li scale
  2045. filters and those within simple filtergraphs, if not overridden within the
  2046. filtergraph definition.
  2047. .Pp
  2048. See the scaler_options,,ffmpeg-scaler manual,ffmpeg-scaler for a list of scaler
  2049. options.
  2050. .Pp
  2051. .It -rc_override[: Va stream_specifier] Va override ( Em output,per-stream)
  2052. Rate control override for specific intervals, formatted as "int,int,int" list
  2053. separated with slashes. Two first values are the beginning and end frame numbers,
  2054. last one is quantizer to use if positive, or quality factor if negative.
  2055. .Pp
  2056. .It -vstats
  2057. Dump video coding statistics to
  2058. .Pa vstats_HHMMSS.log .
  2059. See the vstats_file_format,,vstats file format section for the format description.
  2060. .Pp
  2061. .It -vstats_file Va file
  2062. Dump video coding statistics to
  2063. .Va file .
  2064. See the vstats_file_format,,vstats file format section for the format description.
  2065. .Pp
  2066. .It -vstats_version Va file
  2067. Specify which version of the vstats format to use. Default is
  2068. .Li 2 .
  2069. See the vstats_file_format,,vstats file format section for the format description.
  2070. .Pp
  2071. .It -vtag Va fourcc/tag ( Em output)
  2072. Force video tag/fourcc. This is an alias for
  2073. .Li -tag:v .
  2074. .Pp
  2075. .It -force_key_frames[: Va stream_specifier] Va time[, Va time...] ( Em output,per-stream)
  2076. .It -force_key_frames[: Va stream_specifier] expr: Va expr ( Em output,per-stream)
  2077. .It -force_key_frames[: Va stream_specifier] source ( Em output,per-stream)
  2078. .Pp
  2079. .Va force_key_frames
  2080. can take arguments of the following form:
  2081. .Pp
  2082. .Bl -tag -width Ds
  2083. .It Va time[, Va time...]
  2084. If the argument consists of timestamps, ffmpeg will round the specified times
  2085. to the nearest output timestamp as per the encoder time base and force a keyframe
  2086. at the first frame having timestamp equal or greater than the computed timestamp.
  2087. Note that if the encoder time base is too coarse, then the keyframes may be
  2088. forced on frames with timestamps lower than the specified time. The default
  2089. encoder time base is the inverse of the output framerate but may be set otherwise
  2090. via
  2091. .Li -enc_time_base .
  2092. .Pp
  2093. If one of the times is "
  2094. .Li chapters
  2095. [
  2096. .Va delta
  2097. ]", it is expanded into the time of the beginning of all chapters in the file,
  2098. shifted by
  2099. .Va delta ,
  2100. expressed as a time in seconds. This option can be useful to ensure that a
  2101. seek point is present at a chapter mark or any other designated place in the
  2102. output file.
  2103. .Pp
  2104. For example, to insert a key frame at 5 minutes, plus key frames 0.1 second
  2105. before the beginning of every chapter:
  2106. .Bd -literal -offset indent
  2107. -force_key_frames 0:05:00,chapters-0.1
  2108. .Ed
  2109. .Pp
  2110. .It expr: Va expr
  2111. If the argument is prefixed with
  2112. .Li expr: ,
  2113. the string
  2114. .Va expr
  2115. is interpreted like an expression and is evaluated for each frame. A key frame
  2116. is forced in case the evaluation is non-zero.
  2117. .Pp
  2118. The expression in
  2119. .Va expr
  2120. can contain the following constants:
  2121. .Bl -tag -width Ds
  2122. .It n
  2123. the number of current processed frame, starting from 0
  2124. .It n_forced
  2125. the number of forced frames
  2126. .It prev_forced_n
  2127. the number of the previous forced frame, it is
  2128. .Li NAN
  2129. when no keyframe was forced yet
  2130. .It prev_forced_t
  2131. the time of the previous forced frame, it is
  2132. .Li NAN
  2133. when no keyframe was forced yet
  2134. .It t
  2135. the time of the current processed frame
  2136. .El
  2137. .Pp
  2138. For example to force a key frame every 5 seconds, you can specify:
  2139. .Bd -literal -offset indent
  2140. -force_key_frames expr:gte(t,n_forced*5)
  2141. .Ed
  2142. .Pp
  2143. To force a key frame 5 seconds after the time of the last forced one, starting
  2144. from second 13:
  2145. .Bd -literal -offset indent
  2146. -force_key_frames expr:if(isnan(prev_forced_t),gte(t,13),gte(t,prev_forced_t+5))
  2147. .Ed
  2148. .Pp
  2149. .It source
  2150. If the argument is
  2151. .Li source ,
  2152. ffmpeg will force a key frame if the current frame being encoded is marked
  2153. as a key frame in its source. In cases where this particular source frame
  2154. has to be dropped, enforce the next available frame to become a key frame
  2155. instead.
  2156. .Pp
  2157. .El
  2158. Note that forcing too many keyframes is very harmful for the lookahead algorithms
  2159. of certain encoders: using fixed-GOP options or similar would be more efficient.
  2160. .Pp
  2161. .It -copyinkf[: Va stream_specifier] ( Em output,per-stream)
  2162. When doing stream copy, copy also non-key frames found at the beginning.
  2163. .Pp
  2164. .It -init_hw_device Va type[= Va name][: Va device[, Va key=value...]]
  2165. Initialise a new hardware device of type
  2166. .Va type
  2167. called
  2168. .Va name ,
  2169. using the given device parameters. If no name is specified it will receive
  2170. a default name of the form "
  2171. .Va type
  2172. %d".
  2173. .Pp
  2174. The meaning of
  2175. .Va device
  2176. and the following arguments depends on the device type:
  2177. .Bl -tag -width Ds
  2178. .It cuda
  2179. .Va device
  2180. is the number of the CUDA device.
  2181. .Pp
  2182. The following options are recognized:
  2183. .Bl -tag -width Ds
  2184. .It primary_ctx
  2185. If set to 1, uses the primary device context instead of creating a new one.
  2186. .El
  2187. .Pp
  2188. Examples:
  2189. .Bl -tag -width Ds
  2190. .It -init_hw_device cuda:1
  2191. Choose the second device on the system.
  2192. .Pp
  2193. .It -init_hw_device cuda:0,primary_ctx=1
  2194. Choose the first device and use the primary device context.
  2195. .El
  2196. .Pp
  2197. .It dxva2
  2198. .Va device
  2199. is the number of the Direct3D 9 display adapter.
  2200. .Pp
  2201. .It d3d11va
  2202. .Va device
  2203. is the number of the Direct3D 11 display adapter. If not specified, it will
  2204. attempt to use the default Direct3D 11 display adapter or the first Direct3D
  2205. 11 display adapter whose hardware VendorId is specified by
  2206. .Li vendor_id .
  2207. .Pp
  2208. Examples:
  2209. .Bl -tag -width Ds
  2210. .It -init_hw_device d3d11va
  2211. Create a d3d11va device on the default Direct3D 11 display adapter.
  2212. .Pp
  2213. .It -init_hw_device d3d11va:1
  2214. Create a d3d11va device on the Direct3D 11 display adapter specified by index
  2215. 1.
  2216. .Pp
  2217. .It -init_hw_device d3d11va:,vendor_id=0x8086
  2218. Create a d3d11va device on the first Direct3D 11 display adapter whose hardware
  2219. VendorId is 0x8086.
  2220. .El
  2221. .Pp
  2222. .It vaapi
  2223. .Va device
  2224. is either an X11 display name, a DRM render node or a DirectX adapter index.
  2225. If not specified, it will attempt to open the default X11 display (
  2226. .Em $DISPLAY )
  2227. and then the first DRM render node (
  2228. .Em /dev/dri/renderD128 ) ,
  2229. or the default DirectX adapter on Windows.
  2230. .Pp
  2231. The following options are recognized:
  2232. .Bl -tag -width Ds
  2233. .It kernel_driver
  2234. When
  2235. .Va device
  2236. is not specified, use this option to specify the name of the kernel driver
  2237. associated with the desired device. This option is available only when the
  2238. hardware acceleration method
  2239. .Em drm
  2240. and
  2241. .Em vaapi
  2242. are enabled.
  2243. .El
  2244. .Pp
  2245. Examples:
  2246. .Bl -tag -width Ds
  2247. .It -init_hw_device vaapi
  2248. Create a vaapi device on the default device.
  2249. .Pp
  2250. .It -init_hw_device vaapi:/dev/dri/renderD129
  2251. Create a vaapi device on DRM render node
  2252. .Pa /dev/dri/renderD129 .
  2253. .Pp
  2254. .It -init_hw_device vaapi:1
  2255. Create a vaapi device on DirectX adapter 1.
  2256. .Pp
  2257. .It -init_hw_device vaapi:,kernel_driver=i915
  2258. Create a vaapi device on a device associated with kernel driver
  2259. .Li i915 .
  2260. .El
  2261. .Pp
  2262. .It vdpau
  2263. .Va device
  2264. is an X11 display name. If not specified, it will attempt to open the default
  2265. X11 display (
  2266. .Em $DISPLAY ) .
  2267. .Pp
  2268. .It qsv
  2269. .Va device
  2270. selects a value in
  2271. .Li MFX_IMPL_* .
  2272. Allowed values are:
  2273. .Bl -tag -width Ds
  2274. .It auto
  2275. .It sw
  2276. .It hw
  2277. .It auto_any
  2278. .It hw_any
  2279. .It hw2
  2280. .It hw3
  2281. .It hw4
  2282. .El
  2283. If not specified,
  2284. .Li auto_any
  2285. is used. (Note that it may be easier to achieve the desired result for QSV
  2286. by creating the platform-appropriate subdevice (
  2287. .Li dxva2
  2288. or
  2289. .Li d3d11va
  2290. or
  2291. .Li vaapi )
  2292. and then deriving a QSV device from that.)
  2293. .Pp
  2294. The following options are recognized:
  2295. .Bl -tag -width Ds
  2296. .It child_device
  2297. Specify a DRM render node on Linux or DirectX adapter on Windows.
  2298. .It child_device_type
  2299. Choose platform-appropriate subdevice type. On Windows
  2300. .Li d3d11va
  2301. is used as default subdevice type when
  2302. .Li --enable-libvpl
  2303. is specified at configuration time,
  2304. .Li dxva2
  2305. is used as default subdevice type when
  2306. .Li --enable-libmfx
  2307. is specified at configuration time. On Linux user can use
  2308. .Li vaapi
  2309. only as subdevice type.
  2310. .El
  2311. .Pp
  2312. Examples:
  2313. .Bl -tag -width Ds
  2314. .It -init_hw_device qsv:hw,child_device=/dev/dri/renderD129
  2315. Create a QSV device with
  2316. .Li MFX_IMPL_HARDWARE
  2317. on DRM render node
  2318. .Pa /dev/dri/renderD129 .
  2319. .Pp
  2320. .It -init_hw_device qsv:hw,child_device=1
  2321. Create a QSV device with
  2322. .Li MFX_IMPL_HARDWARE
  2323. on DirectX adapter 1.
  2324. .Pp
  2325. .It -init_hw_device qsv:hw,child_device_type=d3d11va
  2326. Choose the GPU subdevice with type
  2327. .Li d3d11va
  2328. and create QSV device with
  2329. .Li MFX_IMPL_HARDWARE .
  2330. .Pp
  2331. .It -init_hw_device qsv:hw,child_device_type=dxva2
  2332. Choose the GPU subdevice with type
  2333. .Li dxva2
  2334. and create QSV device with
  2335. .Li MFX_IMPL_HARDWARE .
  2336. .Pp
  2337. .It -init_hw_device qsv:hw,child_device=1,child_device_type=d3d11va
  2338. Create a QSV device with
  2339. .Li MFX_IMPL_HARDWARE
  2340. on DirectX adapter 1 with subdevice type
  2341. .Li d3d11va .
  2342. .Pp
  2343. .It -init_hw_device vaapi=va:/dev/dri/renderD129 -init_hw_device qsv=hw1@ Va va
  2344. Create a VAAPI device called
  2345. .Li va
  2346. on
  2347. .Pa /dev/dri/renderD129 ,
  2348. then derive a QSV device called
  2349. .Li hw1
  2350. from device
  2351. .Li va .
  2352. .Pp
  2353. .El
  2354. .It opencl
  2355. .Va device
  2356. selects the platform and device as
  2357. .Em platform_index.device_index .
  2358. .Pp
  2359. The set of devices can also be filtered using the key-value pairs to find
  2360. only devices matching particular platform or device strings.
  2361. .Pp
  2362. The strings usable as filters are:
  2363. .Bl -tag -width Ds
  2364. .It platform_profile
  2365. .It platform_version
  2366. .It platform_name
  2367. .It platform_vendor
  2368. .It platform_extensions
  2369. .It device_name
  2370. .It device_vendor
  2371. .It driver_version
  2372. .It device_version
  2373. .It device_profile
  2374. .It device_extensions
  2375. .It device_type
  2376. .El
  2377. .Pp
  2378. The indices and filters must together uniquely select a device.
  2379. .Pp
  2380. Examples:
  2381. .Bl -tag -width Ds
  2382. .It -init_hw_device opencl:0.1
  2383. Choose the second device on the first platform.
  2384. .Pp
  2385. .It -init_hw_device opencl:,device_name=Foo9000
  2386. Choose the device with a name containing the string
  2387. .Em Foo9000 .
  2388. .Pp
  2389. .It -init_hw_device opencl:1,device_type=gpu,device_extensions=cl_khr_fp16
  2390. Choose the GPU device on the second platform supporting the
  2391. .Em cl_khr_fp16
  2392. extension.
  2393. .El
  2394. .Pp
  2395. .It vulkan
  2396. If
  2397. .Va device
  2398. is an integer, it selects the device by its index in a system-dependent list
  2399. of devices. If
  2400. .Va device
  2401. is any other string, it selects the first device with a name containing that
  2402. string as a substring.
  2403. .Pp
  2404. The following options are recognized:
  2405. .Bl -tag -width Ds
  2406. .It debug
  2407. If set to 1, enables the validation layer, if installed.
  2408. .It linear_images
  2409. If set to 1, images allocated by the hwcontext will be linear and locally
  2410. mappable.
  2411. .It instance_extensions
  2412. A plus separated list of additional instance extensions to enable.
  2413. .It device_extensions
  2414. A plus separated list of additional device extensions to enable.
  2415. .El
  2416. .Pp
  2417. Examples:
  2418. .Bl -tag -width Ds
  2419. .It -init_hw_device vulkan:1
  2420. Choose the second device on the system.
  2421. .Pp
  2422. .It -init_hw_device vulkan:RADV
  2423. Choose the first device with a name containing the string
  2424. .Em RADV .
  2425. .Pp
  2426. .It -init_hw_device vulkan:0,instance_extensions=VK_KHR_wayland_surface+VK_KHR_xcb_surface
  2427. Choose the first device and enable the Wayland and XCB instance extensions.
  2428. .El
  2429. .Pp
  2430. .El
  2431. .It -init_hw_device Va type[= Va name]@ Va source
  2432. Initialise a new hardware device of type
  2433. .Va type
  2434. called
  2435. .Va name ,
  2436. deriving it from the existing device with the name
  2437. .Va source .
  2438. .Pp
  2439. .It -init_hw_device list
  2440. List all hardware device types supported in this build of ffmpeg.
  2441. .Pp
  2442. .It -filter_hw_device Va name
  2443. Pass the hardware device called
  2444. .Va name
  2445. to all filters in any filter graph. This can be used to set the device to
  2446. upload to with the
  2447. .Li hwupload
  2448. filter, or the device to map to with the
  2449. .Li hwmap
  2450. filter. Other filters may also make use of this parameter when they require
  2451. a hardware device. Note that this is typically only required when the input
  2452. is not already in hardware frames - when it is, filters will derive the device
  2453. they require from the context of the frames they receive as input.
  2454. .Pp
  2455. This is a global setting, so all filters will receive the same device.
  2456. .Pp
  2457. .It -hwaccel[: Va stream_specifier] Va hwaccel ( Em input,per-stream)
  2458. Use hardware acceleration to decode the matching stream(s). The allowed values
  2459. of
  2460. .Va hwaccel
  2461. are:
  2462. .Bl -tag -width Ds
  2463. .It none
  2464. Do not use any hardware acceleration (the default).
  2465. .Pp
  2466. .It auto
  2467. Automatically select the hardware acceleration method.
  2468. .Pp
  2469. .It vdpau
  2470. Use VDPAU (Video Decode and Presentation API for Unix) hardware acceleration.
  2471. .Pp
  2472. .It dxva2
  2473. Use DXVA2 (DirectX Video Acceleration) hardware acceleration.
  2474. .Pp
  2475. .It d3d11va
  2476. Use D3D11VA (DirectX Video Acceleration) hardware acceleration.
  2477. .Pp
  2478. .It vaapi
  2479. Use VAAPI (Video Acceleration API) hardware acceleration.
  2480. .Pp
  2481. .It qsv
  2482. Use the Intel QuickSync Video acceleration for video transcoding.
  2483. .Pp
  2484. Unlike most other values, this option does not enable accelerated decoding
  2485. (that is used automatically whenever a qsv decoder is selected), but accelerated
  2486. transcoding, without copying the frames into the system memory.
  2487. .Pp
  2488. For it to work, both the decoder and the encoder must support QSV acceleration
  2489. and no filters must be used.
  2490. .El
  2491. .Pp
  2492. This option has no effect if the selected hwaccel is not available or not
  2493. supported by the chosen decoder.
  2494. .Pp
  2495. Note that most acceleration methods are intended for playback and will not
  2496. be faster than software decoding on modern CPUs. Additionally,
  2497. .Xr ffmpeg
  2498. will usually need to copy the decoded frames from the GPU memory into the
  2499. system memory, resulting in further performance loss. This option is thus
  2500. mainly useful for testing.
  2501. .Pp
  2502. .It -hwaccel_device[: Va stream_specifier] Va hwaccel_device ( Em input,per-stream)
  2503. Select a device to use for hardware acceleration.
  2504. .Pp
  2505. This option only makes sense when the
  2506. .Op -hwaccel
  2507. option is also specified. It can either refer to an existing device created
  2508. with
  2509. .Op -init_hw_device
  2510. by name, or it can create a new device as if
  2511. .Li -init_hw_device
  2512. .Va type
  2513. :
  2514. .Va hwaccel_device
  2515. were called immediately before.
  2516. .Pp
  2517. .It -hwaccels
  2518. List all hardware acceleration components enabled in this build of ffmpeg.
  2519. Actual runtime availability depends on the hardware and its suitable driver
  2520. being installed.
  2521. .Pp
  2522. .It -fix_sub_duration_heartbeat[: Va stream_specifier]
  2523. Set a specific output video stream as the heartbeat stream according to which
  2524. to split and push through currently in-progress subtitle upon receipt of a
  2525. random access packet.
  2526. .Pp
  2527. This lowers the latency of subtitles for which the end packet or the following
  2528. subtitle has not yet been received. As a drawback, this will most likely lead
  2529. to duplication of subtitle events in order to cover the full duration, so
  2530. when dealing with use cases where latency of when the subtitle event is passed
  2531. on to output is not relevant this option should not be utilized.
  2532. .Pp
  2533. Requires
  2534. .Op -fix_sub_duration
  2535. to be set for the relevant input subtitle stream for this to have any effect,
  2536. as well as for the input subtitle stream having to be directly mapped to the
  2537. same output in which the heartbeat stream resides.
  2538. .Pp
  2539. .El
  2540. .Ss Audio Options
  2541. .Bl -tag -width Ds
  2542. .It -aframes Va number ( Em output)
  2543. Set the number of audio frames to output. This is an obsolete alias for
  2544. .Li -frames:a ,
  2545. which you should use instead.
  2546. .It -ar[: Va stream_specifier] Va freq ( Em input/output,per-stream)
  2547. Set the audio sampling frequency. For output streams it is set by default
  2548. to the frequency of the corresponding input stream. For input streams this
  2549. option only makes sense for audio grabbing devices and raw demuxers and is
  2550. mapped to the corresponding demuxer options.
  2551. .It -aq Va q ( Em output)
  2552. Set the audio quality (codec-specific, VBR). This is an alias for -q:a.
  2553. .It -ac[: Va stream_specifier] Va channels ( Em input/output,per-stream)
  2554. Set the number of audio channels. For output streams it is set by default
  2555. to the number of input audio channels. For input streams this option only
  2556. makes sense for audio grabbing devices and raw demuxers and is mapped to the
  2557. corresponding demuxer options.
  2558. .It -an ( Em input/output)
  2559. As an input option, blocks all audio streams of a file from being filtered
  2560. or being automatically selected or mapped for any output. See
  2561. .Li -discard
  2562. option to disable streams individually.
  2563. .Pp
  2564. As an output option, disables audio recording i.e. automatic selection or
  2565. mapping of any audio stream. For full manual control see the
  2566. .Li -map
  2567. option.
  2568. .It -acodec Va codec ( Em input/output)
  2569. Set the audio codec. This is an alias for
  2570. .Li -codec:a .
  2571. .It -sample_fmt[: Va stream_specifier] Va sample_fmt ( Em output,per-stream)
  2572. Set the audio sample format. Use
  2573. .Li -sample_fmts
  2574. to get a list of supported sample formats.
  2575. .Pp
  2576. .It -af Va filtergraph ( Em output)
  2577. Create the filtergraph specified by
  2578. .Va filtergraph
  2579. and use it to filter the stream.
  2580. .Pp
  2581. This is an alias for
  2582. .Li -filter:a ,
  2583. see the filter_option,,-filter option.
  2584. .El
  2585. .Pp
  2586. .Ss Advanced Audio options
  2587. .Bl -tag -width Ds
  2588. .It -atag Va fourcc/tag ( Em output)
  2589. Force audio tag/fourcc. This is an alias for
  2590. .Li -tag:a .
  2591. .It -guess_layout_max Va channels ( Em input,per-stream)
  2592. If some input channel layout is not known, try to guess only if it corresponds
  2593. to at most the specified number of channels. For example, 2 tells to
  2594. .Xr ffmpeg
  2595. to recognize 1 channel as mono and 2 channels as stereo but not 6 channels
  2596. as 5.1. The default is to always try to guess. Use 0 to disable all guessing.
  2597. .El
  2598. .Pp
  2599. .Ss Subtitle options
  2600. .Bl -tag -width Ds
  2601. .It -scodec Va codec ( Em input/output)
  2602. Set the subtitle codec. This is an alias for
  2603. .Li -codec:s .
  2604. .It -sn ( Em input/output)
  2605. As an input option, blocks all subtitle streams of a file from being filtered
  2606. or being automatically selected or mapped for any output. See
  2607. .Li -discard
  2608. option to disable streams individually.
  2609. .Pp
  2610. As an output option, disables subtitle recording i.e. automatic selection
  2611. or mapping of any subtitle stream. For full manual control see the
  2612. .Li -map
  2613. option.
  2614. .El
  2615. .Pp
  2616. .Ss Advanced Subtitle options
  2617. .Bl -tag -width Ds
  2618. .It -fix_sub_duration
  2619. Fix subtitles durations. For each subtitle, wait for the next packet in the
  2620. same stream and adjust the duration of the first to avoid overlap. This is
  2621. necessary with some subtitles codecs, especially DVB subtitles, because the
  2622. duration in the original packet is only a rough estimate and the end is actually
  2623. marked by an empty subtitle frame. Failing to use this option when necessary
  2624. can result in exaggerated durations or muxing failures due to non-monotonic
  2625. timestamps.
  2626. .Pp
  2627. Note that this option will delay the output of all data until the next subtitle
  2628. packet is decoded: it may increase memory consumption and latency a lot.
  2629. .Pp
  2630. .It -canvas_size Va size
  2631. Set the size of the canvas used to render subtitles.
  2632. .Pp
  2633. .El
  2634. .Ss Advanced options
  2635. .Bl -tag -width Ds
  2636. .It -map [-] Va input_file_id[: Va stream_specifier][?] | Va [linklabel] ( Em output)
  2637. .Pp
  2638. Create one or more streams in the output file. This option has two forms for
  2639. specifying the data source(s): the first selects one or more streams from
  2640. some input file (specified with
  2641. .Li -i ) ,
  2642. the second takes an output from some complex filtergraph (specified with
  2643. .Li -filter_complex ) .
  2644. .Pp
  2645. In the first form, an output stream is created for every stream from the input
  2646. file with the index
  2647. .Va input_file_id .
  2648. If
  2649. .Va stream_specifier
  2650. is given, only those streams that match the specifier are used (see the Stream
  2651. specifiers section for the
  2652. .Va stream_specifier
  2653. syntax).
  2654. .Pp
  2655. A
  2656. .Li -
  2657. character before the stream identifier creates a "negative" mapping. It disables
  2658. matching streams from already created mappings.
  2659. .Pp
  2660. A trailing
  2661. .Li ?
  2662. after the stream index will allow the map to be optional: if the map matches
  2663. no streams the map will be ignored instead of failing. Note the map will still
  2664. fail if an invalid input file index is used; such as if the map refers to
  2665. a non-existent input.
  2666. .Pp
  2667. An alternative
  2668. .Va [linklabel]
  2669. form will map outputs from complex filter graphs (see the
  2670. .Op -filter_complex
  2671. option) to the output file.
  2672. .Va linklabel
  2673. must correspond to a defined output link label in the graph.
  2674. .Pp
  2675. This option may be specified multiple times, each adding more streams to the
  2676. output file. Any given input stream may also be mapped any number of times
  2677. as a source for different output streams, e.g. in order to use different encoding
  2678. options and/or filters. The streams are created in the output in the same
  2679. order in which the
  2680. .Li -map
  2681. options are given on the commandline.
  2682. .Pp
  2683. Using this option disables the default mappings for this output file.
  2684. .Pp
  2685. Examples:
  2686. .Pp
  2687. .Bl -tag -width Ds
  2688. .It map everything
  2689. To map ALL streams from the first input file to output
  2690. .Bd -literal -offset indent
  2691. ffmpeg -i INPUT -map 0 output
  2692. .Ed
  2693. .Pp
  2694. .It select specific stream
  2695. If you have two audio streams in the first input file, these streams are identified
  2696. by
  2697. .Va 0:0
  2698. and
  2699. .Va 0:1 .
  2700. You can use
  2701. .Li -map
  2702. to select which streams to place in an output file. For example:
  2703. .Bd -literal -offset indent
  2704. ffmpeg -i INPUT -map 0:1 out.wav
  2705. .Ed
  2706. will map the second input stream in
  2707. .Pa INPUT
  2708. to the (single) output stream in
  2709. .Pa out.wav .
  2710. .Pp
  2711. .It create multiple streams
  2712. To select the stream with index 2 from input file
  2713. .Pa a.mov
  2714. (specified by the identifier
  2715. .Va 0:2 ) ,
  2716. and stream with index 6 from input
  2717. .Pa b.mov
  2718. (specified by the identifier
  2719. .Va 1:6 ) ,
  2720. and copy them to the output file
  2721. .Pa out.mov :
  2722. .Bd -literal -offset indent
  2723. ffmpeg -i a.mov -i b.mov -c copy -map 0:2 -map 1:6 out.mov
  2724. .Ed
  2725. .Pp
  2726. .It create multiple streams 2
  2727. To select all video and the third audio stream from an input file:
  2728. .Bd -literal -offset indent
  2729. ffmpeg -i INPUT -map 0:v -map 0:a:2 OUTPUT
  2730. .Ed
  2731. .Pp
  2732. .It negative map
  2733. To map all the streams except the second audio, use negative mappings
  2734. .Bd -literal -offset indent
  2735. ffmpeg -i INPUT -map 0 -map -0:a:1 OUTPUT
  2736. .Ed
  2737. .Pp
  2738. .It optional map
  2739. To map the video and audio streams from the first input, and using the trailing
  2740. .Li ? ,
  2741. ignore the audio mapping if no audio streams exist in the first input:
  2742. .Bd -literal -offset indent
  2743. ffmpeg -i INPUT -map 0:v -map 0:a? OUTPUT
  2744. .Ed
  2745. .Pp
  2746. .It map by language
  2747. To pick the English audio stream:
  2748. .Bd -literal -offset indent
  2749. ffmpeg -i INPUT -map 0:m:language:eng OUTPUT
  2750. .Ed
  2751. .Pp
  2752. .El
  2753. .It -ignore_unknown
  2754. Ignore input streams with unknown type instead of failing if copying such
  2755. streams is attempted.
  2756. .Pp
  2757. .It -copy_unknown
  2758. Allow input streams with unknown type to be copied instead of failing if copying
  2759. such streams is attempted.
  2760. .Pp
  2761. .It -map_metadata[: Va metadata_spec_out] Va infile[: Va metadata_spec_in] ( Em output,per-metadata)
  2762. Set metadata information of the next output file from
  2763. .Va infile .
  2764. Note that those are file indices (zero-based), not filenames. Optional
  2765. .Va metadata_spec_in/out
  2766. parameters specify, which metadata to copy. A metadata specifier can have
  2767. the following forms:
  2768. .Bl -tag -width Ds
  2769. .It Va g
  2770. global metadata, i.e. metadata that applies to the whole file
  2771. .Pp
  2772. .It Va s[: Va stream_spec]
  2773. per-stream metadata.
  2774. .Va stream_spec
  2775. is a stream specifier as described in the Stream specifiers chapter. In an
  2776. input metadata specifier, the first matching stream is copied from. In an
  2777. output metadata specifier, all matching streams are copied to.
  2778. .Pp
  2779. .It Va c: Va chapter_index
  2780. per-chapter metadata.
  2781. .Va chapter_index
  2782. is the zero-based chapter index.
  2783. .Pp
  2784. .It Va p: Va program_index
  2785. per-program metadata.
  2786. .Va program_index
  2787. is the zero-based program index.
  2788. .El
  2789. If metadata specifier is omitted, it defaults to global.
  2790. .Pp
  2791. By default, global metadata is copied from the first input file, per-stream
  2792. and per-chapter metadata is copied along with streams/chapters. These default
  2793. mappings are disabled by creating any mapping of the relevant type. A negative
  2794. file index can be used to create a dummy mapping that just disables automatic
  2795. copying.
  2796. .Pp
  2797. For example to copy metadata from the first stream of the input file to global
  2798. metadata of the output file:
  2799. .Bd -literal -offset indent
  2800. ffmpeg -i in.ogg -map_metadata 0:s:0 out.mp3
  2801. .Ed
  2802. .Pp
  2803. To do the reverse, i.e. copy global metadata to all audio streams:
  2804. .Bd -literal -offset indent
  2805. ffmpeg -i in.mkv -map_metadata:s:a 0:g out.mkv
  2806. .Ed
  2807. Note that simple
  2808. .Li 0
  2809. would work as well in this example, since global metadata is assumed by default.
  2810. .Pp
  2811. .It -map_chapters Va input_file_index ( Em output)
  2812. Copy chapters from input file with index
  2813. .Va input_file_index
  2814. to the next output file. If no chapter mapping is specified, then chapters
  2815. are copied from the first input file with at least one chapter. Use a negative
  2816. file index to disable any chapter copying.
  2817. .Pp
  2818. .It -benchmark ( Em global)
  2819. Show benchmarking information at the end of an encode. Shows real, system
  2820. and user time used and maximum memory consumption. Maximum memory consumption
  2821. is not supported on all systems, it will usually display as 0 if not supported.
  2822. .It -benchmark_all ( Em global)
  2823. Show benchmarking information during the encode. Shows real, system and user
  2824. time used in various steps (audio/video encode/decode).
  2825. .It -timelimit Va duration ( Em global)
  2826. Exit after ffmpeg has been running for
  2827. .Va duration
  2828. seconds in CPU user time.
  2829. .It -dump ( Em global)
  2830. Dump each input packet to stderr.
  2831. .It -hex ( Em global)
  2832. When dumping packets, also dump the payload.
  2833. .It -readrate Va speed ( Em input)
  2834. Limit input read speed.
  2835. .Pp
  2836. Its value is a floating-point positive number which represents the maximum
  2837. duration of media, in seconds, that should be ingested in one second of wallclock
  2838. time. Default value is zero and represents no imposed limitation on speed
  2839. of ingestion. Value
  2840. .Li 1
  2841. represents real-time speed and is equivalent to
  2842. .Li -re .
  2843. .Pp
  2844. Mainly used to simulate a capture device or live input stream (e.g. when reading
  2845. from a file). Should not be used with a low value when input is an actual
  2846. capture device or live stream as it may cause packet loss.
  2847. .Pp
  2848. It is useful for when flow speed of output packets is important, such as live
  2849. streaming.
  2850. .It -re ( Em input)
  2851. Read input at native frame rate. This is equivalent to setting
  2852. .Li -readrate 1 .
  2853. .It -readrate_initial_burst Va seconds
  2854. Set an initial read burst time, in seconds, after which
  2855. .Op -re/-readrate
  2856. will be enforced.
  2857. .It -vsync Va parameter ( Em global)
  2858. .It -fps_mode[: Va stream_specifier] Va parameter ( Em output,per-stream)
  2859. Set video sync method / framerate mode. vsync is applied to all output video
  2860. streams but can be overridden for a stream by setting fps_mode. vsync is deprecated
  2861. and will be removed in the future.
  2862. .Pp
  2863. For compatibility reasons some of the values for vsync can be specified as
  2864. numbers (shown in parentheses in the following table).
  2865. .Pp
  2866. .Bl -tag -width Ds
  2867. .It passthrough (0)
  2868. Each frame is passed with its timestamp from the demuxer to the muxer.
  2869. .It cfr (1)
  2870. Frames will be duplicated and dropped to achieve exactly the requested constant
  2871. frame rate.
  2872. .It vfr (2)
  2873. Frames are passed through with their timestamp or dropped so as to prevent
  2874. 2 frames from having the same timestamp.
  2875. .It auto (-1)
  2876. Chooses between cfr and vfr depending on muxer capabilities. This is the default
  2877. method.
  2878. .El
  2879. .Pp
  2880. Note that the timestamps may be further modified by the muxer, after this.
  2881. For example, in the case that the format option
  2882. .Op avoid_negative_ts
  2883. is enabled.
  2884. .Pp
  2885. With -map you can select from which stream the timestamps should be taken.
  2886. You can leave either video or audio unchanged and sync the remaining stream(s)
  2887. to the unchanged one.
  2888. .Pp
  2889. .It -frame_drop_threshold Va parameter
  2890. Frame drop threshold, which specifies how much behind video frames can be
  2891. before they are dropped. In frame rate units, so 1.0 is one frame. The default
  2892. is -1.1. One possible usecase is to avoid framedrops in case of noisy timestamps
  2893. or to increase frame drop precision in case of exact timestamps.
  2894. .Pp
  2895. .It -apad Va parameters ( Em output,per-stream)
  2896. Pad the output audio stream(s). This is the same as applying
  2897. .Li -af apad .
  2898. Argument is a string of filter parameters composed the same as with the
  2899. .Li apad
  2900. filter.
  2901. .Li -shortest
  2902. must be set for this output for the option to take effect.
  2903. .Pp
  2904. .It -copyts
  2905. Do not process input timestamps, but keep their values without trying to sanitize
  2906. them. In particular, do not remove the initial start time offset value.
  2907. .Pp
  2908. Note that, depending on the
  2909. .Op vsync
  2910. option or on specific muxer processing (e.g. in case the format option
  2911. .Op avoid_negative_ts
  2912. is enabled) the output timestamps may mismatch with the input timestamps even
  2913. when this option is selected.
  2914. .Pp
  2915. .It -start_at_zero
  2916. When used with
  2917. .Op copyts ,
  2918. shift input timestamps so they start at zero.
  2919. .Pp
  2920. This means that using e.g.
  2921. .Li -ss 50
  2922. will make output timestamps start at 50 seconds, regardless of what timestamp
  2923. the input file started at.
  2924. .Pp
  2925. .It -copytb Va mode
  2926. Specify how to set the encoder timebase when stream copying.
  2927. .Va mode
  2928. is an integer numeric value, and can assume one of the following values:
  2929. .Pp
  2930. .Bl -tag -width Ds
  2931. .It 1
  2932. Use the demuxer timebase.
  2933. .Pp
  2934. The time base is copied to the output encoder from the corresponding input
  2935. demuxer. This is sometimes required to avoid non monotonically increasing
  2936. timestamps when copying video streams with variable frame rate.
  2937. .Pp
  2938. .It 0
  2939. Use the decoder timebase.
  2940. .Pp
  2941. The time base is copied to the output encoder from the corresponding input
  2942. decoder.
  2943. .Pp
  2944. .It -1
  2945. Try to make the choice automatically, in order to generate a sane output.
  2946. .El
  2947. .Pp
  2948. Default value is -1.
  2949. .Pp
  2950. .It -enc_time_base[: Va stream_specifier] Va timebase ( Em output,per-stream)
  2951. Set the encoder timebase.
  2952. .Va timebase
  2953. can assume one of the following values:
  2954. .Pp
  2955. .Bl -tag -width Ds
  2956. .It 0
  2957. Assign a default value according to the media type.
  2958. .Pp
  2959. For video - use 1/framerate, for audio - use 1/samplerate.
  2960. .Pp
  2961. .It demux
  2962. Use the timebase from the demuxer.
  2963. .Pp
  2964. .It filter
  2965. Use the timebase from the filtergraph.
  2966. .Pp
  2967. .It a positive number
  2968. Use the provided number as the timebase.
  2969. .Pp
  2970. This field can be provided as a ratio of two integers (e.g. 1:24, 1:48000)
  2971. or as a decimal number (e.g. 0.04166, 2.0833e-5)
  2972. .El
  2973. .Pp
  2974. Default value is 0.
  2975. .Pp
  2976. .It -bitexact ( Em input/output)
  2977. Enable bitexact mode for (de)muxer and (de/en)coder
  2978. .It -shortest ( Em output)
  2979. Finish encoding when the shortest output stream ends.
  2980. .Pp
  2981. Note that this option may require buffering frames, which introduces extra
  2982. latency. The maximum amount of this latency may be controlled with the
  2983. .Li -shortest_buf_duration
  2984. option.
  2985. .Pp
  2986. .It -shortest_buf_duration Va duration ( Em output)
  2987. The
  2988. .Li -shortest
  2989. option may require buffering potentially large amounts of data when at least
  2990. one of the streams is "sparse" (i.e. has large gaps between frames – this
  2991. is typically the case for subtitles).
  2992. .Pp
  2993. This option controls the maximum duration of buffered frames in seconds. Larger
  2994. values may allow the
  2995. .Li -shortest
  2996. option to produce more accurate results, but increase memory use and latency.
  2997. .Pp
  2998. The default value is 10 seconds.
  2999. .Pp
  3000. .It -dts_delta_threshold Va threshold
  3001. Timestamp discontinuity delta threshold, expressed as a decimal number of
  3002. seconds.
  3003. .Pp
  3004. The timestamp discontinuity correction enabled by this option is only applied
  3005. to input formats accepting timestamp discontinuity (for which the
  3006. .Li AVFMT_TS_DISCONT
  3007. flag is enabled), e.g. MPEG-TS and HLS, and is automatically disabled when
  3008. employing the
  3009. .Li -copyts
  3010. option (unless wrapping is detected).
  3011. .Pp
  3012. If a timestamp discontinuity is detected whose absolute value is greater than
  3013. .Va threshold ,
  3014. ffmpeg will remove the discontinuity by decreasing/increasing the current
  3015. DTS and PTS by the corresponding delta value.
  3016. .Pp
  3017. The default value is 10.
  3018. .Pp
  3019. .It -dts_error_threshold Va threshold
  3020. Timestamp error delta threshold, expressed as a decimal number of seconds.
  3021. .Pp
  3022. The timestamp correction enabled by this option is only applied to input formats
  3023. not accepting timestamp discontinuity (for which the
  3024. .Li AVFMT_TS_DISCONT
  3025. flag is not enabled).
  3026. .Pp
  3027. If a timestamp discontinuity is detected whose absolute value is greater than
  3028. .Va threshold ,
  3029. ffmpeg will drop the PTS/DTS timestamp value.
  3030. .Pp
  3031. The default value is
  3032. .Li 3600*30
  3033. (30 hours), which is arbitrarily picked and quite conservative.
  3034. .Pp
  3035. .It -muxdelay Va seconds ( Em output)
  3036. Set the maximum demux-decode delay.
  3037. .It -muxpreload Va seconds ( Em output)
  3038. Set the initial demux-decode delay.
  3039. .It -streamid Va output-stream-index: Va new-value ( Em output)
  3040. Assign a new stream-id value to an output stream. This option should be specified
  3041. prior to the output filename to which it applies. For the situation where
  3042. multiple output files exist, a streamid may be reassigned to a different value.
  3043. .Pp
  3044. For example, to set the stream 0 PID to 33 and the stream 1 PID to 36 for
  3045. an output mpegts file:
  3046. .Bd -literal -offset indent
  3047. ffmpeg -i inurl -streamid 0:33 -streamid 1:36 out.ts
  3048. .Ed
  3049. .Pp
  3050. .It -bsf[: Va stream_specifier] Va bitstream_filters ( Em input/output,per-stream)
  3051. Apply bitstream filters to matching streams. The filters are applied to each
  3052. packet as it is received from the demuxer (when used as an input option) or
  3053. before it is sent to the muxer (when used as an output option).
  3054. .Pp
  3055. .Va bitstream_filters
  3056. is a comma-separated list of bitstream filter specifications, each of the
  3057. form
  3058. .Bd -literal -offset indent
  3059. filter[=optname0=optval0:optname1=optval1:...]
  3060. .Ed
  3061. Any of the ',=:' characters that are to be a part of an option value need
  3062. to be escaped with a backslash.
  3063. .Pp
  3064. Use the
  3065. .Li -bsfs
  3066. option to get the list of bitstream filters.
  3067. .Pp
  3068. E.g.
  3069. .Bd -literal -offset indent
  3070. ffmpeg -bsf:v h264_mp4toannexb -i h264.mp4 -c:v copy -an out.h264
  3071. .Ed
  3072. applies the
  3073. .Li h264_mp4toannexb
  3074. bitstream filter (which converts MP4-encapsulated H.264 stream to Annex B)
  3075. to the
  3076. .Em input
  3077. video stream.
  3078. .Pp
  3079. On the other hand,
  3080. .Bd -literal -offset indent
  3081. ffmpeg -i file.mov -an -vn -bsf:s mov2textsub -c:s copy -f rawvideo sub.txt
  3082. .Ed
  3083. applies the
  3084. .Li mov2textsub
  3085. bitstream filter (which extracts text from MOV subtitles) to the
  3086. .Em output
  3087. subtitle stream. Note, however, that since both examples use
  3088. .Li -c copy ,
  3089. it matters little whether the filters are applied on input or output - that
  3090. would change if transcoding was happening.
  3091. .Pp
  3092. .It -tag[: Va stream_specifier] Va codec_tag ( Em input/output,per-stream)
  3093. Force a tag/fourcc for matching streams.
  3094. .Pp
  3095. .It -timecode Va hh: Va mm: Va ssSEP Va ff
  3096. Specify Timecode for writing.
  3097. .Va SEP
  3098. is ':' for non drop timecode and ';' (or '.') for drop.
  3099. .Bd -literal -offset indent
  3100. ffmpeg -i input.mpg -timecode 01:02:03.04 -r 30000/1001 -s ntsc output.mpg
  3101. .Ed
  3102. .Pp
  3103. .It -filter_complex Va filtergraph ( Em global)
  3104. Define a complex filtergraph, i.e. one with arbitrary number of inputs and/or
  3105. outputs. For simple graphs -- those with one input and one output of the same
  3106. type -- see the
  3107. .Op -filter
  3108. options.
  3109. .Va filtergraph
  3110. is a description of the filtergraph, as described in the \(lqFiltergraph syntax\(rq
  3111. section of the ffmpeg-filters manual.
  3112. .Pp
  3113. Input link labels must refer to either input streams or loopback decoders.
  3114. For input streams, use the
  3115. .Li [file_index:stream_specifier]
  3116. syntax (i.e. the same as
  3117. .Op -map
  3118. uses). If
  3119. .Va stream_specifier
  3120. matches multiple streams, the first one will be used.
  3121. .Pp
  3122. For decoders, the link label must be [dec:
  3123. .Va dec_idx
  3124. ], where
  3125. .Va dec_idx
  3126. is the index of the loopback decoder to be connected to given input.
  3127. .Pp
  3128. An unlabeled input will be connected to the first unused input stream of the
  3129. matching type.
  3130. .Pp
  3131. Output link labels are referred to with
  3132. .Op -map .
  3133. Unlabeled outputs are added to the first output file.
  3134. .Pp
  3135. Note that with this option it is possible to use only lavfi sources without
  3136. normal input files.
  3137. .Pp
  3138. For example, to overlay an image over video
  3139. .Bd -literal -offset indent
  3140. ffmpeg -i video.mkv -i image.png -filter_complex '[0:v][1:v]overlay[out]' -map
  3141. \&'[out]' out.mkv
  3142. .Ed
  3143. Here
  3144. .Li [0:v]
  3145. refers to the first video stream in the first input file, which is linked
  3146. to the first (main) input of the overlay filter. Similarly the first video
  3147. stream in the second input is linked to the second (overlay) input of overlay.
  3148. .Pp
  3149. Assuming there is only one video stream in each input file, we can omit input
  3150. labels, so the above is equivalent to
  3151. .Bd -literal -offset indent
  3152. ffmpeg -i video.mkv -i image.png -filter_complex 'overlay[out]' -map
  3153. \&'[out]' out.mkv
  3154. .Ed
  3155. .Pp
  3156. Furthermore we can omit the output label and the single output from the filter
  3157. graph will be added to the output file automatically, so we can simply write
  3158. .Bd -literal -offset indent
  3159. ffmpeg -i video.mkv -i image.png -filter_complex 'overlay' out.mkv
  3160. .Ed
  3161. .Pp
  3162. As a special exception, you can use a bitmap subtitle stream as input: it
  3163. will be converted into a video with the same size as the largest video in
  3164. the file, or 720x576 if no video is present. Note that this is an experimental
  3165. and temporary solution. It will be removed once libavfilter has proper support
  3166. for subtitles.
  3167. .Pp
  3168. For example, to hardcode subtitles on top of a DVB-T recording stored in MPEG-TS
  3169. format, delaying the subtitles by 1 second:
  3170. .Bd -literal -offset indent
  3171. ffmpeg -i input.ts -filter_complex \e
  3172. '[#0x2ef] setpts=PTS+1/TB [sub] ; [#0x2d0] [sub] overlay' \e
  3173. -sn -map '#0x2dc' output.mkv
  3174. .Ed
  3175. (0x2d0, 0x2dc and 0x2ef are the MPEG-TS PIDs of respectively the video, audio
  3176. and subtitles streams; 0:0, 0:3 and 0:7 would have worked too)
  3177. .Pp
  3178. To generate 5 seconds of pure red video using lavfi
  3179. .Li color
  3180. source:
  3181. .Bd -literal -offset indent
  3182. ffmpeg -filter_complex 'color=c=red' -t 5 out.mkv
  3183. .Ed
  3184. .Pp
  3185. .It -filter_complex_threads Va nb_threads ( Em global)
  3186. Defines how many threads are used to process a filter_complex graph. Similar
  3187. to filter_threads but used for
  3188. .Li -filter_complex
  3189. graphs only. The default is the number of available CPUs.
  3190. .Pp
  3191. .It -lavfi Va filtergraph ( Em global)
  3192. Define a complex filtergraph, i.e. one with arbitrary number of inputs and/or
  3193. outputs. Equivalent to
  3194. .Op -filter_complex .
  3195. .Pp
  3196. .It -accurate_seek ( Em input)
  3197. This option enables or disables accurate seeking in input files with the
  3198. .Op -ss
  3199. option. It is enabled by default, so seeking is accurate when transcoding.
  3200. Use
  3201. .Op -noaccurate_seek
  3202. to disable it, which may be useful e.g. when copying some streams and transcoding
  3203. the others.
  3204. .Pp
  3205. .It -seek_timestamp ( Em input)
  3206. This option enables or disables seeking by timestamp in input files with the
  3207. .Op -ss
  3208. option. It is disabled by default. If enabled, the argument to the
  3209. .Op -ss
  3210. option is considered an actual timestamp, and is not offset by the start time
  3211. of the file. This matters only for files which do not start from timestamp
  3212. 0, such as transport streams.
  3213. .Pp
  3214. .It -thread_queue_size Va size ( Em input/output)
  3215. For input, this option sets the maximum number of queued packets when reading
  3216. from the file or device. With low latency / high rate live streams, packets
  3217. may be discarded if they are not read in a timely manner; setting this value
  3218. can force ffmpeg to use a separate input thread and read packets as soon as
  3219. they arrive. By default ffmpeg only does this if multiple inputs are specified.
  3220. .Pp
  3221. For output, this option specified the maximum number of packets that may be
  3222. queued to each muxing thread.
  3223. .Pp
  3224. .It -sdp_file Va file ( Em global)
  3225. Print sdp information for an output stream to
  3226. .Va file .
  3227. This allows dumping sdp information when at least one output isn't an rtp
  3228. stream. (Requires at least one of the output formats to be rtp).
  3229. .Pp
  3230. .It -discard ( Em input)
  3231. Allows discarding specific streams or frames from streams. Any input stream
  3232. can be fully discarded, using value
  3233. .Li all
  3234. whereas selective discarding of frames from a stream occurs at the demuxer
  3235. and is not supported by all demuxers.
  3236. .Pp
  3237. .Bl -tag -width Ds
  3238. .It none
  3239. Discard no frame.
  3240. .Pp
  3241. .It default
  3242. Default, which discards no frames.
  3243. .Pp
  3244. .It noref
  3245. Discard all non-reference frames.
  3246. .Pp
  3247. .It bidir
  3248. Discard all bidirectional frames.
  3249. .Pp
  3250. .It nokey
  3251. Discard all frames excepts keyframes.
  3252. .Pp
  3253. .It all
  3254. Discard all frames.
  3255. .El
  3256. .Pp
  3257. .It -abort_on Va flags ( Em global)
  3258. Stop and abort on various conditions. The following flags are available:
  3259. .Pp
  3260. .Bl -tag -width Ds
  3261. .It empty_output
  3262. No packets were passed to the muxer, the output is empty.
  3263. .It empty_output_stream
  3264. No packets were passed to the muxer in some of the output streams.
  3265. .El
  3266. .Pp
  3267. .It -max_error_rate ( Em global)
  3268. Set fraction of decoding frame failures across all inputs which when crossed
  3269. ffmpeg will return exit code 69. Crossing this threshold does not terminate
  3270. processing. Range is a floating-point number between 0 to 1. Default is 2/3.
  3271. .Pp
  3272. .It -xerror ( Em global)
  3273. Stop and exit on error
  3274. .Pp
  3275. .It -max_muxing_queue_size Va packets ( Em output,per-stream)
  3276. When transcoding audio and/or video streams, ffmpeg will not begin writing
  3277. into the output until it has one packet for each such stream. While waiting
  3278. for that to happen, packets for other streams are buffered. This option sets
  3279. the size of this buffer, in packets, for the matching output stream.
  3280. .Pp
  3281. The default value of this option should be high enough for most uses, so only
  3282. touch this option if you are sure that you need it.
  3283. .Pp
  3284. .It -muxing_queue_data_threshold Va bytes ( Em output,per-stream)
  3285. This is a minimum threshold until which the muxing queue size is not taken
  3286. into account. Defaults to 50 megabytes per stream, and is based on the overall
  3287. size of packets passed to the muxer.
  3288. .Pp
  3289. .It -auto_conversion_filters ( Em global)
  3290. Enable automatically inserting format conversion filters in all filter graphs,
  3291. including those defined by
  3292. .Op -vf ,
  3293. .Op -af ,
  3294. .Op -filter_complex
  3295. and
  3296. .Op -lavfi .
  3297. If filter format negotiation requires a conversion, the initialization of
  3298. the filters will fail. Conversions can still be performed by inserting the
  3299. relevant conversion filter (scale, aresample) in the graph. On by default,
  3300. to explicitly disable it you need to specify
  3301. .Li -noauto_conversion_filters .
  3302. .Pp
  3303. .It -bits_per_raw_sample[: Va stream_specifier] Va value ( Em output,per-stream)
  3304. Declare the number of bits per raw sample in the given output stream to be
  3305. .Va value .
  3306. Note that this option sets the information provided to the encoder/muxer,
  3307. it does not change the stream to conform to this value. Setting values that
  3308. do not match the stream properties may result in encoding failures or invalid
  3309. output files.
  3310. .Pp
  3311. .It -stats_enc_pre[: Va stream_specifier] Va path ( Em output,per-stream)
  3312. .It -stats_enc_post[: Va stream_specifier] Va path ( Em output,per-stream)
  3313. .It -stats_mux_pre[: Va stream_specifier] Va path ( Em output,per-stream)
  3314. Write per-frame encoding information about the matching streams into the file
  3315. given by
  3316. .Va path .
  3317. .Pp
  3318. .Op -stats_enc_pre
  3319. writes information about raw video or audio frames right before they are sent
  3320. for encoding, while
  3321. .Op -stats_enc_post
  3322. writes information about encoded packets as they are received from the encoder.
  3323. .Op -stats_mux_pre
  3324. writes information about packets just as they are about to be sent to the
  3325. muxer. Every frame or packet produces one line in the specified file. The
  3326. format of this line is controlled by
  3327. .Op -stats_enc_pre_fmt
  3328. /
  3329. .Op -stats_enc_post_fmt
  3330. /
  3331. .Op -stats_mux_pre_fmt .
  3332. .Pp
  3333. When stats for multiple streams are written into a single file, the lines
  3334. corresponding to different streams will be interleaved. The precise order
  3335. of this interleaving is not specified and not guaranteed to remain stable
  3336. between different invocations of the program, even with the same options.
  3337. .Pp
  3338. .It -stats_enc_pre_fmt[: Va stream_specifier] Va format_spec ( Em output,per-stream)
  3339. .It -stats_enc_post_fmt[: Va stream_specifier] Va format_spec ( Em output,per-stream)
  3340. .It -stats_mux_pre_fmt[: Va stream_specifier] Va format_spec ( Em output,per-stream)
  3341. Specify the format for the lines written with
  3342. .Op -stats_enc_pre
  3343. /
  3344. .Op -stats_enc_post
  3345. /
  3346. .Op -stats_mux_pre .
  3347. .Pp
  3348. .Va format_spec
  3349. is a string that may contain directives of the form
  3350. .Va {fmt} .
  3351. .Va format_spec
  3352. is backslash-escaped --- use \e{, \e}, and \e\e to write a literal {, }, or \e, respectively,
  3353. into the output.
  3354. .Pp
  3355. The directives given with
  3356. .Va fmt
  3357. may be one of the following:
  3358. .Bl -tag -width Ds
  3359. .It fidx
  3360. Index of the output file.
  3361. .Pp
  3362. .It sidx
  3363. Index of the output stream in the file.
  3364. .Pp
  3365. .It n
  3366. Frame number. Pre-encoding: number of frames sent to the encoder so far. Post-encoding:
  3367. number of packets received from the encoder so far. Muxing: number of packets
  3368. submitted to the muxer for this stream so far.
  3369. .Pp
  3370. .It ni
  3371. Input frame number. Index of the input frame (i.e. output by a decoder) that
  3372. corresponds to this output frame or packet. -1 if unavailable.
  3373. .Pp
  3374. .It tb
  3375. Timebase in which this frame/packet's timestamps are expressed, as a rational
  3376. number
  3377. .Va num/den .
  3378. Note that encoder and muxer may use different timebases.
  3379. .Pp
  3380. .It tbi
  3381. Timebase for
  3382. .Va ptsi ,
  3383. as a rational number
  3384. .Va num/den .
  3385. Available when
  3386. .Va ptsi
  3387. is available,
  3388. .Va 0/1
  3389. otherwise.
  3390. .Pp
  3391. .It pts
  3392. Presentation timestamp of the frame or packet, as an integer. Should be multiplied
  3393. by the timebase to compute presentation time.
  3394. .Pp
  3395. .It ptsi
  3396. Presentation timestamp of the input frame (see
  3397. .Va ni ) ,
  3398. as an integer. Should be multiplied by
  3399. .Va tbi
  3400. to compute presentation time. Printed as (2^63 - 1 = 9223372036854775807)
  3401. when not available.
  3402. .Pp
  3403. .It t
  3404. Presentation time of the frame or packet, as a decimal number. Equal to
  3405. .Va pts
  3406. multiplied by
  3407. .Va tb .
  3408. .Pp
  3409. .It ti
  3410. Presentation time of the input frame (see
  3411. .Va ni ) ,
  3412. as a decimal number. Equal to
  3413. .Va ptsi
  3414. multiplied by
  3415. .Va tbi .
  3416. Printed as inf when not available.
  3417. .Pp
  3418. .It dts ( Em packet)
  3419. Decoding timestamp of the packet, as an integer. Should be multiplied by the
  3420. timebase to compute presentation time.
  3421. .Pp
  3422. .It dt ( Em packet)
  3423. Decoding time of the frame or packet, as a decimal number. Equal to
  3424. .Va dts
  3425. multiplied by
  3426. .Va tb .
  3427. .Pp
  3428. .It sn ( Em frame,audio)
  3429. Number of audio samples sent to the encoder so far.
  3430. .Pp
  3431. .It samp ( Em frame,audio)
  3432. Number of audio samples in the frame.
  3433. .Pp
  3434. .It size ( Em packet)
  3435. Size of the encoded packet in bytes.
  3436. .Pp
  3437. .It br ( Em packet)
  3438. Current bitrate in bits per second.
  3439. .Pp
  3440. .It abr ( Em packet)
  3441. Average bitrate for the whole stream so far, in bits per second, -1 if it
  3442. cannot be determined at this point.
  3443. .Pp
  3444. .It key ( Em packet)
  3445. Character 'K' if the packet contains a keyframe, character 'N' otherwise.
  3446. .El
  3447. .Pp
  3448. Directives tagged with
  3449. .Em packet
  3450. may only be used with
  3451. .Op -stats_enc_post_fmt
  3452. and
  3453. .Op -stats_mux_pre_fmt .
  3454. .Pp
  3455. Directives tagged with
  3456. .Em frame
  3457. may only be used with
  3458. .Op -stats_enc_pre_fmt .
  3459. .Pp
  3460. Directives tagged with
  3461. .Em audio
  3462. may only be used with audio streams.
  3463. .Pp
  3464. The default format strings are:
  3465. .Bl -tag -width Ds
  3466. .It pre-encoding
  3467. {fidx} {sidx} {n} {t}
  3468. .It post-encoding
  3469. {fidx} {sidx} {n} {t}
  3470. .El
  3471. In the future, new items may be added to the end of the default formatting
  3472. strings. Users who depend on the format staying exactly the same, should prescribe
  3473. it manually.
  3474. .Pp
  3475. Note that stats for different streams written into the same file may have
  3476. different formats.
  3477. .Pp
  3478. .El
  3479. .Ss Preset files
  3480. A preset file contains a sequence of
  3481. .Va option
  3482. =
  3483. .Va value
  3484. pairs, one for each line, specifying a sequence of options which would be
  3485. awkward to specify on the command line. Lines starting with the hash ('#')
  3486. character are ignored and are used to provide comments. Check the
  3487. .Pa presets
  3488. directory in the FFmpeg source tree for examples.
  3489. .Pp
  3490. There are two types of preset files: ffpreset and avpreset files.
  3491. .Pp
  3492. .Em ffpreset files
  3493. .Pp
  3494. ffpreset files are specified with the
  3495. .Li vpre ,
  3496. .Li apre ,
  3497. .Li spre ,
  3498. and
  3499. .Li fpre
  3500. options. The
  3501. .Li fpre
  3502. option takes the filename of the preset instead of a preset name as input
  3503. and can be used for any kind of codec. For the
  3504. .Li vpre ,
  3505. .Li apre ,
  3506. and
  3507. .Li spre
  3508. options, the options specified in a preset file are applied to the currently
  3509. selected codec of the same type as the preset option.
  3510. .Pp
  3511. The argument passed to the
  3512. .Li vpre ,
  3513. .Li apre ,
  3514. and
  3515. .Li spre
  3516. preset options identifies the preset file to use according to the following
  3517. rules:
  3518. .Pp
  3519. First ffmpeg searches for a file named
  3520. .Va arg
  3521. \&.ffpreset in the directories
  3522. .Pa $FFMPEG_DATADIR
  3523. (if set), and
  3524. .Pa $HOME/.ffmpeg ,
  3525. and in the datadir defined at configuration time (usually
  3526. .Pa PREFIX/share/ffmpeg )
  3527. or in a
  3528. .Pa ffpresets
  3529. folder along the executable on win32, in that order. For example, if the argument
  3530. is
  3531. .Li libvpx-1080p ,
  3532. it will search for the file
  3533. .Pa libvpx-1080p.ffpreset .
  3534. .Pp
  3535. If no such file is found, then ffmpeg will search for a file named
  3536. .Va codec_name
  3537. -
  3538. .Va arg
  3539. \&.ffpreset in the above-mentioned directories, where
  3540. .Va codec_name
  3541. is the name of the codec to which the preset file options will be applied.
  3542. For example, if you select the video codec with
  3543. .Li -vcodec libvpx
  3544. and use
  3545. .Li -vpre 1080p ,
  3546. then it will search for the file
  3547. .Pa libvpx-1080p.ffpreset .
  3548. .Pp
  3549. .Em avpreset files
  3550. .Pp
  3551. avpreset files are specified with the
  3552. .Li pre
  3553. option. They work similar to ffpreset files, but they only allow encoder-
  3554. specific options. Therefore, an
  3555. .Va option
  3556. =
  3557. .Va value
  3558. pair specifying an encoder cannot be used.
  3559. .Pp
  3560. When the
  3561. .Li pre
  3562. option is specified, ffmpeg will look for files with the suffix .avpreset
  3563. in the directories
  3564. .Pa $AVCONV_DATADIR
  3565. (if set), and
  3566. .Pa $HOME/.avconv ,
  3567. and in the datadir defined at configuration time (usually
  3568. .Pa PREFIX/share/ffmpeg ) ,
  3569. in that order.
  3570. .Pp
  3571. First ffmpeg searches for a file named
  3572. .Va codec_name
  3573. -
  3574. .Va arg
  3575. \&.avpreset in the above-mentioned directories, where
  3576. .Va codec_name
  3577. is the name of the codec to which the preset file options will be applied.
  3578. For example, if you select the video codec with
  3579. .Li -vcodec libvpx
  3580. and use
  3581. .Li -pre 1080p ,
  3582. then it will search for the file
  3583. .Pa libvpx-1080p.avpreset .
  3584. .Pp
  3585. If no such file is found, then ffmpeg will search for a file named
  3586. .Va arg
  3587. \&.avpreset in the same directories.
  3588. .Pp
  3589. .Ss vstats file format
  3590. The
  3591. .Li -vstats
  3592. and
  3593. .Li -vstats_file
  3594. options enable generation of a file containing statistics about the generated
  3595. video outputs.
  3596. .Pp
  3597. The
  3598. .Li -vstats_version
  3599. option controls the format version of the generated file.
  3600. .Pp
  3601. With version
  3602. .Li 1
  3603. the format is:
  3604. .Bd -literal -offset indent
  3605. frame= FRAME q= FRAME_QUALITY PSNR= PSNR f_size= FRAME_SIZE s_size= STREAM_SIZEkB time= TIMESTAMP br= BITRATEkbits/s avg_br= AVERAGE_BITRATEkbits/s
  3606. .Ed
  3607. .Pp
  3608. With version
  3609. .Li 2
  3610. the format is:
  3611. .Bd -literal -offset indent
  3612. out= OUT_FILE_INDEX st= OUT_FILE_STREAM_INDEX frame= FRAME_NUMBER q= FRAME_QUALITYf PSNR= PSNR f_size= FRAME_SIZE s_size= STREAM_SIZEkB time= TIMESTAMP br= BITRATEkbits/s avg_br= AVERAGE_BITRATEkbits/s
  3613. .Ed
  3614. .Pp
  3615. The value corresponding to each key is described below:
  3616. .Bl -tag -width Ds
  3617. .It avg_br
  3618. average bitrate expressed in Kbits/s
  3619. .Pp
  3620. .It br
  3621. bitrate expressed in Kbits/s
  3622. .Pp
  3623. .It frame
  3624. number of encoded frame
  3625. .Pp
  3626. .It out
  3627. out file index
  3628. .Pp
  3629. .It PSNR
  3630. Peak Signal to Noise Ratio
  3631. .Pp
  3632. .It q
  3633. quality of the frame
  3634. .Pp
  3635. .It f_size
  3636. encoded packet size expressed as number of bytes
  3637. .Pp
  3638. .It s_size
  3639. stream size expressed in KiB
  3640. .Pp
  3641. .It st
  3642. out file stream index
  3643. .Pp
  3644. .It time
  3645. time of the packet
  3646. .Pp
  3647. .It type
  3648. picture type
  3649. .El
  3650. .Pp
  3651. See also the stats_enc_options,,-stats_enc options for an alternative way
  3652. to show encoding statistics.
  3653. .Pp
  3654. .Sh Examples
  3655. .Ss Video and Audio grabbing
  3656. If you specify the input format and device then ffmpeg can grab video and
  3657. audio directly.
  3658. .Pp
  3659. .Bd -literal -offset indent
  3660. ffmpeg -f oss -i /dev/dsp -f video4linux2 -i /dev/video0 /tmp/out.mpg
  3661. .Ed
  3662. .Pp
  3663. Or with an ALSA audio source (mono input, card id 1) instead of OSS:
  3664. .Bd -literal -offset indent
  3665. ffmpeg -f alsa -ac 1 -i hw:1 -f video4linux2 -i /dev/video0 /tmp/out.mpg
  3666. .Ed
  3667. .Pp
  3668. Note that you must activate the right video source and channel before launching
  3669. ffmpeg with any TV viewer such as
  3670. .Lk http://linux.bytesex.org/xawtv/
  3671. by Gerd Knorr. You also have to set the audio recording levels correctly with
  3672. a standard mixer.
  3673. .Pp
  3674. .Ss X11 grabbing
  3675. Grab the X11 display with ffmpeg via
  3676. .Pp
  3677. .Bd -literal -offset indent
  3678. ffmpeg -f x11grab -video_size cif -framerate 25 -i :0.0 /tmp/out.mpg
  3679. .Ed
  3680. .Pp
  3681. 0.0 is display.screen number of your X11 server, same as the DISPLAY environment
  3682. variable.
  3683. .Pp
  3684. .Bd -literal -offset indent
  3685. ffmpeg -f x11grab -video_size cif -framerate 25 -i :0.0+10,20 /tmp/out.mpg
  3686. .Ed
  3687. .Pp
  3688. 0.0 is display.screen number of your X11 server, same as the DISPLAY environment
  3689. variable. 10 is the x-offset and 20 the y-offset for the grabbing.
  3690. .Pp
  3691. .Ss Video and Audio file format conversion
  3692. Any supported file format and protocol can serve as input to ffmpeg:
  3693. .Pp
  3694. Examples:
  3695. .Bl -bullet
  3696. .It
  3697. You can use YUV files as input:
  3698. .Pp
  3699. .Bd -literal -offset indent
  3700. ffmpeg -i /tmp/test%d.Y /tmp/out.mpg
  3701. .Ed
  3702. .Pp
  3703. It will use the files:
  3704. .Bd -literal -offset indent
  3705. /tmp/test0.Y, /tmp/test0.U, /tmp/test0.V,
  3706. /tmp/test1.Y, /tmp/test1.U, /tmp/test1.V, etc...
  3707. .Ed
  3708. .Pp
  3709. The Y files use twice the resolution of the U and V files. They are raw files,
  3710. without header. They can be generated by all decent video decoders. You must
  3711. specify the size of the image with the
  3712. .Op -s
  3713. option if ffmpeg cannot guess it.
  3714. .Pp
  3715. .It
  3716. You can input from a raw YUV420P file:
  3717. .Pp
  3718. .Bd -literal -offset indent
  3719. ffmpeg -i /tmp/test.yuv /tmp/out.avi
  3720. .Ed
  3721. .Pp
  3722. test.yuv is a file containing raw YUV planar data. Each frame is composed
  3723. of the Y plane followed by the U and V planes at half vertical and horizontal
  3724. resolution.
  3725. .Pp
  3726. .It
  3727. You can output to a raw YUV420P file:
  3728. .Pp
  3729. .Bd -literal -offset indent
  3730. ffmpeg -i mydivx.avi hugefile.yuv
  3731. .Ed
  3732. .Pp
  3733. .It
  3734. You can set several input files and output files:
  3735. .Pp
  3736. .Bd -literal -offset indent
  3737. ffmpeg -i /tmp/a.wav -s 640x480 -i /tmp/a.yuv /tmp/a.mpg
  3738. .Ed
  3739. .Pp
  3740. Converts the audio file a.wav and the raw YUV video file a.yuv to MPEG file
  3741. a.mpg.
  3742. .Pp
  3743. .It
  3744. You can also do audio and video conversions at the same time:
  3745. .Pp
  3746. .Bd -literal -offset indent
  3747. ffmpeg -i /tmp/a.wav -ar 22050 /tmp/a.mp2
  3748. .Ed
  3749. .Pp
  3750. Converts a.wav to MPEG audio at 22050 Hz sample rate.
  3751. .Pp
  3752. .It
  3753. You can encode to several formats at the same time and define a mapping from
  3754. input stream to output streams:
  3755. .Pp
  3756. .Bd -literal -offset indent
  3757. ffmpeg -i /tmp/a.wav -map 0:a -b:a 64k /tmp/a.mp2 -map 0:a -b:a 128k /tmp/b.mp2
  3758. .Ed
  3759. .Pp
  3760. Converts a.wav to a.mp2 at 64 kbits and to b.mp2 at 128 kbits. '-map file:index'
  3761. specifies which input stream is used for each output stream, in the order
  3762. of the definition of output streams.
  3763. .Pp
  3764. .It
  3765. You can transcode decrypted VOBs:
  3766. .Pp
  3767. .Bd -literal -offset indent
  3768. ffmpeg -i snatch_1.vob -f avi -c:v mpeg4 -b:v 800k -g 300 -bf 2 -c:a libmp3lame -b:a 128k snatch.avi
  3769. .Ed
  3770. .Pp
  3771. This is a typical DVD ripping example; the input is a VOB file, the output
  3772. an AVI file with MPEG-4 video and MP3 audio. Note that in this command we
  3773. use B-frames so the MPEG-4 stream is DivX5 compatible, and GOP size is 300
  3774. which means one intra frame every 10 seconds for 29.97fps input video. Furthermore,
  3775. the audio stream is MP3-encoded so you need to enable LAME support by passing
  3776. .Li --enable-libmp3lame
  3777. to configure. The mapping is particularly useful for DVD transcoding to get
  3778. the desired audio language.
  3779. .Pp
  3780. NOTE: To see the supported input formats, use
  3781. .Li ffmpeg -demuxers .
  3782. .Pp
  3783. .It
  3784. You can extract images from a video, or create a video from many images:
  3785. .Pp
  3786. For extracting images from a video:
  3787. .Bd -literal -offset indent
  3788. ffmpeg -i foo.avi -r 1 -s WxH -f image2 foo-%03d.jpeg
  3789. .Ed
  3790. .Pp
  3791. This will extract one video frame per second from the video and will output
  3792. them in files named
  3793. .Pa foo-001.jpeg ,
  3794. .Pa foo-002.jpeg ,
  3795. etc. Images will be rescaled to fit the new WxH values.
  3796. .Pp
  3797. If you want to extract just a limited number of frames, you can use the above
  3798. command in combination with the
  3799. .Li -frames:v
  3800. or
  3801. .Li -t
  3802. option, or in combination with -ss to start extracting from a certain point
  3803. in time.
  3804. .Pp
  3805. For creating a video from many images:
  3806. .Bd -literal -offset indent
  3807. ffmpeg -f image2 -framerate 12 -i foo-%03d.jpeg -s WxH foo.avi
  3808. .Ed
  3809. .Pp
  3810. The syntax
  3811. .Li foo-%03d.jpeg
  3812. specifies to use a decimal number composed of three digits padded with zeroes
  3813. to express the sequence number. It is the same syntax supported by the C printf
  3814. function, but only formats accepting a normal integer are suitable.
  3815. .Pp
  3816. When importing an image sequence, -i also supports expanding shell-like wildcard
  3817. patterns (globbing) internally, by selecting the image2-specific
  3818. .Li -pattern_type glob
  3819. option.
  3820. .Pp
  3821. For example, for creating a video from filenames matching the glob pattern
  3822. .Li foo-*.jpeg :
  3823. .Bd -literal -offset indent
  3824. ffmpeg -f image2 -pattern_type glob -framerate 12 -i 'foo-*.jpeg' -s WxH foo.avi
  3825. .Ed
  3826. .Pp
  3827. .It
  3828. You can put many streams of the same type in the output:
  3829. .Pp
  3830. .Bd -literal -offset indent
  3831. ffmpeg -i test1.avi -i test2.avi -map 1:1 -map 1:0 -map 0:1 -map 0:0 -c copy -y test12.nut
  3832. .Ed
  3833. .Pp
  3834. The resulting output file
  3835. .Pa test12.nut
  3836. will contain the first four streams from the input files in reverse order.
  3837. .Pp
  3838. .It
  3839. To force CBR video output:
  3840. .Bd -literal -offset indent
  3841. ffmpeg -i myfile.avi -b 4000k -minrate 4000k -maxrate 4000k -bufsize 1835k out.m2v
  3842. .Ed
  3843. .Pp
  3844. .It
  3845. The four options lmin, lmax, mblmin and mblmax use 'lambda' units, but you
  3846. may use the QP2LAMBDA constant to easily convert from 'q' units:
  3847. .Bd -literal -offset indent
  3848. ffmpeg -i src.ext -lmax 21*QP2LAMBDA dst.ext
  3849. .Ed
  3850. .Pp
  3851. .El
  3852. .Sh See Also
  3853. ffplay(1), ffprobe(1), ffmpeg-utils(1), ffmpeg-scaler(1), ffmpeg-resampler(1),
  3854. ffmpeg-codecs(1), ffmpeg-bitstream-filters(1), ffmpeg-formats(1), ffmpeg-devices(1),
  3855. ffmpeg-protocols(1), ffmpeg-filters(1)
  3856. .Pp
  3857. .Sh Authors
  3858. The FFmpeg developers.
  3859. .Pp
  3860. For details about the authorship, see the Git history of the project (https://git.ffmpeg.org/ffmpeg),
  3861. e.g. by typing the command
  3862. .Xr git log
  3863. in the FFmpeg source directory, or browsing the online repository at
  3864. .Lk https://git.ffmpeg.org/ffmpeg .
  3865. .Pp
  3866. Maintainers for the specific components are listed in the file
  3867. .Pa MAINTAINERS
  3868. in the source code tree.
  3869. .Pp