bitstream_filters.texi 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  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 MPEG-4 Audio Specific Configuration
  22. bitstream filter.
  23. This filter creates an MPEG-4 AudioSpecificConfig from an MPEG-2/4
  24. ADTS header and removes the ADTS header.
  25. This is required for example when copying an AAC stream from a raw
  26. ADTS AAC container to a FLV or a MOV/MP4 file.
  27. @section chomp
  28. Remove zero padding at the end of a packet.
  29. @section dump_extra
  30. Add extradata to the beginning of the filtered packets.
  31. The additional argument specifies which packets should be filtered.
  32. It accepts the values:
  33. @table @samp
  34. @item a
  35. add extradata to all key packets, but only if @var{local_header} is
  36. set in the @option{flags2} codec context field
  37. @item k
  38. add extradata to all key packets
  39. @item e
  40. add extradata to all packets
  41. @end table
  42. If not specified it is assumed @samp{k}.
  43. For example the following @command{ffmpeg} command forces a global
  44. header (thus disabling individual packet headers) in the H.264 packets
  45. generated by the @code{libx264} encoder, but corrects them by adding
  46. the header stored in extradata to the key packets:
  47. @example
  48. ffmpeg -i INPUT -map 0 -flags:v +global_header -c:v libx264 -bsf:v dump_extra out.ts
  49. @end example
  50. @section dca_core
  51. Extract DCA core from DTS-HD streams.
  52. @section h264_mp4toannexb
  53. Convert an H.264 bitstream from length prefixed mode to start code
  54. prefixed mode (as defined in the Annex B of the ITU-T H.264
  55. specification).
  56. This is required by some streaming formats, typically the MPEG-2
  57. transport stream format ("mpegts").
  58. For example to remux an MP4 file containing an H.264 stream to mpegts
  59. format with @command{ffmpeg}, you can use the command:
  60. @example
  61. ffmpeg -i INPUT.mp4 -codec copy -bsf:v h264_mp4toannexb OUTPUT.ts
  62. @end example
  63. @section imxdump
  64. Modifies the bitstream to fit in MOV and to be usable by the Final Cut
  65. Pro decoder. This filter only applies to the mpeg2video codec, and is
  66. likely not needed for Final Cut Pro 7 and newer with the appropriate
  67. @option{-tag:v}.
  68. For example, to remux 30 MB/sec NTSC IMX to MOV:
  69. @example
  70. ffmpeg -i input.mxf -c copy -bsf:v imxdump -tag:v mx3n output.mov
  71. @end example
  72. @section mjpeg2jpeg
  73. Convert MJPEG/AVI1 packets to full JPEG/JFIF packets.
  74. MJPEG is a video codec wherein each video frame is essentially a
  75. JPEG image. The individual frames can be extracted without loss,
  76. e.g. by
  77. @example
  78. ffmpeg -i ../some_mjpeg.avi -c:v copy frames_%d.jpg
  79. @end example
  80. Unfortunately, these chunks are incomplete JPEG images, because
  81. they lack the DHT segment required for decoding. Quoting from
  82. @url{http://www.digitalpreservation.gov/formats/fdd/fdd000063.shtml}:
  83. Avery Lee, writing in the rec.video.desktop newsgroup in 2001,
  84. commented that "MJPEG, or at least the MJPEG in AVIs having the
  85. MJPG fourcc, is restricted JPEG with a fixed -- and *omitted* --
  86. Huffman table. The JPEG must be YCbCr colorspace, it must be 4:2:2,
  87. and it must use basic Huffman encoding, not arithmetic or
  88. progressive. . . . You can indeed extract the MJPEG frames and
  89. decode them with a regular JPEG decoder, but you have to prepend
  90. the DHT segment to them, or else the decoder won't have any idea
  91. how to decompress the data. The exact table necessary is given in
  92. the OpenDML spec."
  93. This bitstream filter patches the header of frames extracted from an MJPEG
  94. stream (carrying the AVI1 header ID and lacking a DHT segment) to
  95. produce fully qualified JPEG images.
  96. @example
  97. ffmpeg -i mjpeg-movie.avi -c:v copy -bsf:v mjpeg2jpeg frame_%d.jpg
  98. exiftran -i -9 frame*.jpg
  99. ffmpeg -i frame_%d.jpg -c:v copy rotated.avi
  100. @end example
  101. @section mjpega_dump_header
  102. @section movsub
  103. @section mp3_header_decompress
  104. @section mpeg4_unpack_bframes
  105. Unpack DivX-style packed B-frames.
  106. DivX-style packed B-frames are not valid MPEG-4 and were only a
  107. workaround for the broken Video for Windows subsystem.
  108. They use more space, can cause minor AV sync issues, require more
  109. CPU power to decode (unless the player has some decoded picture queue
  110. to compensate the 2,0,2,0 frame per packet style) and cause
  111. trouble if copied into a standard container like mp4 or mpeg-ps/ts,
  112. because MPEG-4 decoders may not be able to decode them, since they are
  113. not valid MPEG-4.
  114. For example to fix an AVI file containing an MPEG-4 stream with
  115. DivX-style packed B-frames using @command{ffmpeg}, you can use the command:
  116. @example
  117. ffmpeg -i INPUT.avi -codec copy -bsf:v mpeg4_unpack_bframes OUTPUT.avi
  118. @end example
  119. @section noise
  120. Damages the contents of packets without damaging the container. Can be
  121. used for fuzzing or testing error resilience/concealment.
  122. Parameters:
  123. A numeral string, whose value is related to how often output bytes will
  124. be modified. Therefore, values below or equal to 0 are forbidden, and
  125. the lower the more frequent bytes will be modified, with 1 meaning
  126. every byte is modified.
  127. @example
  128. ffmpeg -i INPUT -c copy -bsf noise[=1] output.mkv
  129. @end example
  130. applies the modification to every byte.
  131. @section remove_extra
  132. @c man end BITSTREAM FILTERS