You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

493 lines
15KB

  1. @chapter Bitstream Filters
  2. @c man begin BITSTREAM FILTERS
  3. When you configure your FFmpeg build, all the supported bitstream
  4. filters are enabled by default. You can list all available ones using
  5. the configure option @code{--list-bsfs}.
  6. You can disable all the bitstream filters using the configure option
  7. @code{--disable-bsfs}, and selectively enable any bitstream filter using
  8. the option @code{--enable-bsf=BSF}, or you can disable a particular
  9. bitstream filter using the option @code{--disable-bsf=BSF}.
  10. The option @code{-bsfs} of the ff* tools will display the list of
  11. all the supported bitstream filters included in your build.
  12. The ff* tools have a -bsf option applied per stream, taking a
  13. comma-separated list of filters, whose parameters follow the filter
  14. name after a '='.
  15. @example
  16. ffmpeg -i INPUT -c:v copy -bsf:v filter1[=opt1=str1:opt2=str2][,filter2] OUTPUT
  17. @end example
  18. Below is a description of the currently available bitstream filters,
  19. with their parameters, if any.
  20. @section aac_adtstoasc
  21. Convert MPEG-2/4 AAC ADTS to an MPEG-4 Audio Specific Configuration
  22. bitstream.
  23. This filter creates an MPEG-4 AudioSpecificConfig from an MPEG-2/4
  24. ADTS header and removes the ADTS header.
  25. This filter is required for example when copying an AAC stream from a
  26. raw ADTS AAC or an MPEG-TS container to MP4A-LATM, to an FLV file, or
  27. to MOV/MP4 files and related formats such as 3GP or M4A. Please note
  28. that it is auto-inserted for MP4A-LATM and MOV/MP4 and related formats.
  29. @section chomp
  30. Remove zero padding at the end of a packet.
  31. @section dca_core
  32. Extract the core from a DCA/DTS stream, dropping extensions such as
  33. DTS-HD.
  34. @section dump_extra
  35. Add extradata to the beginning of the filtered packets.
  36. @table @option
  37. @item freq
  38. The additional argument specifies which packets should be filtered.
  39. It accepts the values:
  40. @table @samp
  41. @item k
  42. @item keyframe
  43. add extradata to all key packets
  44. @item e
  45. @item all
  46. add extradata to all packets
  47. @end table
  48. @end table
  49. If not specified it is assumed @samp{e}.
  50. For example the following @command{ffmpeg} command forces a global
  51. header (thus disabling individual packet headers) in the H.264 packets
  52. generated by the @code{libx264} encoder, but corrects them by adding
  53. the header stored in extradata to the key packets:
  54. @example
  55. ffmpeg -i INPUT -map 0 -flags:v +global_header -c:v libx264 -bsf:v dump_extra out.ts
  56. @end example
  57. @section extract_extradata
  58. Extract the in-band extradata.
  59. Certain codecs allow the long-term headers (e.g. MPEG-2 sequence headers,
  60. or H.264/HEVC (VPS/)SPS/PPS) to be transmitted either "in-band" (i.e. as a part
  61. of the bitstream containing the coded frames) or "out of band" (e.g. on the
  62. container level). This latter form is called "extradata" in FFmpeg terminology.
  63. This bitstream filter detects the in-band headers and makes them available as
  64. extradata.
  65. @table @option
  66. @item remove
  67. When this option is enabled, the long-term headers are removed from the
  68. bitstream after extraction.
  69. @end table
  70. @section hapqa_extract
  71. Extract Rgb or Alpha part of an HAPQA file, without recompression, in order to create an HAPQ or an HAPAlphaOnly file.
  72. @table @option
  73. @item texture
  74. Specifies the texture to keep.
  75. @table @option
  76. @item color
  77. @item alpha
  78. @end table
  79. @end table
  80. Convert HAPQA to HAPQ
  81. @example
  82. ffmpeg -i hapqa_inputfile.mov -c copy -bsf:v hapqa_extract=texture=color -tag:v HapY -metadata:s:v:0 encoder="HAPQ" hapq_file.mov
  83. @end example
  84. Convert HAPQA to HAPAlphaOnly
  85. @example
  86. ffmpeg -i hapqa_inputfile.mov -c copy -bsf:v hapqa_extract=texture=alpha -tag:v HapA -metadata:s:v:0 encoder="HAPAlpha Only" hapalphaonly_file.mov
  87. @end example
  88. @section h264_metadata
  89. Modify metadata embedded in an H.264 stream.
  90. @table @option
  91. @item aud
  92. Insert or remove AUD NAL units in all access units of the stream.
  93. @table @samp
  94. @item insert
  95. @item remove
  96. @end table
  97. @item sample_aspect_ratio
  98. Set the sample aspect ratio of the stream in the VUI parameters.
  99. @item video_format
  100. @item video_full_range_flag
  101. Set the video format in the stream (see H.264 section E.2.1 and
  102. table E-2).
  103. @item colour_primaries
  104. @item transfer_characteristics
  105. @item matrix_coefficients
  106. Set the colour description in the stream (see H.264 section E.2.1
  107. and tables E-3, E-4 and E-5).
  108. @item chroma_sample_loc_type
  109. Set the chroma sample location in the stream (see H.264 section
  110. E.2.1 and figure E-1).
  111. @item tick_rate
  112. Set the tick rate (num_units_in_tick / time_scale) in the VUI
  113. parameters. This is the smallest time unit representable in the
  114. stream, and in many cases represents the field rate of the stream
  115. (double the frame rate).
  116. @item fixed_frame_rate_flag
  117. Set whether the stream has fixed framerate - typically this indicates
  118. that the framerate is exactly half the tick rate, but the exact
  119. meaning is dependent on interlacing and the picture structure (see
  120. H.264 section E.2.1 and table E-6).
  121. @item crop_left
  122. @item crop_right
  123. @item crop_top
  124. @item crop_bottom
  125. Set the frame cropping offsets in the SPS. These values will replace
  126. the current ones if the stream is already cropped.
  127. These fields are set in pixels. Note that some sizes may not be
  128. representable if the chroma is subsampled or the stream is interlaced
  129. (see H.264 section 7.4.2.1.1).
  130. @item sei_user_data
  131. Insert a string as SEI unregistered user data. The argument must
  132. be of the form @emph{UUID+string}, where the UUID is as hex digits
  133. possibly separated by hyphens, and the string can be anything.
  134. For example, @samp{086f3693-b7b3-4f2c-9653-21492feee5b8+hello} will
  135. insert the string ``hello'' associated with the given UUID.
  136. @item delete_filler
  137. Deletes both filler NAL units and filler SEI messages.
  138. @end table
  139. @section h264_mp4toannexb
  140. Convert an H.264 bitstream from length prefixed mode to start code
  141. prefixed mode (as defined in the Annex B of the ITU-T H.264
  142. specification).
  143. This is required by some streaming formats, typically the MPEG-2
  144. transport stream format (muxer @code{mpegts}).
  145. For example to remux an MP4 file containing an H.264 stream to mpegts
  146. format with @command{ffmpeg}, you can use the command:
  147. @example
  148. ffmpeg -i INPUT.mp4 -codec copy -bsf:v h264_mp4toannexb OUTPUT.ts
  149. @end example
  150. Please note that this filter is auto-inserted for MPEG-TS (muxer
  151. @code{mpegts}) and raw H.264 (muxer @code{h264}) output formats.
  152. @section h264_redundant_pps
  153. This applies a specific fixup to some Blu-ray streams which contain
  154. redundant PPSs modifying irrelevant parameters of the stream which
  155. confuse other transformations which require correct extradata.
  156. A new single global PPS is created, and all of the redundant PPSs
  157. within the stream are removed.
  158. @section hevc_metadata
  159. Modify metadata embedded in an HEVC stream.
  160. @table @option
  161. @item aud
  162. Insert or remove AUD NAL units in all access units of the stream.
  163. @table @samp
  164. @item insert
  165. @item remove
  166. @end table
  167. @item sample_aspect_ratio
  168. Set the sample aspect ratio in the stream in the VUI parameters.
  169. @item video_format
  170. @item video_full_range_flag
  171. Set the video format in the stream (see H.265 section E.3.1 and
  172. table E.2).
  173. @item colour_primaries
  174. @item transfer_characteristics
  175. @item matrix_coefficients
  176. Set the colour description in the stream (see H.265 section E.3.1
  177. and tables E.3, E.4 and E.5).
  178. @item chroma_sample_loc_type
  179. Set the chroma sample location in the stream (see H.265 section
  180. E.3.1 and figure E.1).
  181. @item tick_rate
  182. Set the tick rate in the VPS and VUI parameters (num_units_in_tick /
  183. time_scale). Combined with @option{num_ticks_poc_diff_one}, this can
  184. set a constant framerate in the stream. Note that it is likely to be
  185. overridden by container parameters when the stream is in a container.
  186. @item num_ticks_poc_diff_one
  187. Set poc_proportional_to_timing_flag in VPS and VUI and use this value
  188. to set num_ticks_poc_diff_one_minus1 (see H.265 sections 7.4.3.1 and
  189. E.3.1). Ignored if @option{tick_rate} is not also set.
  190. @item crop_left
  191. @item crop_right
  192. @item crop_top
  193. @item crop_bottom
  194. Set the conformance window cropping offsets in the SPS. These values
  195. will replace the current ones if the stream is already cropped.
  196. These fields are set in pixels. Note that some sizes may not be
  197. representable if the chroma is subsampled (H.265 section 7.4.3.2.1).
  198. @end table
  199. @section hevc_mp4toannexb
  200. Convert an HEVC/H.265 bitstream from length prefixed mode to start code
  201. prefixed mode (as defined in the Annex B of the ITU-T H.265
  202. specification).
  203. This is required by some streaming formats, typically the MPEG-2
  204. transport stream format (muxer @code{mpegts}).
  205. For example to remux an MP4 file containing an HEVC stream to mpegts
  206. format with @command{ffmpeg}, you can use the command:
  207. @example
  208. ffmpeg -i INPUT.mp4 -codec copy -bsf:v hevc_mp4toannexb OUTPUT.ts
  209. @end example
  210. Please note that this filter is auto-inserted for MPEG-TS (muxer
  211. @code{mpegts}) and raw HEVC/H.265 (muxer @code{h265} or
  212. @code{hevc}) output formats.
  213. @section imxdump
  214. Modifies the bitstream to fit in MOV and to be usable by the Final Cut
  215. Pro decoder. This filter only applies to the mpeg2video codec, and is
  216. likely not needed for Final Cut Pro 7 and newer with the appropriate
  217. @option{-tag:v}.
  218. For example, to remux 30 MB/sec NTSC IMX to MOV:
  219. @example
  220. ffmpeg -i input.mxf -c copy -bsf:v imxdump -tag:v mx3n output.mov
  221. @end example
  222. @section mjpeg2jpeg
  223. Convert MJPEG/AVI1 packets to full JPEG/JFIF packets.
  224. MJPEG is a video codec wherein each video frame is essentially a
  225. JPEG image. The individual frames can be extracted without loss,
  226. e.g. by
  227. @example
  228. ffmpeg -i ../some_mjpeg.avi -c:v copy frames_%d.jpg
  229. @end example
  230. Unfortunately, these chunks are incomplete JPEG images, because
  231. they lack the DHT segment required for decoding. Quoting from
  232. @url{http://www.digitalpreservation.gov/formats/fdd/fdd000063.shtml}:
  233. Avery Lee, writing in the rec.video.desktop newsgroup in 2001,
  234. commented that "MJPEG, or at least the MJPEG in AVIs having the
  235. MJPG fourcc, is restricted JPEG with a fixed -- and *omitted* --
  236. Huffman table. The JPEG must be YCbCr colorspace, it must be 4:2:2,
  237. and it must use basic Huffman encoding, not arithmetic or
  238. progressive. . . . You can indeed extract the MJPEG frames and
  239. decode them with a regular JPEG decoder, but you have to prepend
  240. the DHT segment to them, or else the decoder won't have any idea
  241. how to decompress the data. The exact table necessary is given in
  242. the OpenDML spec."
  243. This bitstream filter patches the header of frames extracted from an MJPEG
  244. stream (carrying the AVI1 header ID and lacking a DHT segment) to
  245. produce fully qualified JPEG images.
  246. @example
  247. ffmpeg -i mjpeg-movie.avi -c:v copy -bsf:v mjpeg2jpeg frame_%d.jpg
  248. exiftran -i -9 frame*.jpg
  249. ffmpeg -i frame_%d.jpg -c:v copy rotated.avi
  250. @end example
  251. @section mjpegadump
  252. Add an MJPEG A header to the bitstream, to enable decoding by
  253. Quicktime.
  254. @anchor{mov2textsub}
  255. @section mov2textsub
  256. Extract a representable text file from MOV subtitles, stripping the
  257. metadata header from each subtitle packet.
  258. See also the @ref{text2movsub} filter.
  259. @section mp3decomp
  260. Decompress non-standard compressed MP3 audio headers.
  261. @section mpeg2_metadata
  262. Modify metadata embedded in an MPEG-2 stream.
  263. @table @option
  264. @item display_aspect_ratio
  265. Set the display aspect ratio in the stream.
  266. The following fixed values are supported:
  267. @table @option
  268. @item 4/3
  269. @item 16/9
  270. @item 221/100
  271. @end table
  272. Any other value will result in square pixels being signalled instead
  273. (see H.262 section 6.3.3 and table 6-3).
  274. @item frame_rate
  275. Set the frame rate in the stream. This is constructed from a table
  276. of known values combined with a small multiplier and divisor - if
  277. the supplied value is not exactly representable, the nearest
  278. representable value will be used instead (see H.262 section 6.3.3
  279. and table 6-4).
  280. @item video_format
  281. Set the video format in the stream (see H.262 section 6.3.6 and
  282. table 6-6).
  283. @item colour_primaries
  284. @item transfer_characteristics
  285. @item matrix_coefficients
  286. Set the colour description in the stream (see H.262 section 6.3.6
  287. and tables 6-7, 6-8 and 6-9).
  288. @end table
  289. @section mpeg4_unpack_bframes
  290. Unpack DivX-style packed B-frames.
  291. DivX-style packed B-frames are not valid MPEG-4 and were only a
  292. workaround for the broken Video for Windows subsystem.
  293. They use more space, can cause minor AV sync issues, require more
  294. CPU power to decode (unless the player has some decoded picture queue
  295. to compensate the 2,0,2,0 frame per packet style) and cause
  296. trouble if copied into a standard container like mp4 or mpeg-ps/ts,
  297. because MPEG-4 decoders may not be able to decode them, since they are
  298. not valid MPEG-4.
  299. For example to fix an AVI file containing an MPEG-4 stream with
  300. DivX-style packed B-frames using @command{ffmpeg}, you can use the command:
  301. @example
  302. ffmpeg -i INPUT.avi -codec copy -bsf:v mpeg4_unpack_bframes OUTPUT.avi
  303. @end example
  304. @section noise
  305. Damages the contents of packets or simply drops them without damaging the
  306. container. Can be used for fuzzing or testing error resilience/concealment.
  307. Parameters:
  308. @table @option
  309. @item amount
  310. A numeral string, whose value is related to how often output bytes will
  311. be modified. Therefore, values below or equal to 0 are forbidden, and
  312. the lower the more frequent bytes will be modified, with 1 meaning
  313. every byte is modified.
  314. @item dropamount
  315. A numeral string, whose value is related to how often packets will be dropped.
  316. Therefore, values below or equal to 0 are forbidden, and the lower the more
  317. frequent packets will be dropped, with 1 meaning every packet is dropped.
  318. @end table
  319. The following example applies the modification to every byte but does not drop
  320. any packets.
  321. @example
  322. ffmpeg -i INPUT -c copy -bsf noise[=1] output.mkv
  323. @end example
  324. @section null
  325. This bitstream filter passes the packets through unchanged.
  326. @section remove_extra
  327. Remove extradata from packets.
  328. It accepts the following parameter:
  329. @table @option
  330. @item freq
  331. Set which frame types to remove extradata from.
  332. @table @samp
  333. @item k
  334. Remove extradata from non-keyframes only.
  335. @item keyframe
  336. Remove extradata from keyframes only.
  337. @item e, all
  338. Remove extradata from all frames.
  339. @end table
  340. @end table
  341. @anchor{text2movsub}
  342. @section text2movsub
  343. Convert text subtitles to MOV subtitles (as used by the @code{mov_text}
  344. codec) with metadata headers.
  345. See also the @ref{mov2textsub} filter.
  346. @section trace_headers
  347. Log trace output containing all syntax elements in the coded stream
  348. headers (everything above the level of individual coded blocks).
  349. This can be useful for debugging low-level stream issues.
  350. Supports H.264, H.265 and MPEG-2.
  351. @section vp9_superframe
  352. Merge VP9 invisible (alt-ref) frames back into VP9 superframes. This
  353. fixes merging of split/segmented VP9 streams where the alt-ref frame
  354. was split from its visible counterpart.
  355. @section vp9_superframe_split
  356. Split VP9 superframes into single frames.
  357. @section vp9_raw_reorder
  358. Given a VP9 stream with correct timestamps but possibly out of order,
  359. insert additional show-existing-frame packets to correct the ordering.
  360. @c man end BITSTREAM FILTERS