1 @chapter Bitstream Filters
2 @c man begin BITSTREAM FILTERS
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}.
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}.
13 The option @code{-bsfs} of the ff* tools will display the list of
14 all the supported bitstream filters included in your build.
16 The ff* tools have a -bsf option applied per stream, taking a
17 comma-separated list of filters, whose parameters follow the filter
21 ffmpeg -i INPUT -c:v copy -bsf:v filter1[=opt1=str1:opt2=str2][,filter2] OUTPUT
24 Below is a description of the currently available bitstream filters,
25 with their parameters, if any.
27 @section aac_adtstoasc
29 Convert MPEG-2/4 AAC ADTS to an MPEG-4 Audio Specific Configuration
32 This filter creates an MPEG-4 AudioSpecificConfig from an MPEG-2/4
33 ADTS header and removes the ADTS header.
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.
42 Remove zero padding at the end of a packet.
46 Extract the core from a DCA/DTS stream, dropping extensions such as
51 Add extradata to the beginning of the filtered packets.
53 The additional argument specifies which packets should be filtered.
54 It accepts the values:
57 add extradata to all key packets, but only if @var{local_header} is
58 set in the @option{flags2} codec context field
61 add extradata to all key packets
64 add extradata to all packets
67 If not specified it is assumed @samp{k}.
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:
74 ffmpeg -i INPUT -map 0 -flags:v +global_header -c:v libx264 -bsf:v dump_extra out.ts
77 @section extract_extradata
79 Extract the in-band extradata.
81 Certain codecs allow the long-term headers (e.g. MPEG-2 sequence headers,
82 or H.264/HEVC (VPS/)SPS/PPS) to be transmitted either "in-band" (i.e. as a part
83 of the bitstream containing the coded frames) or "out of band" (e.g. on the
84 container level). This latter form is called "extradata" in FFmpeg terminology.
86 This bitstream filter detects the in-band headers and makes them available as
91 When this option is enabled, the long-term headers are removed from the
92 bitstream after extraction.
95 @section h264_metadata
97 Modify metadata embedded in an H.264 stream.
101 Insert or remove AUD NAL units in all access units of the stream.
108 @item sample_aspect_ratio
109 Set the sample aspect ratio of the stream in the VUI parameters.
112 @item video_full_range_flag
113 Set the video format in the stream (see H.264 section E.2.1 and
116 @item colour_primaries
117 @item transfer_characteristics
118 @item matrix_coefficients
119 Set the colour description in the stream (see H.264 section E.2.1
120 and tables E-3, E-4 and E-5).
122 @item chroma_sample_loc_type
123 Set the chroma sample location in the stream (see H.264 section
124 E.2.1 and figure E-1).
127 Set the tick rate (num_units_in_tick / time_scale) in the VUI
128 parameters. This is the smallest time unit representable in the
129 stream, and in many cases represents the field rate of the stream
130 (double the frame rate).
131 @item fixed_frame_rate_flag
132 Set whether the stream has fixed framerate - typically this indicates
133 that the framerate is exactly half the tick rate, but the exact
134 meaning is dependent on interlacing and the picture structure (see
135 H.264 section E.2.1 and table E-6).
141 Set the frame cropping offsets in the SPS. These values will replace
142 the current ones if the stream is already cropped.
144 These fields are set in pixels. Note that some sizes may not be
145 representable if the chroma is subsampled or the stream is interlaced
146 (see H.264 section 7.4.2.1.1).
149 Insert a string as SEI unregistered user data. The argument must
150 be of the form @emph{UUID+string}, where the UUID is as hex digits
151 possibly separated by hyphens, and the string can be anything.
153 For example, @samp{086f3693-b7b3-4f2c-9653-21492feee5b8+hello} will
154 insert the string ``hello'' associated with the given UUID.
158 @section h264_mp4toannexb
160 Convert an H.264 bitstream from length prefixed mode to start code
161 prefixed mode (as defined in the Annex B of the ITU-T H.264
164 This is required by some streaming formats, typically the MPEG-2
165 transport stream format (muxer @code{mpegts}).
167 For example to remux an MP4 file containing an H.264 stream to mpegts
168 format with @command{ffmpeg}, you can use the command:
171 ffmpeg -i INPUT.mp4 -codec copy -bsf:v h264_mp4toannexb OUTPUT.ts
174 Please note that this filter is auto-inserted for MPEG-TS (muxer
175 @code{mpegts}) and raw H.264 (muxer @code{h264}) output formats.
177 @section h264_redundant_pps
179 This applies a specific fixup to some Blu-ray streams which contain
180 redundant PPSs modifying irrelevant parameters of the stream which
181 confuse other transformations which require correct extradata.
183 A new single global PPS is created, and all of the redundant PPSs
184 within the stream are removed.
186 @section hevc_metadata
188 Modify metadata embedded in an HEVC stream.
192 Insert or remove AUD NAL units in all access units of the stream.
199 @item sample_aspect_ratio
200 Set the sample aspect ratio in the stream in the VUI parameters.
203 @item video_full_range_flag
204 Set the video format in the stream (see H.265 section E.3.1 and
207 @item colour_primaries
208 @item transfer_characteristics
209 @item matrix_coefficients
210 Set the colour description in the stream (see H.265 section E.3.1
211 and tables E.3, E.4 and E.5).
213 @item chroma_sample_loc_type
214 Set the chroma sample location in the stream (see H.265 section
215 E.3.1 and figure E.1).
218 Set the tick rate in the VPS and VUI parameters (num_units_in_tick /
219 time_scale). Combined with @option{num_ticks_poc_diff_one}, this can
220 set a constant framerate in the stream. Note that it is likely to be
221 overridden by container parameters when the stream is in a container.
223 @item num_ticks_poc_diff_one
224 Set poc_proportional_to_timing_flag in VPS and VUI and use this value
225 to set num_ticks_poc_diff_one_minus1 (see H.265 sections 7.4.3.1 and
226 E.3.1). Ignored if @option{tick_rate} is not also set.
232 Set the conformance window cropping offsets in the SPS. These values
233 will replace the current ones if the stream is already cropped.
235 These fields are set in pixels. Note that some sizes may not be
236 representable if the chroma is subsampled (H.265 section 7.4.3.2.1).
240 @section hevc_mp4toannexb
242 Convert an HEVC/H.265 bitstream from length prefixed mode to start code
243 prefixed mode (as defined in the Annex B of the ITU-T H.265
246 This is required by some streaming formats, typically the MPEG-2
247 transport stream format (muxer @code{mpegts}).
249 For example to remux an MP4 file containing an HEVC stream to mpegts
250 format with @command{ffmpeg}, you can use the command:
253 ffmpeg -i INPUT.mp4 -codec copy -bsf:v hevc_mp4toannexb OUTPUT.ts
256 Please note that this filter is auto-inserted for MPEG-TS (muxer
257 @code{mpegts}) and raw HEVC/H.265 (muxer @code{h265} or
258 @code{hevc}) output formats.
262 Modifies the bitstream to fit in MOV and to be usable by the Final Cut
263 Pro decoder. This filter only applies to the mpeg2video codec, and is
264 likely not needed for Final Cut Pro 7 and newer with the appropriate
267 For example, to remux 30 MB/sec NTSC IMX to MOV:
270 ffmpeg -i input.mxf -c copy -bsf:v imxdump -tag:v mx3n output.mov
275 Convert MJPEG/AVI1 packets to full JPEG/JFIF packets.
277 MJPEG is a video codec wherein each video frame is essentially a
278 JPEG image. The individual frames can be extracted without loss,
282 ffmpeg -i ../some_mjpeg.avi -c:v copy frames_%d.jpg
285 Unfortunately, these chunks are incomplete JPEG images, because
286 they lack the DHT segment required for decoding. Quoting from
287 @url{http://www.digitalpreservation.gov/formats/fdd/fdd000063.shtml}:
289 Avery Lee, writing in the rec.video.desktop newsgroup in 2001,
290 commented that "MJPEG, or at least the MJPEG in AVIs having the
291 MJPG fourcc, is restricted JPEG with a fixed -- and *omitted* --
292 Huffman table. The JPEG must be YCbCr colorspace, it must be 4:2:2,
293 and it must use basic Huffman encoding, not arithmetic or
294 progressive. . . . You can indeed extract the MJPEG frames and
295 decode them with a regular JPEG decoder, but you have to prepend
296 the DHT segment to them, or else the decoder won't have any idea
297 how to decompress the data. The exact table necessary is given in
300 This bitstream filter patches the header of frames extracted from an MJPEG
301 stream (carrying the AVI1 header ID and lacking a DHT segment) to
302 produce fully qualified JPEG images.
305 ffmpeg -i mjpeg-movie.avi -c:v copy -bsf:v mjpeg2jpeg frame_%d.jpg
306 exiftran -i -9 frame*.jpg
307 ffmpeg -i frame_%d.jpg -c:v copy rotated.avi
312 Add an MJPEG A header to the bitstream, to enable decoding by
318 Extract a representable text file from MOV subtitles, stripping the
319 metadata header from each subtitle packet.
321 See also the @ref{text2movsub} filter.
325 Decompress non-standard compressed MP3 audio headers.
327 @section mpeg2_metadata
329 Modify metadata embedded in an MPEG-2 stream.
332 @item display_aspect_ratio
333 Set the display aspect ratio in the stream.
335 The following fixed values are supported:
341 Any other value will result in square pixels being signalled instead
342 (see H.262 section 6.3.3 and table 6-3).
345 Set the frame rate in the stream. This is constructed from a table
346 of known values combined with a small multiplier and divisor - if
347 the supplied value is not exactly representable, the nearest
348 representable value will be used instead (see H.262 section 6.3.3
352 Set the video format in the stream (see H.262 section 6.3.6 and
355 @item colour_primaries
356 @item transfer_characteristics
357 @item matrix_coefficients
358 Set the colour description in the stream (see H.262 section 6.3.6
359 and tables 6-7, 6-8 and 6-9).
363 @section mpeg4_unpack_bframes
365 Unpack DivX-style packed B-frames.
367 DivX-style packed B-frames are not valid MPEG-4 and were only a
368 workaround for the broken Video for Windows subsystem.
369 They use more space, can cause minor AV sync issues, require more
370 CPU power to decode (unless the player has some decoded picture queue
371 to compensate the 2,0,2,0 frame per packet style) and cause
372 trouble if copied into a standard container like mp4 or mpeg-ps/ts,
373 because MPEG-4 decoders may not be able to decode them, since they are
376 For example to fix an AVI file containing an MPEG-4 stream with
377 DivX-style packed B-frames using @command{ffmpeg}, you can use the command:
380 ffmpeg -i INPUT.avi -codec copy -bsf:v mpeg4_unpack_bframes OUTPUT.avi
385 Damages the contents of packets or simply drops them without damaging the
386 container. Can be used for fuzzing or testing error resilience/concealment.
391 A numeral string, whose value is related to how often output bytes will
392 be modified. Therefore, values below or equal to 0 are forbidden, and
393 the lower the more frequent bytes will be modified, with 1 meaning
394 every byte is modified.
396 A numeral string, whose value is related to how often packets will be dropped.
397 Therefore, values below or equal to 0 are forbidden, and the lower the more
398 frequent packets will be dropped, with 1 meaning every packet is dropped.
401 The following example applies the modification to every byte but does not drop
404 ffmpeg -i INPUT -c copy -bsf noise[=1] output.mkv
408 This bitstream filter passes the packets through unchanged.
410 @section remove_extra
412 Remove extradata from packets.
414 It accepts the following parameter:
417 Set which frame types to remove extradata from.
421 Remove extradata from non-keyframes only.
424 Remove extradata from keyframes only.
427 Remove extradata from all frames.
435 Convert text subtitles to MOV subtitles (as used by the @code{mov_text}
436 codec) with metadata headers.
438 See also the @ref{mov2textsub} filter.
440 @section trace_headers
442 Log trace output containing all syntax elements in the coded stream
443 headers (everything above the level of individual coded blocks).
444 This can be useful for debugging low-level stream issues.
446 Supports H.264, H.265 and MPEG-2.
448 @section vp9_superframe
450 Merge VP9 invisible (alt-ref) frames back into VP9 superframes. This
451 fixes merging of split/segmented VP9 streams where the alt-ref frame
452 was split from its visible counterpart.
454 @section vp9_superframe_split
456 Split VP9 superframes into single frames.
458 @section vp9_raw_reorder
460 Given a VP9 stream with correct timestamps but possibly out of order,
461 insert additional show-existing-frame packets to correct the ordering.
463 @c man end BITSTREAM FILTERS