bitstream_filters.texi 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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. Below is a description of the currently available bitstream filters.
  13. @section aac_adtstoasc
  14. Convert MPEG-2/4 AAC ADTS to MPEG-4 Audio Specific Configuration
  15. bitstream filter.
  16. This filter creates an MPEG-4 AudioSpecificConfig from an MPEG-2/4
  17. ADTS header and removes the ADTS header.
  18. This is required for example when copying an AAC stream from a raw
  19. ADTS AAC container to a FLV or a MOV/MP4 file.
  20. @section chomp
  21. Remove zero padding at the end of a packet.
  22. @section dump_extra
  23. Add extradata to the beginning of the filtered packets.
  24. The additional argument specifies which packets should be filtered.
  25. It accepts the values:
  26. @table @samp
  27. @item a
  28. add extradata to all key packets, but only if @var{local_header} is
  29. set in the @option{flags2} codec context field
  30. @item k
  31. add extradata to all key packets
  32. @item e
  33. add extradata to all packets
  34. @end table
  35. If not specified it is assumed @samp{k}.
  36. For example the following @command{ffmpeg} command forces a global
  37. header (thus disabling individual packet headers) in the H.264 packets
  38. generated by the @code{libx264} encoder, but corrects them by adding
  39. the header stored in extradata to the key packets:
  40. @example
  41. ffmpeg -i INPUT -map 0 -flags:v +global_header -c:v libx264 -bsf:v dump_extra out.ts
  42. @end example
  43. @section h264_mp4toannexb
  44. Convert an H.264 bitstream from length prefixed mode to start code
  45. prefixed mode (as defined in the Annex B of the ITU-T H.264
  46. specification).
  47. This is required by some streaming formats, typically the MPEG-2
  48. transport stream format ("mpegts").
  49. For example to remux an MP4 file containing an H.264 stream to mpegts
  50. format with @command{ffmpeg}, you can use the command:
  51. @example
  52. ffmpeg -i INPUT.mp4 -codec copy -bsf:v h264_mp4toannexb OUTPUT.ts
  53. @end example
  54. @section imx_dump_header
  55. @section mjpeg2jpeg
  56. Convert MJPEG/AVI1 packets to full JPEG/JFIF packets.
  57. MJPEG is a video codec wherein each video frame is essentially a
  58. JPEG image. The individual frames can be extracted without loss,
  59. e.g. by
  60. @example
  61. ffmpeg -i ../some_mjpeg.avi -c:v copy frames_%d.jpg
  62. @end example
  63. Unfortunately, these chunks are incomplete JPEG images, because
  64. they lack the DHT segment required for decoding. Quoting from
  65. @url{http://www.digitalpreservation.gov/formats/fdd/fdd000063.shtml}:
  66. Avery Lee, writing in the rec.video.desktop newsgroup in 2001,
  67. commented that "MJPEG, or at least the MJPEG in AVIs having the
  68. MJPG fourcc, is restricted JPEG with a fixed -- and *omitted* --
  69. Huffman table. The JPEG must be YCbCr colorspace, it must be 4:2:2,
  70. and it must use basic Huffman encoding, not arithmetic or
  71. progressive. . . . You can indeed extract the MJPEG frames and
  72. decode them with a regular JPEG decoder, but you have to prepend
  73. the DHT segment to them, or else the decoder won't have any idea
  74. how to decompress the data. The exact table necessary is given in
  75. the OpenDML spec."
  76. This bitstream filter patches the header of frames extracted from an MJPEG
  77. stream (carrying the AVI1 header ID and lacking a DHT segment) to
  78. produce fully qualified JPEG images.
  79. @example
  80. ffmpeg -i mjpeg-movie.avi -c:v copy -bsf:v mjpeg2jpeg frame_%d.jpg
  81. exiftran -i -9 frame*.jpg
  82. ffmpeg -i frame_%d.jpg -c:v copy rotated.avi
  83. @end example
  84. @section mjpega_dump_header
  85. @section movsub
  86. @section mp3_header_decompress
  87. @section noise
  88. @section remove_extra
  89. @c man end BITSTREAM FILTERS