]> git.sesse.net Git - ffmpeg/blob - doc/bitstream_filters.texi
Merge commit '5c2fb561d94fc51d76ab21d6f7cc5b6cc3aa599c'
[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 MPEG-4 Audio Specific Configuration
30 bitstream filter.
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 is required for example when copying an AAC stream from a raw
36 ADTS AAC container to a FLV or a MOV/MP4 file.
37
38 @section chomp
39
40 Remove zero padding at the end of a packet.
41
42 @section dump_extra
43
44 Add extradata to the beginning of the filtered packets.
45
46 The additional argument specifies which packets should be filtered.
47 It accepts the values:
48 @table @samp
49 @item a
50 add extradata to all key packets, but only if @var{local_header} is
51 set in the @option{flags2} codec context field
52
53 @item k
54 add extradata to all key packets
55
56 @item e
57 add extradata to all packets
58 @end table
59
60 If not specified it is assumed @samp{k}.
61
62 For example the following @command{ffmpeg} command forces a global
63 header (thus disabling individual packet headers) in the H.264 packets
64 generated by the @code{libx264} encoder, but corrects them by adding
65 the header stored in extradata to the key packets:
66 @example
67 ffmpeg -i INPUT -map 0 -flags:v +global_header -c:v libx264 -bsf:v dump_extra out.ts
68 @end example
69
70 @section dca_core
71
72 Extract DCA core from DTS-HD streams.
73
74 @section h264_mp4toannexb
75
76 Convert an H.264 bitstream from length prefixed mode to start code
77 prefixed mode (as defined in the Annex B of the ITU-T H.264
78 specification).
79
80 This is required by some streaming formats, typically the MPEG-2
81 transport stream format ("mpegts").
82
83 For example to remux an MP4 file containing an H.264 stream to mpegts
84 format with @command{ffmpeg}, you can use the command:
85
86 @example
87 ffmpeg -i INPUT.mp4 -codec copy -bsf:v h264_mp4toannexb OUTPUT.ts
88 @end example
89
90 @section imxdump
91
92 Modifies the bitstream to fit in MOV and to be usable by the Final Cut
93 Pro decoder. This filter only applies to the mpeg2video codec, and is
94 likely not needed for Final Cut Pro 7 and newer with the appropriate
95 @option{-tag:v}.
96
97 For example, to remux 30 MB/sec NTSC IMX to MOV:
98
99 @example
100 ffmpeg -i input.mxf -c copy -bsf:v imxdump -tag:v mx3n output.mov
101 @end example
102
103 @section mjpeg2jpeg
104
105 Convert MJPEG/AVI1 packets to full JPEG/JFIF packets.
106
107 MJPEG is a video codec wherein each video frame is essentially a
108 JPEG image. The individual frames can be extracted without loss,
109 e.g. by
110
111 @example
112 ffmpeg -i ../some_mjpeg.avi -c:v copy frames_%d.jpg
113 @end example
114
115 Unfortunately, these chunks are incomplete JPEG images, because
116 they lack the DHT segment required for decoding. Quoting from
117 @url{http://www.digitalpreservation.gov/formats/fdd/fdd000063.shtml}:
118
119 Avery Lee, writing in the rec.video.desktop newsgroup in 2001,
120 commented that "MJPEG, or at least the MJPEG in AVIs having the
121 MJPG fourcc, is restricted JPEG with a fixed -- and *omitted* --
122 Huffman table. The JPEG must be YCbCr colorspace, it must be 4:2:2,
123 and it must use basic Huffman encoding, not arithmetic or
124 progressive. . . . You can indeed extract the MJPEG frames and
125 decode them with a regular JPEG decoder, but you have to prepend
126 the DHT segment to them, or else the decoder won't have any idea
127 how to decompress the data. The exact table necessary is given in
128 the OpenDML spec."
129
130 This bitstream filter patches the header of frames extracted from an MJPEG
131 stream (carrying the AVI1 header ID and lacking a DHT segment) to
132 produce fully qualified JPEG images.
133
134 @example
135 ffmpeg -i mjpeg-movie.avi -c:v copy -bsf:v mjpeg2jpeg frame_%d.jpg
136 exiftran -i -9 frame*.jpg
137 ffmpeg -i frame_%d.jpg -c:v copy rotated.avi
138 @end example
139
140 @section mjpega_dump_header
141
142 @section movsub
143
144 @section mp3_header_decompress
145
146 @section mpeg4_unpack_bframes
147
148 Unpack DivX-style packed B-frames.
149
150 DivX-style packed B-frames are not valid MPEG-4 and were only a
151 workaround for the broken Video for Windows subsystem.
152 They use more space, can cause minor AV sync issues, require more
153 CPU power to decode (unless the player has some decoded picture queue
154 to compensate the 2,0,2,0 frame per packet style) and cause
155 trouble if copied into a standard container like mp4 or mpeg-ps/ts,
156 because MPEG-4 decoders may not be able to decode them, since they are
157 not valid MPEG-4.
158
159 For example to fix an AVI file containing an MPEG-4 stream with
160 DivX-style packed B-frames using @command{ffmpeg}, you can use the command:
161
162 @example
163 ffmpeg -i INPUT.avi -codec copy -bsf:v mpeg4_unpack_bframes OUTPUT.avi
164 @end example
165
166 @section noise
167
168 Damages the contents of packets without damaging the container. Can be
169 used for fuzzing or testing error resilience/concealment.
170
171 Parameters:
172 A numeral string, whose value is related to how often output bytes will
173 be modified. Therefore, values below or equal to 0 are forbidden, and
174 the lower the more frequent bytes will be modified, with 1 meaning
175 every byte is modified.
176
177 @example
178 ffmpeg -i INPUT -c copy -bsf noise[=1] output.mkv
179 @end example
180 applies the modification to every byte.
181
182 @section remove_extra
183
184 @c man end BITSTREAM FILTERS