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