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.

274 lines
8.4KB

  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. The additional argument specifies which packets should be filtered.
  37. It accepts the values:
  38. @table @samp
  39. @item a
  40. add extradata to all key packets, but only if @var{local_header} is
  41. set in the @option{flags2} codec context field
  42. @item k
  43. add extradata to all key packets
  44. @item e
  45. add extradata to all packets
  46. @end table
  47. If not specified it is assumed @samp{k}.
  48. For example the following @command{ffmpeg} command forces a global
  49. header (thus disabling individual packet headers) in the H.264 packets
  50. generated by the @code{libx264} encoder, but corrects them by adding
  51. the header stored in extradata to the key packets:
  52. @example
  53. ffmpeg -i INPUT -map 0 -flags:v +global_header -c:v libx264 -bsf:v dump_extra out.ts
  54. @end example
  55. @section extract_extradata
  56. Extract the in-band extradata.
  57. Certain codecs allow the long-term headers (e.g. MPEG-2 sequence headers,
  58. or H.264/HEVC (VPS/)SPS/PPS) to be transmitted either "in-band" (i.e. as a part
  59. of the bitstream containing the coded frames) or "out of band" (e.g. on the
  60. container level). This latter form is called "extradata" in FFmpeg terminology.
  61. This bitstream filter detects the in-band headers and makes them available as
  62. extradata.
  63. @table @option
  64. @item remove
  65. When this option is enabled, the long-term headers are removed from the
  66. bitstream after extraction.
  67. @end table
  68. @section h264_mp4toannexb
  69. Convert an H.264 bitstream from length prefixed mode to start code
  70. prefixed mode (as defined in the Annex B of the ITU-T H.264
  71. specification).
  72. This is required by some streaming formats, typically the MPEG-2
  73. transport stream format (muxer @code{mpegts}).
  74. For example to remux an MP4 file containing an H.264 stream to mpegts
  75. format with @command{ffmpeg}, you can use the command:
  76. @example
  77. ffmpeg -i INPUT.mp4 -codec copy -bsf:v h264_mp4toannexb OUTPUT.ts
  78. @end example
  79. Please note that this filter is auto-inserted for MPEG-TS (muxer
  80. @code{mpegts}) and raw H.264 (muxer @code{h264}) output formats.
  81. @section hevc_mp4toannexb
  82. Convert an HEVC/H.265 bitstream from length prefixed mode to start code
  83. prefixed mode (as defined in the Annex B of the ITU-T H.265
  84. specification).
  85. This is required by some streaming formats, typically the MPEG-2
  86. transport stream format (muxer @code{mpegts}).
  87. For example to remux an MP4 file containing an HEVC stream to mpegts
  88. format with @command{ffmpeg}, you can use the command:
  89. @example
  90. ffmpeg -i INPUT.mp4 -codec copy -bsf:v hevc_mp4toannexb OUTPUT.ts
  91. @end example
  92. Please note that this filter is auto-inserted for MPEG-TS (muxer
  93. @code{mpegts}) and raw HEVC/H.265 (muxer @code{h265} or
  94. @code{hevc}) output formats.
  95. @section imxdump
  96. Modifies the bitstream to fit in MOV and to be usable by the Final Cut
  97. Pro decoder. This filter only applies to the mpeg2video codec, and is
  98. likely not needed for Final Cut Pro 7 and newer with the appropriate
  99. @option{-tag:v}.
  100. For example, to remux 30 MB/sec NTSC IMX to MOV:
  101. @example
  102. ffmpeg -i input.mxf -c copy -bsf:v imxdump -tag:v mx3n output.mov
  103. @end example
  104. @section mjpeg2jpeg
  105. Convert MJPEG/AVI1 packets to full JPEG/JFIF packets.
  106. MJPEG is a video codec wherein each video frame is essentially a
  107. JPEG image. The individual frames can be extracted without loss,
  108. e.g. by
  109. @example
  110. ffmpeg -i ../some_mjpeg.avi -c:v copy frames_%d.jpg
  111. @end example
  112. Unfortunately, these chunks are incomplete JPEG images, because
  113. they lack the DHT segment required for decoding. Quoting from
  114. @url{http://www.digitalpreservation.gov/formats/fdd/fdd000063.shtml}:
  115. Avery Lee, writing in the rec.video.desktop newsgroup in 2001,
  116. commented that "MJPEG, or at least the MJPEG in AVIs having the
  117. MJPG fourcc, is restricted JPEG with a fixed -- and *omitted* --
  118. Huffman table. The JPEG must be YCbCr colorspace, it must be 4:2:2,
  119. and it must use basic Huffman encoding, not arithmetic or
  120. progressive. . . . You can indeed extract the MJPEG frames and
  121. decode them with a regular JPEG decoder, but you have to prepend
  122. the DHT segment to them, or else the decoder won't have any idea
  123. how to decompress the data. The exact table necessary is given in
  124. the OpenDML spec."
  125. This bitstream filter patches the header of frames extracted from an MJPEG
  126. stream (carrying the AVI1 header ID and lacking a DHT segment) to
  127. produce fully qualified JPEG images.
  128. @example
  129. ffmpeg -i mjpeg-movie.avi -c:v copy -bsf:v mjpeg2jpeg frame_%d.jpg
  130. exiftran -i -9 frame*.jpg
  131. ffmpeg -i frame_%d.jpg -c:v copy rotated.avi
  132. @end example
  133. @section mjpegadump
  134. Add an MJPEG A header to the bitstream, to enable decoding by
  135. Quicktime.
  136. @anchor{mov2textsub}
  137. @section mov2textsub
  138. Extract a representable text file from MOV subtitles, stripping the
  139. metadata header from each subtitle packet.
  140. See also the @ref{text2movsub} filter.
  141. @section mp3decomp
  142. Decompress non-standard compressed MP3 audio headers.
  143. @section mpeg4_unpack_bframes
  144. Unpack DivX-style packed B-frames.
  145. DivX-style packed B-frames are not valid MPEG-4 and were only a
  146. workaround for the broken Video for Windows subsystem.
  147. They use more space, can cause minor AV sync issues, require more
  148. CPU power to decode (unless the player has some decoded picture queue
  149. to compensate the 2,0,2,0 frame per packet style) and cause
  150. trouble if copied into a standard container like mp4 or mpeg-ps/ts,
  151. because MPEG-4 decoders may not be able to decode them, since they are
  152. not valid MPEG-4.
  153. For example to fix an AVI file containing an MPEG-4 stream with
  154. DivX-style packed B-frames using @command{ffmpeg}, you can use the command:
  155. @example
  156. ffmpeg -i INPUT.avi -codec copy -bsf:v mpeg4_unpack_bframes OUTPUT.avi
  157. @end example
  158. @section noise
  159. Damages the contents of packets without damaging the container. Can be
  160. used for fuzzing or testing error resilience/concealment.
  161. Parameters:
  162. A numeral string, whose value is related to how often output bytes will
  163. be modified. Therefore, values below or equal to 0 are forbidden, and
  164. the lower the more frequent bytes will be modified, with 1 meaning
  165. every byte is modified.
  166. @example
  167. ffmpeg -i INPUT -c copy -bsf noise[=1] output.mkv
  168. @end example
  169. applies the modification to every byte.
  170. @section remove_extra
  171. Remove extradata from packets.
  172. It accepts the following parameter:
  173. @table @option
  174. @item freq
  175. Set which frame types to remove extradata from.
  176. @table @samp
  177. @item k
  178. Remove extradata from non-keyframes only.
  179. @item keyframe
  180. Remove extradata from keyframes only.
  181. @item e, all
  182. Remove extradata from all frames.
  183. @end table
  184. @end table
  185. @anchor{text2movsub}
  186. @section text2movsub
  187. Convert text subtitles to MOV subtitles (as used by the @code{mov_text}
  188. codec) with metadata headers.
  189. See also the @ref{mov2textsub} filter.
  190. @section vp9_superframe
  191. Merge VP9 invisible (alt-ref) frames back into VP9 superframes. This
  192. fixes merging of split/segmented VP9 streams where the alt-ref frame
  193. was split from its visible counterpart.
  194. @c man end BITSTREAM FILTERS