lavc: Add hevc_metadata bitstream filter
[libav.git] / doc / bitstream_filters.texi
CommitLineData
361d2758
SS
1@chapter Bitstream Filters
2@c man begin BITSTREAM FILTERS
3
f8a45fa1 4When you configure your Libav build, all the supported bitstream
361d2758
SS
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
202b5f6d 13The option @code{-bsfs} of the av* tools will display the list of
361d2758
SS
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
20@section chomp
21
22@section dump_extradata
23
89b35a13
AK
24@section extract_extradata
25
26Extract the in-band extradata.
27
28Certain codecs allow the long-term headers (e.g. MPEG-2 sequence headers,
29or H.264/HEVC (VPS/)SPS/PPS) to be transmitted either "in-band" (i.e. as a part
30of the bitstream containing the coded frames) or "out of band" (e.g. on the
31container level). This latter form is called "extradata" in Libav terminology.
32
33This bitstream filter detects the in-band headers and makes them available as
34extradata.
35
36@table @option
37@item remove
38When this option is enabled, the long-term headers are removed from the
39bitstream after extraction.
40@end table
41
9e93001b
MT
42@section h264_metadata
43
44Modify metadata embedded in an H.264 stream.
45
46@table @option
47@item aud
48Insert or remove AUD NAL units in all access units of the stream.
49
50@table @samp
51@item insert
52@item remove
53@end table
54
55@item sample_aspect_ratio
56Set the sample aspect ratio of the stream in the VUI parameters.
57
58@item video_format
59@item video_full_range_flag
60Set the video format in the stream (see H.264 section E.2.1 and
61table E-2).
62
63@item colour_primaries
64@item transfer_characteristics
65@item matrix_coefficients
66Set the colour description in the stream (see H.264 section E.2.1
67and tables E-3, E-4 and E-5).
68
69@item chroma_sample_loc_type
70Set the chroma sample location in the stream (see H.264 section
71E.2.1 and figure E-1).
72
73@item tick_rate
74Set the tick rate (num_units_in_tick / time_scale) in the VUI
75parameters. This is the smallest time unit representable in the
76stream, and in many cases represents the field rate of the stream
77(double the frame rate).
78@item fixed_frame_rate_flag
79Set whether the stream has fixed framerate - typically this indicates
80that the framerate is exactly half the tick rate, but the exact
81meaning is dependent on interlacing and the picture structure (see
82H.264 section E.2.1 and table E-6).
83
84@item crop_left
85@item crop_right
86@item crop_top
87@item crop_bottom
88Set the frame cropping offsets in the SPS. These values will replace
89the current ones if the stream is already cropped.
90
91These fields are set in pixels. Note that some sizes may not be
92representable if the chroma is subsampled or the stream is interlaced
93(see H.264 section 7.4.2.1.1).
94
95@item sei_user_data
96Insert a string as SEI unregistered user data. The argument must
97be of the form @emph{UUID+string}, where the UUID is as hex digits
98possibly separated by hyphens, and the string can be anything.
99
100For example, @samp{086f3693-b7b3-4f2c-9653-21492feee5b8+hello} will
101insert the string ``hello'' associated with the given UUID.
102
103@end table
104
361d2758
SS
105@section h264_mp4toannexb
106
e6874bc3
MT
107@section h264_redundant_pps
108
109This applies a specific fixup to some Bluray streams which contain
110redundant PPSs modifying irrelevant parameters of the stream which
111confuse other transformations which require correct extradata.
112
113A new single global PPS is created, and all of the redundant PPSs
114within the stream are removed.
115
b31a9eae
MT
116@section hevc_metadata
117
118Modify metadata embedded in an HEVC stream.
119
120@table @option
121@item aud
122Insert or remove AUD NAL units in all access units of the stream.
123
124@table @samp
125@item insert
126@item remove
127@end table
128
129@item sample_aspect_ratio
130Set the sample aspect ratio in the stream in the VUI parameters.
131
132@item video_format
133@item video_full_range_flag
134Set the video format in the stream (see H.265 section E.3.1 and
135table E.2).
136
137@item colour_primaries
138@item transfer_characteristics
139@item matrix_coefficients
140Set the colour description in the stream (see H.265 section E.3.1
141and tables E.3, E.4 and E.5).
142
143@item chroma_sample_loc_type
144Set the chroma sample location in the stream (see H.265 section
145E.3.1 and figure E.1).
146
147@item tick_rate
148Set the tick rate in the VPS and VUI parameters (num_units_in_tick /
149time_scale). Combined with @option{num_ticks_poc_diff_one}, this can
150set a constant framerate in the stream. Note that it is likely to be
151overridden by container parameters when the stream is in a container.
152
153@item num_ticks_poc_diff_one
154Set poc_proportional_to_timing_flag in VPS and VUI and use this value
155to set num_ticks_poc_diff_one_minus1 (see H.265 sections 7.4.3.1 and
156E.3.1). Ignored if @option{tick_rate} is not also set.
157
158@item crop_left
159@item crop_right
160@item crop_top
161@item crop_bottom
162Set the conformance window cropping offsets in the SPS. These values
163will replace the current ones if the stream is already cropped.
164
165These fields are set in pixels. Note that some sizes may not be
166representable if the chroma is subsampled (H.265 section 7.4.3.2.1).
167
168@end table
169
361d2758
SS
170@section imx_dump_header
171
ba83c4bf
NG
172@section mjpeg2jpeg
173
174Convert MJPEG/AVI1 packets to full JPEG/JFIF packets.
175
176MJPEG is a video codec wherein each video frame is essentially a
177JPEG image. The individual frames can be extracted without loss,
178e.g. by
179
180@example
d5837d7f 181avconv -i ../some_mjpeg.avi -c:v copy frames_%d.jpg
ba83c4bf
NG
182@end example
183
184Unfortunately, these chunks are incomplete JPEG images, because
185they lack the DHT segment required for decoding. Quoting from
186@url{http://www.digitalpreservation.gov/formats/fdd/fdd000063.shtml}:
187
188Avery Lee, writing in the rec.video.desktop newsgroup in 2001,
189commented that "MJPEG, or at least the MJPEG in AVIs having the
190MJPG fourcc, is restricted JPEG with a fixed -- and *omitted* --
191Huffman table. The JPEG must be YCbCr colorspace, it must be 4:2:2,
192and it must use basic Huffman encoding, not arithmetic or
193progressive. . . . You can indeed extract the MJPEG frames and
194decode them with a regular JPEG decoder, but you have to prepend
195the DHT segment to them, or else the decoder won't have any idea
196how to decompress the data. The exact table necessary is given in
197the OpenDML spec."
198
199This bitstream filter patches the header of frames extracted from an MJPEG
200stream (carrying the AVI1 header ID and lacking a DHT segment) to
201produce fully qualified JPEG images.
202
203@example
d6a77e2b 204avconv -i mjpeg-movie.avi -c:v copy -bsf:v mjpeg2jpeg frame_%d.jpg
ba83c4bf 205exiftran -i -9 frame*.jpg
d5837d7f 206avconv -i frame_%d.jpg -c:v copy rotated.avi
ba83c4bf
NG
207@end example
208
361d2758
SS
209@section mjpega_dump_header
210
211@section movsub
212
213@section mp3_header_compress
214
215@section mp3_header_decompress
216
217@section noise
218
47e547b3
AK
219@section null
220This bitstream filter passes the packets through unchanged.
221
361d2758
SS
222@section remove_extradata
223
f11d8a5e
MT
224@section trace_headers
225
226Log trace output containing all syntax elements in the coded stream
227headers (everything above the level of individual coded blocks).
228This can be useful for debugging low-level stream issues.
229
230Supports H.264 and H.265.
231
0cf949a0
RB
232@section vp9_superframe
233
234Combine VP9 frames into superframes.
235
03a80925
AK
236@section vp9_superframe_split
237
238Split VP9 superframes into single frames.
239
34e051d1
MT
240@section vp9_raw_reorder
241
242Given a VP9 stream with correct timestamps but possibly out of order,
243insert additional show-existing-frame packets to correct the ordering.
244
361d2758 245@c man end BITSTREAM FILTERS