Imported Debian version 2.5.0~trusty1.1
[deb_ffmpeg.git] / ffmpeg / doc / bitstream_filters.texi
CommitLineData
2ba45a60
DM
1@chapter Bitstream Filters
2@c man begin BITSTREAM FILTERS
3
4When you configure your FFmpeg build, all the supported bitstream
5filters are enabled by default. You can list all available ones using
6the configure option @code{--list-bsfs}.
7
8You can disable all the bitstream filters using the configure option
9@code{--disable-bsfs}, and selectively enable any bitstream filter using
10the option @code{--enable-bsf=BSF}, or you can disable a particular
11bitstream filter using the option @code{--disable-bsf=BSF}.
12
13The option @code{-bsfs} of the ff* tools will display the list of
14all the supported bitstream filters included in your build.
15
f6fa7814
DM
16The ff* tools have a -bsf option applied per stream, taking a
17comma-separated list of filters, whose parameters follow the filter
18name after a '='.
19
20@example
21ffmpeg -i INPUT -c:v copy -bsf:v filter1[=opt1=str1/opt2=str2][,filter2] OUTPUT
22@end example
23
24Below is a description of the currently available bitstream filters,
25with their parameters, if any.
2ba45a60
DM
26
27@section aac_adtstoasc
28
29Convert MPEG-2/4 AAC ADTS to MPEG-4 Audio Specific Configuration
30bitstream filter.
31
32This filter creates an MPEG-4 AudioSpecificConfig from an MPEG-2/4
33ADTS header and removes the ADTS header.
34
35This is required for example when copying an AAC stream from a raw
36ADTS AAC container to a FLV or a MOV/MP4 file.
37
38@section chomp
39
40Remove zero padding at the end of a packet.
41
42@section dump_extra
43
44Add extradata to the beginning of the filtered packets.
45
46The additional argument specifies which packets should be filtered.
47It accepts the values:
48@table @samp
49@item a
50add extradata to all key packets, but only if @var{local_header} is
51set in the @option{flags2} codec context field
52
53@item k
54add extradata to all key packets
55
56@item e
57add extradata to all packets
58@end table
59
60If not specified it is assumed @samp{k}.
61
62For example the following @command{ffmpeg} command forces a global
63header (thus disabling individual packet headers) in the H.264 packets
64generated by the @code{libx264} encoder, but corrects them by adding
65the header stored in extradata to the key packets:
66@example
67ffmpeg -i INPUT -map 0 -flags:v +global_header -c:v libx264 -bsf:v dump_extra out.ts
68@end example
69
70@section h264_mp4toannexb
71
72Convert an H.264 bitstream from length prefixed mode to start code
73prefixed mode (as defined in the Annex B of the ITU-T H.264
74specification).
75
76This is required by some streaming formats, typically the MPEG-2
77transport stream format ("mpegts").
78
79For example to remux an MP4 file containing an H.264 stream to mpegts
80format with @command{ffmpeg}, you can use the command:
81
82@example
83ffmpeg -i INPUT.mp4 -codec copy -bsf:v h264_mp4toannexb OUTPUT.ts
84@end example
85
86@section imxdump
87
88Modifies the bitstream to fit in MOV and to be usable by the Final Cut
89Pro decoder. This filter only applies to the mpeg2video codec, and is
90likely not needed for Final Cut Pro 7 and newer with the appropriate
91@option{-tag:v}.
92
93For example, to remux 30 MB/sec NTSC IMX to MOV:
94
95@example
96ffmpeg -i input.mxf -c copy -bsf:v imxdump -tag:v mx3n output.mov
97@end example
98
99@section mjpeg2jpeg
100
101Convert MJPEG/AVI1 packets to full JPEG/JFIF packets.
102
103MJPEG is a video codec wherein each video frame is essentially a
104JPEG image. The individual frames can be extracted without loss,
105e.g. by
106
107@example
108ffmpeg -i ../some_mjpeg.avi -c:v copy frames_%d.jpg
109@end example
110
111Unfortunately, these chunks are incomplete JPEG images, because
112they lack the DHT segment required for decoding. Quoting from
113@url{http://www.digitalpreservation.gov/formats/fdd/fdd000063.shtml}:
114
115Avery Lee, writing in the rec.video.desktop newsgroup in 2001,
116commented that "MJPEG, or at least the MJPEG in AVIs having the
117MJPG fourcc, is restricted JPEG with a fixed -- and *omitted* --
118Huffman table. The JPEG must be YCbCr colorspace, it must be 4:2:2,
119and it must use basic Huffman encoding, not arithmetic or
120progressive. . . . You can indeed extract the MJPEG frames and
121decode them with a regular JPEG decoder, but you have to prepend
122the DHT segment to them, or else the decoder won't have any idea
123how to decompress the data. The exact table necessary is given in
124the OpenDML spec."
125
126This bitstream filter patches the header of frames extracted from an MJPEG
127stream (carrying the AVI1 header ID and lacking a DHT segment) to
128produce fully qualified JPEG images.
129
130@example
131ffmpeg -i mjpeg-movie.avi -c:v copy -bsf:v mjpeg2jpeg frame_%d.jpg
132exiftran -i -9 frame*.jpg
133ffmpeg -i frame_%d.jpg -c:v copy rotated.avi
134@end example
135
136@section mjpega_dump_header
137
138@section movsub
139
140@section mp3_header_decompress
141
142@section noise
143
144Damages the contents of packets without damaging the container. Can be
145used for fuzzing or testing error resilience/concealment.
146
f6fa7814
DM
147Parameters:
148A numeral string, whose value is related to how often output bytes will
149be modified. Therefore, values below or equal to 0 are forbidden, and
150the lower the more frequent bytes will be modified, with 1 meaning
151every byte is modified.
152
2ba45a60 153@example
f6fa7814 154ffmpeg -i INPUT -c copy -bsf noise[=1] output.mkv
2ba45a60 155@end example
f6fa7814 156applies the modification to every byte.
2ba45a60
DM
157
158@section remove_extra
159
160@c man end BITSTREAM FILTERS