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.

256 lines
7.8KB

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