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.

153 lines
4.7KB

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