]> git.sesse.net Git - ffmpeg/blob - doc/bitstream_filters.texi
Merge commit '230b1c070baa3b6d4bd590426a365b843d60ff50'
[ffmpeg] / doc / bitstream_filters.texi
1 @chapter Bitstream Filters
2 @c man begin BITSTREAM FILTERS
3
4 When you configure your FFmpeg build, all the supported bitstream
5 filters are enabled by default. You can list all available ones using
6 the configure option @code{--list-bsfs}.
7
8 You can disable all the bitstream filters using the configure option
9 @code{--disable-bsfs}, and selectively enable any bitstream filter using
10 the option @code{--enable-bsf=BSF}, or you can disable a particular
11 bitstream filter using the option @code{--disable-bsf=BSF}.
12
13 The option @code{-bsfs} of the ff* tools will display the list of
14 all the supported bitstream filters included in your build.
15
16 The ff* tools have a -bsf option applied per stream, taking a
17 comma-separated list of filters, whose parameters follow the filter
18 name after a '='.
19
20 @example
21 ffmpeg -i INPUT -c:v copy -bsf:v filter1[=opt1=str1:opt2=str2][,filter2] OUTPUT
22 @end example
23
24 Below is a description of the currently available bitstream filters,
25 with their parameters, if any.
26
27 @section aac_adtstoasc
28
29 Convert MPEG-2/4 AAC ADTS to an MPEG-4 Audio Specific Configuration
30 bitstream.
31
32 This filter creates an MPEG-4 AudioSpecificConfig from an MPEG-2/4
33 ADTS header and removes the ADTS header.
34
35 This filter is required for example when copying an AAC stream from a
36 raw ADTS AAC or an MPEG-TS container to MP4A-LATM, to an FLV file, or
37 to MOV/MP4 files and related formats such as 3GP or M4A. Please note
38 that it is auto-inserted for MP4A-LATM and MOV/MP4 and related formats.
39
40 @section chomp
41
42 Remove zero padding at the end of a packet.
43
44 @section dca_core
45
46 Extract the core from a DCA/DTS stream, dropping extensions such as
47 DTS-HD.
48
49 @section dump_extra
50
51 Add extradata to the beginning of the filtered packets.
52
53 The additional argument specifies which packets should be filtered.
54 It accepts the values:
55 @table @samp
56 @item a
57 add extradata to all key packets, but only if @var{local_header} is
58 set in the @option{flags2} codec context field
59
60 @item k
61 add extradata to all key packets
62
63 @item e
64 add extradata to all packets
65 @end table
66
67 If not specified it is assumed @samp{k}.
68
69 For example the following @command{ffmpeg} command forces a global
70 header (thus disabling individual packet headers) in the H.264 packets
71 generated by the @code{libx264} encoder, but corrects them by adding
72 the header stored in extradata to the key packets:
73 @example
74 ffmpeg -i INPUT -map 0 -flags:v +global_header -c:v libx264 -bsf:v dump_extra out.ts
75 @end example
76
77 @section h264_mp4toannexb
78
79 Convert an H.264 bitstream from length prefixed mode to start code
80 prefixed mode (as defined in the Annex B of the ITU-T H.264
81 specification).
82
83 This is required by some streaming formats, typically the MPEG-2
84 transport stream format (muxer @code{mpegts}).
85
86 For example to remux an MP4 file containing an H.264 stream to mpegts
87 format with @command{ffmpeg}, you can use the command:
88
89 @example
90 ffmpeg -i INPUT.mp4 -codec copy -bsf:v h264_mp4toannexb OUTPUT.ts
91 @end example
92
93 Please note that this filter is auto-inserted for MPEG-TS (muxer
94 @code{mpegts}) and raw H.264 (muxer @code{h264}) output formats.
95
96 @section hevc_mp4toannexb
97
98 Convert an HEVC/H.265 bitstream from length prefixed mode to start code
99 prefixed mode (as defined in the Annex B of the ITU-T H.265
100 specification).
101
102 This is required by some streaming formats, typically the MPEG-2
103 transport stream format (muxer @code{mpegts}).
104
105 For example to remux an MP4 file containing an HEVC stream to mpegts
106 format with @command{ffmpeg}, you can use the command:
107
108 @example
109 ffmpeg -i INPUT.mp4 -codec copy -bsf:v hevc_mp4toannexb OUTPUT.ts
110 @end example
111
112 Please note that this filter is auto-inserted for MPEG-TS (muxer
113 @code{mpegts}) and raw HEVC/H.265 (muxer @code{h265} or
114 @code{hevc}) output formats.
115
116 @section imxdump
117
118 Modifies the bitstream to fit in MOV and to be usable by the Final Cut
119 Pro decoder. This filter only applies to the mpeg2video codec, and is
120 likely not needed for Final Cut Pro 7 and newer with the appropriate
121 @option{-tag:v}.
122
123 For example, to remux 30 MB/sec NTSC IMX to MOV:
124
125 @example
126 ffmpeg -i input.mxf -c copy -bsf:v imxdump -tag:v mx3n output.mov
127 @end example
128
129 @section mjpeg2jpeg
130
131 Convert MJPEG/AVI1 packets to full JPEG/JFIF packets.
132
133 MJPEG is a video codec wherein each video frame is essentially a
134 JPEG image. The individual frames can be extracted without loss,
135 e.g. by
136
137 @example
138 ffmpeg -i ../some_mjpeg.avi -c:v copy frames_%d.jpg
139 @end example
140
141 Unfortunately, these chunks are incomplete JPEG images, because
142 they lack the DHT segment required for decoding. Quoting from
143 @url{http://www.digitalpreservation.gov/formats/fdd/fdd000063.shtml}:
144
145 Avery Lee, writing in the rec.video.desktop newsgroup in 2001,
146 commented that "MJPEG, or at least the MJPEG in AVIs having the
147 MJPG fourcc, is restricted JPEG with a fixed -- and *omitted* --
148 Huffman table. The JPEG must be YCbCr colorspace, it must be 4:2:2,
149 and it must use basic Huffman encoding, not arithmetic or
150 progressive. . . . You can indeed extract the MJPEG frames and
151 decode them with a regular JPEG decoder, but you have to prepend
152 the DHT segment to them, or else the decoder won't have any idea
153 how to decompress the data. The exact table necessary is given in
154 the OpenDML spec."
155
156 This bitstream filter patches the header of frames extracted from an MJPEG
157 stream (carrying the AVI1 header ID and lacking a DHT segment) to
158 produce fully qualified JPEG images.
159
160 @example
161 ffmpeg -i mjpeg-movie.avi -c:v copy -bsf:v mjpeg2jpeg frame_%d.jpg
162 exiftran -i -9 frame*.jpg
163 ffmpeg -i frame_%d.jpg -c:v copy rotated.avi
164 @end example
165
166 @section mjpegadump
167
168 Add an MJPEG A header to the bitstream, to enable decoding by
169 Quicktime.
170
171 @anchor{mov2textsub}
172 @section mov2textsub
173
174 Extract a representable text file from MOV subtitles, stripping the
175 metadata header from each subtitle packet.
176
177 See also the @ref{text2movsub} filter.
178
179 @section mp3decomp
180
181 Decompress non-standard compressed MP3 audio headers.
182
183 @section mpeg4_unpack_bframes
184
185 Unpack DivX-style packed B-frames.
186
187 DivX-style packed B-frames are not valid MPEG-4 and were only a
188 workaround for the broken Video for Windows subsystem.
189 They use more space, can cause minor AV sync issues, require more
190 CPU power to decode (unless the player has some decoded picture queue
191 to compensate the 2,0,2,0 frame per packet style) and cause
192 trouble if copied into a standard container like mp4 or mpeg-ps/ts,
193 because MPEG-4 decoders may not be able to decode them, since they are
194 not valid MPEG-4.
195
196 For example to fix an AVI file containing an MPEG-4 stream with
197 DivX-style packed B-frames using @command{ffmpeg}, you can use the command:
198
199 @example
200 ffmpeg -i INPUT.avi -codec copy -bsf:v mpeg4_unpack_bframes OUTPUT.avi
201 @end example
202
203 @section noise
204
205 Damages the contents of packets without damaging the container. Can be
206 used for fuzzing or testing error resilience/concealment.
207
208 Parameters:
209 A numeral string, whose value is related to how often output bytes will
210 be modified. Therefore, values below or equal to 0 are forbidden, and
211 the lower the more frequent bytes will be modified, with 1 meaning
212 every byte is modified.
213
214 @example
215 ffmpeg -i INPUT -c copy -bsf noise[=1] output.mkv
216 @end example
217 applies the modification to every byte.
218
219 @section remove_extra
220
221 Remove extradata from packets.
222
223 It accepts the following parameter:
224 @table @option
225 @item freq
226 Set which frame types to remove extradata from.
227
228 @table @samp
229 @item k
230 Remove extradata from non-keyframes only.
231
232 @item keyframe
233 Remove extradata from keyframes only.
234
235 @item e, all
236 Remove extradata from all frames.
237
238 @end table
239 @end table
240
241 @anchor{text2movsub}
242 @section text2movsub
243
244 Convert text subtitles to MOV subtitles (as used by the @code{mov_text}
245 codec) with metadata headers.
246
247 See also the @ref{mov2textsub} filter.
248
249 @section vp9_superframe
250
251 Merge VP9 invisible (alt-ref) frames back into VP9 superframes. This
252 fixes merging of split/segmented VP9 streams where the alt-ref frame
253 was split from its visible counterpart.
254
255 @c man end BITSTREAM FILTERS