<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8" /> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <title>FFmpeg documentation</title> <link rel="stylesheet" href="bootstrap.min.css" /> <link rel="stylesheet" href="style.min.css" /> <meta name="description" content="FFmpeg Bitstream Filters Documentation: "> <meta name="keywords" content="FFmpeg documentation : FFmpeg Bitstream Filters "> <meta name="Generator" content="texi2html 5.0"> <!-- Created on September 13, 2017 by texi2html 5.0 --> <!-- texi2html was written by: Lionel Cons <Lionel.Cons@cern.ch> (original author) Karl Berry <karl@freefriends.org> Olaf Bachmann <obachman@mathematik.uni-kl.de> and many others. Maintained by: Many creative people. Send bugs and suggestions to <texi2html-bug@nongnu.org> --> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> </head> <body> <div class="container"> <h1 class="titlefont">FFmpeg Bitstream Filters Documentation</h1> <hr> <a name="SEC_Top"></a> <a name="SEC_Contents"></a> <h1>Table of Contents</h1> <div class="contents"> <ul class="no-bullet"> <li><a name="toc-Description" href="#Description">1 Description</a></li> <li><a name="toc-Bitstream-Filters" href="#Bitstream-Filters">2 Bitstream Filters</a> <ul class="no-bullet"> <li><a name="toc-aac_005fadtstoasc" href="#aac_005fadtstoasc">2.1 aac_adtstoasc</a></li> <li><a name="toc-chomp" href="#chomp">2.2 chomp</a></li> <li><a name="toc-dca_005fcore" href="#dca_005fcore">2.3 dca_core</a></li> <li><a name="toc-dump_005fextra" href="#dump_005fextra">2.4 dump_extra</a></li> <li><a name="toc-extract_005fextradata" href="#extract_005fextradata">2.5 extract_extradata</a></li> <li><a name="toc-h264_005fmp4toannexb" href="#h264_005fmp4toannexb">2.6 h264_mp4toannexb</a></li> <li><a name="toc-hevc_005fmp4toannexb" href="#hevc_005fmp4toannexb">2.7 hevc_mp4toannexb</a></li> <li><a name="toc-imxdump" href="#imxdump">2.8 imxdump</a></li> <li><a name="toc-mjpeg2jpeg" href="#mjpeg2jpeg">2.9 mjpeg2jpeg</a></li> <li><a name="toc-mjpegadump" href="#mjpegadump">2.10 mjpegadump</a></li> <li><a name="toc-mov2textsub-1" href="#mov2textsub-1">2.11 mov2textsub</a></li> <li><a name="toc-mp3decomp" href="#mp3decomp">2.12 mp3decomp</a></li> <li><a name="toc-mpeg4_005funpack_005fbframes" href="#mpeg4_005funpack_005fbframes">2.13 mpeg4_unpack_bframes</a></li> <li><a name="toc-noise" href="#noise">2.14 noise</a></li> <li><a name="toc-remove_005fextra" href="#remove_005fextra">2.15 remove_extra</a></li> <li><a name="toc-text2movsub-1" href="#text2movsub-1">2.16 text2movsub</a></li> <li><a name="toc-vp9_005fsuperframe" href="#vp9_005fsuperframe">2.17 vp9_superframe</a></li> </ul></li> <li><a name="toc-See-Also" href="#See-Also">3 See Also</a></li> <li><a name="toc-Authors" href="#Authors">4 Authors</a></li> </ul> </div> <hr size="6"> <a name="Description"></a> <h1 class="chapter"><a href="ffmpeg-bitstream-filters.html#toc-Description">1 Description</a></h1> <p>This document describes the bitstream filters provided by the libavcodec library. </p> <p>A bitstream filter operates on the encoded stream data, and performs bitstream level modifications without performing decoding. </p> <a name="Bitstream-Filters"></a> <h1 class="chapter"><a href="ffmpeg-bitstream-filters.html#toc-Bitstream-Filters">2 Bitstream Filters</a></h1> <p>When you configure your FFmpeg build, all the supported bitstream filters are enabled by default. You can list all available ones using the configure option <code>--list-bsfs</code>. </p> <p>You can disable all the bitstream filters using the configure option <code>--disable-bsfs</code>, and selectively enable any bitstream filter using the option <code>--enable-bsf=BSF</code>, or you can disable a particular bitstream filter using the option <code>--disable-bsf=BSF</code>. </p> <p>The option <code>-bsfs</code> of the ff* tools will display the list of all the supported bitstream filters included in your build. </p> <p>The ff* tools have a -bsf option applied per stream, taking a comma-separated list of filters, whose parameters follow the filter name after a ’=’. </p> <div class="example"> <pre class="example">ffmpeg -i INPUT -c:v copy -bsf:v filter1[=opt1=str1:opt2=str2][,filter2] OUTPUT </pre></div> <p>Below is a description of the currently available bitstream filters, with their parameters, if any. </p> <a name="aac_005fadtstoasc"></a> <h2 class="section"><a href="ffmpeg-bitstream-filters.html#toc-aac_005fadtstoasc">2.1 aac_adtstoasc</a></h2> <p>Convert MPEG-2/4 AAC ADTS to an MPEG-4 Audio Specific Configuration bitstream. </p> <p>This filter creates an MPEG-4 AudioSpecificConfig from an MPEG-2/4 ADTS header and removes the ADTS header. </p> <p>This filter is required for example when copying an AAC stream from a raw ADTS AAC or an MPEG-TS container to MP4A-LATM, to an FLV file, or to MOV/MP4 files and related formats such as 3GP or M4A. Please note that it is auto-inserted for MP4A-LATM and MOV/MP4 and related formats. </p> <a name="chomp"></a> <h2 class="section"><a href="ffmpeg-bitstream-filters.html#toc-chomp">2.2 chomp</a></h2> <p>Remove zero padding at the end of a packet. </p> <a name="dca_005fcore"></a> <h2 class="section"><a href="ffmpeg-bitstream-filters.html#toc-dca_005fcore">2.3 dca_core</a></h2> <p>Extract the core from a DCA/DTS stream, dropping extensions such as DTS-HD. </p> <a name="dump_005fextra"></a> <h2 class="section"><a href="ffmpeg-bitstream-filters.html#toc-dump_005fextra">2.4 dump_extra</a></h2> <p>Add extradata to the beginning of the filtered packets. </p> <p>The additional argument specifies which packets should be filtered. It accepts the values: </p><dl compact="compact"> <dt>‘<samp>a</samp>’</dt> <dd><p>add extradata to all key packets, but only if <var>local_header</var> is set in the ‘<samp>flags2</samp>’ codec context field </p> </dd> <dt>‘<samp>k</samp>’</dt> <dd><p>add extradata to all key packets </p> </dd> <dt>‘<samp>e</samp>’</dt> <dd><p>add extradata to all packets </p></dd> </dl> <p>If not specified it is assumed ‘<samp>k</samp>’. </p> <p>For example the following <code>ffmpeg</code> command forces a global header (thus disabling individual packet headers) in the H.264 packets generated by the <code>libx264</code> encoder, but corrects them by adding the header stored in extradata to the key packets: </p><div class="example"> <pre class="example">ffmpeg -i INPUT -map 0 -flags:v +global_header -c:v libx264 -bsf:v dump_extra out.ts </pre></div> <a name="extract_005fextradata"></a> <h2 class="section"><a href="ffmpeg-bitstream-filters.html#toc-extract_005fextradata">2.5 extract_extradata</a></h2> <p>Extract the in-band extradata. </p> <p>Certain codecs allow the long-term headers (e.g. MPEG-2 sequence headers, or H.264/HEVC (VPS/)SPS/PPS) to be transmitted either "in-band" (i.e. as a part of the bitstream containing the coded frames) or "out of band" (e.g. on the container level). This latter form is called "extradata" in FFmpeg terminology. </p> <p>This bitstream filter detects the in-band headers and makes them available as extradata. </p> <dl compact="compact"> <dt>‘<samp>remove</samp>’</dt> <dd><p>When this option is enabled, the long-term headers are removed from the bitstream after extraction. </p></dd> </dl> <a name="h264_005fmp4toannexb"></a> <h2 class="section"><a href="ffmpeg-bitstream-filters.html#toc-h264_005fmp4toannexb">2.6 h264_mp4toannexb</a></h2> <p>Convert an H.264 bitstream from length prefixed mode to start code prefixed mode (as defined in the Annex B of the ITU-T H.264 specification). </p> <p>This is required by some streaming formats, typically the MPEG-2 transport stream format (muxer <code>mpegts</code>). </p> <p>For example to remux an MP4 file containing an H.264 stream to mpegts format with <code>ffmpeg</code>, you can use the command: </p> <div class="example"> <pre class="example">ffmpeg -i INPUT.mp4 -codec copy -bsf:v h264_mp4toannexb OUTPUT.ts </pre></div> <p>Please note that this filter is auto-inserted for MPEG-TS (muxer <code>mpegts</code>) and raw H.264 (muxer <code>h264</code>) output formats. </p> <a name="hevc_005fmp4toannexb"></a> <h2 class="section"><a href="ffmpeg-bitstream-filters.html#toc-hevc_005fmp4toannexb">2.7 hevc_mp4toannexb</a></h2> <p>Convert an HEVC/H.265 bitstream from length prefixed mode to start code prefixed mode (as defined in the Annex B of the ITU-T H.265 specification). </p> <p>This is required by some streaming formats, typically the MPEG-2 transport stream format (muxer <code>mpegts</code>). </p> <p>For example to remux an MP4 file containing an HEVC stream to mpegts format with <code>ffmpeg</code>, you can use the command: </p> <div class="example"> <pre class="example">ffmpeg -i INPUT.mp4 -codec copy -bsf:v hevc_mp4toannexb OUTPUT.ts </pre></div> <p>Please note that this filter is auto-inserted for MPEG-TS (muxer <code>mpegts</code>) and raw HEVC/H.265 (muxer <code>h265</code> or <code>hevc</code>) output formats. </p> <a name="imxdump"></a> <h2 class="section"><a href="ffmpeg-bitstream-filters.html#toc-imxdump">2.8 imxdump</a></h2> <p>Modifies the bitstream to fit in MOV and to be usable by the Final Cut Pro decoder. This filter only applies to the mpeg2video codec, and is likely not needed for Final Cut Pro 7 and newer with the appropriate ‘<samp>-tag:v</samp>’. </p> <p>For example, to remux 30 MB/sec NTSC IMX to MOV: </p> <div class="example"> <pre class="example">ffmpeg -i input.mxf -c copy -bsf:v imxdump -tag:v mx3n output.mov </pre></div> <a name="mjpeg2jpeg"></a> <h2 class="section"><a href="ffmpeg-bitstream-filters.html#toc-mjpeg2jpeg">2.9 mjpeg2jpeg</a></h2> <p>Convert MJPEG/AVI1 packets to full JPEG/JFIF packets. </p> <p>MJPEG is a video codec wherein each video frame is essentially a JPEG image. The individual frames can be extracted without loss, e.g. by </p> <div class="example"> <pre class="example">ffmpeg -i ../some_mjpeg.avi -c:v copy frames_%d.jpg </pre></div> <p>Unfortunately, these chunks are incomplete JPEG images, because they lack the DHT segment required for decoding. Quoting from <a href="http://www.digitalpreservation.gov/formats/fdd/fdd000063.shtml">http://www.digitalpreservation.gov/formats/fdd/fdd000063.shtml</a>: </p> <p>Avery Lee, writing in the rec.video.desktop newsgroup in 2001, commented that "MJPEG, or at least the MJPEG in AVIs having the MJPG fourcc, is restricted JPEG with a fixed – and *omitted* – Huffman table. The JPEG must be YCbCr colorspace, it must be 4:2:2, and it must use basic Huffman encoding, not arithmetic or progressive. . . . You can indeed extract the MJPEG frames and decode them with a regular JPEG decoder, but you have to prepend the DHT segment to them, or else the decoder won’t have any idea how to decompress the data. The exact table necessary is given in the OpenDML spec." </p> <p>This bitstream filter patches the header of frames extracted from an MJPEG stream (carrying the AVI1 header ID and lacking a DHT segment) to produce fully qualified JPEG images. </p> <div class="example"> <pre class="example">ffmpeg -i mjpeg-movie.avi -c:v copy -bsf:v mjpeg2jpeg frame_%d.jpg exiftran -i -9 frame*.jpg ffmpeg -i frame_%d.jpg -c:v copy rotated.avi </pre></div> <a name="mjpegadump"></a> <h2 class="section"><a href="ffmpeg-bitstream-filters.html#toc-mjpegadump">2.10 mjpegadump</a></h2> <p>Add an MJPEG A header to the bitstream, to enable decoding by Quicktime. </p> <p><a name="mov2textsub"></a> </p><a name="mov2textsub-1"></a> <h2 class="section"><a href="ffmpeg-bitstream-filters.html#toc-mov2textsub-1">2.11 mov2textsub</a></h2> <p>Extract a representable text file from MOV subtitles, stripping the metadata header from each subtitle packet. </p> <p>See also the <a href="#text2movsub">text2movsub</a> filter. </p> <a name="mp3decomp"></a> <h2 class="section"><a href="ffmpeg-bitstream-filters.html#toc-mp3decomp">2.12 mp3decomp</a></h2> <p>Decompress non-standard compressed MP3 audio headers. </p> <a name="mpeg4_005funpack_005fbframes"></a> <h2 class="section"><a href="ffmpeg-bitstream-filters.html#toc-mpeg4_005funpack_005fbframes">2.13 mpeg4_unpack_bframes</a></h2> <p>Unpack DivX-style packed B-frames. </p> <p>DivX-style packed B-frames are not valid MPEG-4 and were only a workaround for the broken Video for Windows subsystem. They use more space, can cause minor AV sync issues, require more CPU power to decode (unless the player has some decoded picture queue to compensate the 2,0,2,0 frame per packet style) and cause trouble if copied into a standard container like mp4 or mpeg-ps/ts, because MPEG-4 decoders may not be able to decode them, since they are not valid MPEG-4. </p> <p>For example to fix an AVI file containing an MPEG-4 stream with DivX-style packed B-frames using <code>ffmpeg</code>, you can use the command: </p> <div class="example"> <pre class="example">ffmpeg -i INPUT.avi -codec copy -bsf:v mpeg4_unpack_bframes OUTPUT.avi </pre></div> <a name="noise"></a> <h2 class="section"><a href="ffmpeg-bitstream-filters.html#toc-noise">2.14 noise</a></h2> <p>Damages the contents of packets without damaging the container. Can be used for fuzzing or testing error resilience/concealment. </p> <p>Parameters: A numeral string, whose value is related to how often output bytes will be modified. Therefore, values below or equal to 0 are forbidden, and the lower the more frequent bytes will be modified, with 1 meaning every byte is modified. </p> <div class="example"> <pre class="example">ffmpeg -i INPUT -c copy -bsf noise[=1] output.mkv </pre></div> <p>applies the modification to every byte. </p> <a name="remove_005fextra"></a> <h2 class="section"><a href="ffmpeg-bitstream-filters.html#toc-remove_005fextra">2.15 remove_extra</a></h2> <p>Remove extradata from packets. </p> <p>It accepts the following parameter: </p><dl compact="compact"> <dt>‘<samp>freq</samp>’</dt> <dd><p>Set which frame types to remove extradata from. </p> <dl compact="compact"> <dt>‘<samp>k</samp>’</dt> <dd><p>Remove extradata from non-keyframes only. </p> </dd> <dt>‘<samp>keyframe</samp>’</dt> <dd><p>Remove extradata from keyframes only. </p> </dd> <dt>‘<samp>e, all</samp>’</dt> <dd><p>Remove extradata from all frames. </p> </dd> </dl> </dd> </dl> <p><a name="text2movsub"></a> </p><a name="text2movsub-1"></a> <h2 class="section"><a href="ffmpeg-bitstream-filters.html#toc-text2movsub-1">2.16 text2movsub</a></h2> <p>Convert text subtitles to MOV subtitles (as used by the <code>mov_text</code> codec) with metadata headers. </p> <p>See also the <a href="#mov2textsub">mov2textsub</a> filter. </p> <a name="vp9_005fsuperframe"></a> <h2 class="section"><a href="ffmpeg-bitstream-filters.html#toc-vp9_005fsuperframe">2.17 vp9_superframe</a></h2> <p>Merge VP9 invisible (alt-ref) frames back into VP9 superframes. This fixes merging of split/segmented VP9 streams where the alt-ref frame was split from its visible counterpart. </p> <a name="See-Also"></a> <h1 class="chapter"><a href="ffmpeg-bitstream-filters.html#toc-See-Also">3 See Also</a></h1> <p><a href="ffmpeg.html">ffmpeg</a>, <a href="ffplay.html">ffplay</a>, <a href="ffprobe.html">ffprobe</a>, <a href="ffserver.html">ffserver</a>, <a href="libavcodec.html">libavcodec</a> </p> <a name="Authors"></a> <h1 class="chapter"><a href="ffmpeg-bitstream-filters.html#toc-Authors">4 Authors</a></h1> <p>The FFmpeg developers. </p> <p>For details about the authorship, see the Git history of the project (git://source.ffmpeg.org/ffmpeg), e.g. by typing the command <code>git log</code> in the FFmpeg source directory, or browsing the online repository at <a href="http://source.ffmpeg.org">http://source.ffmpeg.org</a>. </p> <p>Maintainers for the specific components are listed in the file ‘<tt>MAINTAINERS</tt>’ in the source code tree. </p> </div> </body> </html>