]> git.sesse.net Git - ffmpeg/blob - doc/bitstream_filters.texi
avcodec : add prores_metadata bsf for set the color property of each prores frame
[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 an MPEG-4 Audio Specific Configuration
30 bitstream.
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 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.
39
40 @section av1_metadata
41
42 Modify metadata embedded in an AV1 stream.
43
44 @table @option
45 @item td
46 Insert or remove temporal delimiter OBUs in all temporal units of the
47 stream.
48
49 @table @samp
50 @item insert
51 Insert a TD at the beginning of every TU which does not already have one.
52 @item remove
53 Remove the TD from the beginning of every TU which has one.
54 @end table
55
56 @item color_primaries
57 @item transfer_characteristics
58 @item matrix_coefficients
59 Set the color description fields in the stream (see AV1 section 6.4.2).
60
61 @item color_range
62 Set the color range in the stream (see AV1 section 6.4.2; note that
63 this cannot be set for streams using BT.709 primaries, sRGB transfer
64 characteristic and identity (RGB) matrix coefficients).
65 @table @samp
66 @item tv
67 Limited range.
68 @item pc
69 Full range.
70 @end table
71
72 @item chroma_sample_position
73 Set the chroma sample location in the stream (see AV1 section 6.4.2).
74 This can only be set for 4:2:0 streams.
75
76 @table @samp
77 @item vertical
78 Left position (matching the default in MPEG-2 and H.264).
79 @item colocated
80 Top-left position.
81 @end table
82
83 @item tick_rate
84 Set the tick rate (@emph{num_units_in_display_tick / time_scale}) in
85 the timing info in the sequence header.
86 @item num_ticks_per_picture
87 Set the number of ticks in each picture, to indicate that the stream
88 has a fixed framerate.  Ignored if @option{tick_rate} is not also set.
89
90 @end table
91
92 @section chomp
93
94 Remove zero padding at the end of a packet.
95
96 @section dca_core
97
98 Extract the core from a DCA/DTS stream, dropping extensions such as
99 DTS-HD.
100
101 @section dump_extra
102
103 Add extradata to the beginning of the filtered packets.
104
105 @table @option
106 @item freq
107 The additional argument specifies which packets should be filtered.
108 It accepts the values:
109 @table @samp
110 @item k
111 @item keyframe
112 add extradata to all key packets
113
114 @item e
115 @item all
116 add extradata to all packets
117 @end table
118 @end table
119
120 If not specified it is assumed @samp{e}.
121
122 For example the following @command{ffmpeg} command forces a global
123 header (thus disabling individual packet headers) in the H.264 packets
124 generated by the @code{libx264} encoder, but corrects them by adding
125 the header stored in extradata to the key packets:
126 @example
127 ffmpeg -i INPUT -map 0 -flags:v +global_header -c:v libx264 -bsf:v dump_extra out.ts
128 @end example
129
130 @section eac3_core
131
132 Extract the core from a E-AC-3 stream, dropping extra channels.
133
134 @section extract_extradata
135
136 Extract the in-band extradata.
137
138 Certain codecs allow the long-term headers (e.g. MPEG-2 sequence headers,
139 or H.264/HEVC (VPS/)SPS/PPS) to be transmitted either "in-band" (i.e. as a part
140 of the bitstream containing the coded frames) or "out of band" (e.g. on the
141 container level). This latter form is called "extradata" in FFmpeg terminology.
142
143 This bitstream filter detects the in-band headers and makes them available as
144 extradata.
145
146 @table @option
147 @item remove
148 When this option is enabled, the long-term headers are removed from the
149 bitstream after extraction.
150 @end table
151
152 @section filter_units
153
154 Remove units with types in or not in a given set from the stream.
155
156 @table @option
157 @item pass_types
158 List of unit types or ranges of unit types to pass through while removing
159 all others.  This is specified as a '|'-separated list of unit type values
160 or ranges of values with '-'.
161
162 @item remove_types
163 Identical to @option{pass_types}, except the units in the given set
164 removed and all others passed through.
165 @end table
166
167 Extradata is unchanged by this transformation, but note that if the stream
168 contains inline parameter sets then the output may be unusable if they are
169 removed.
170
171 For example, to remove all non-VCL NAL units from an H.264 stream:
172 @example
173 ffmpeg -i INPUT -c:v copy -bsf:v 'filter_units=pass_types=1-5' OUTPUT
174 @end example
175
176 To remove all AUDs, SEI and filler from an H.265 stream:
177 @example
178 ffmpeg -i INPUT -c:v copy -bsf:v 'filter_units=remove_types=35|38-40' OUTPUT
179 @end example
180
181 @section hapqa_extract
182
183 Extract Rgb or Alpha part of an HAPQA file, without recompression, in order to create an HAPQ or an HAPAlphaOnly file.
184
185 @table @option
186 @item texture
187 Specifies the texture to keep.
188
189 @table @option
190 @item color
191 @item alpha
192 @end table
193
194 @end table
195
196 Convert HAPQA to HAPQ
197 @example
198 ffmpeg -i hapqa_inputfile.mov -c copy -bsf:v hapqa_extract=texture=color -tag:v HapY -metadata:s:v:0 encoder="HAPQ" hapq_file.mov
199 @end example
200
201 Convert HAPQA to HAPAlphaOnly
202 @example
203 ffmpeg -i hapqa_inputfile.mov -c copy -bsf:v hapqa_extract=texture=alpha -tag:v HapA -metadata:s:v:0 encoder="HAPAlpha Only" hapalphaonly_file.mov
204 @end example
205
206 @section h264_metadata
207
208 Modify metadata embedded in an H.264 stream.
209
210 @table @option
211 @item aud
212 Insert or remove AUD NAL units in all access units of the stream.
213
214 @table @samp
215 @item insert
216 @item remove
217 @end table
218
219 @item sample_aspect_ratio
220 Set the sample aspect ratio of the stream in the VUI parameters.
221
222 @item video_format
223 @item video_full_range_flag
224 Set the video format in the stream (see H.264 section E.2.1 and
225 table E-2).
226
227 @item colour_primaries
228 @item transfer_characteristics
229 @item matrix_coefficients
230 Set the colour description in the stream (see H.264 section E.2.1
231 and tables E-3, E-4 and E-5).
232
233 @item chroma_sample_loc_type
234 Set the chroma sample location in the stream (see H.264 section
235 E.2.1 and figure E-1).
236
237 @item tick_rate
238 Set the tick rate (num_units_in_tick / time_scale) in the VUI
239 parameters.  This is the smallest time unit representable in the
240 stream, and in many cases represents the field rate of the stream
241 (double the frame rate).
242 @item fixed_frame_rate_flag
243 Set whether the stream has fixed framerate - typically this indicates
244 that the framerate is exactly half the tick rate, but the exact
245 meaning is dependent on interlacing and the picture structure (see
246 H.264 section E.2.1 and table E-6).
247
248 @item crop_left
249 @item crop_right
250 @item crop_top
251 @item crop_bottom
252 Set the frame cropping offsets in the SPS.  These values will replace
253 the current ones if the stream is already cropped.
254
255 These fields are set in pixels.  Note that some sizes may not be
256 representable if the chroma is subsampled or the stream is interlaced
257 (see H.264 section 7.4.2.1.1).
258
259 @item sei_user_data
260 Insert a string as SEI unregistered user data.  The argument must
261 be of the form @emph{UUID+string}, where the UUID is as hex digits
262 possibly separated by hyphens, and the string can be anything.
263
264 For example, @samp{086f3693-b7b3-4f2c-9653-21492feee5b8+hello} will
265 insert the string ``hello'' associated with the given UUID.
266
267 @item delete_filler
268 Deletes both filler NAL units and filler SEI messages.
269
270 @item level
271 Set the level in the SPS.  Refer to H.264 section A.3 and tables A-1
272 to A-5.
273
274 The argument must be the name of a level (for example, @samp{4.2}), a
275 level_idc value (for example, @samp{42}), or the special name @samp{auto}
276 indicating that the filter should attempt to guess the level from the
277 input stream properties.
278
279 @end table
280
281 @section h264_mp4toannexb
282
283 Convert an H.264 bitstream from length prefixed mode to start code
284 prefixed mode (as defined in the Annex B of the ITU-T H.264
285 specification).
286
287 This is required by some streaming formats, typically the MPEG-2
288 transport stream format (muxer @code{mpegts}).
289
290 For example to remux an MP4 file containing an H.264 stream to mpegts
291 format with @command{ffmpeg}, you can use the command:
292
293 @example
294 ffmpeg -i INPUT.mp4 -codec copy -bsf:v h264_mp4toannexb OUTPUT.ts
295 @end example
296
297 Please note that this filter is auto-inserted for MPEG-TS (muxer
298 @code{mpegts}) and raw H.264 (muxer @code{h264}) output formats.
299
300 @section h264_redundant_pps
301
302 This applies a specific fixup to some Blu-ray streams which contain
303 redundant PPSs modifying irrelevant parameters of the stream which
304 confuse other transformations which require correct extradata.
305
306 A new single global PPS is created, and all of the redundant PPSs
307 within the stream are removed.
308
309 @section hevc_metadata
310
311 Modify metadata embedded in an HEVC stream.
312
313 @table @option
314 @item aud
315 Insert or remove AUD NAL units in all access units of the stream.
316
317 @table @samp
318 @item insert
319 @item remove
320 @end table
321
322 @item sample_aspect_ratio
323 Set the sample aspect ratio in the stream in the VUI parameters.
324
325 @item video_format
326 @item video_full_range_flag
327 Set the video format in the stream (see H.265 section E.3.1 and
328 table E.2).
329
330 @item colour_primaries
331 @item transfer_characteristics
332 @item matrix_coefficients
333 Set the colour description in the stream (see H.265 section E.3.1
334 and tables E.3, E.4 and E.5).
335
336 @item chroma_sample_loc_type
337 Set the chroma sample location in the stream (see H.265 section
338 E.3.1 and figure E.1).
339
340 @item tick_rate
341 Set the tick rate in the VPS and VUI parameters (num_units_in_tick /
342 time_scale).  Combined with @option{num_ticks_poc_diff_one}, this can
343 set a constant framerate in the stream.  Note that it is likely to be
344 overridden by container parameters when the stream is in a container.
345
346 @item num_ticks_poc_diff_one
347 Set poc_proportional_to_timing_flag in VPS and VUI and use this value
348 to set num_ticks_poc_diff_one_minus1 (see H.265 sections 7.4.3.1 and
349 E.3.1).  Ignored if @option{tick_rate} is not also set.
350
351 @item crop_left
352 @item crop_right
353 @item crop_top
354 @item crop_bottom
355 Set the conformance window cropping offsets in the SPS.  These values
356 will replace the current ones if the stream is already cropped.
357
358 These fields are set in pixels.  Note that some sizes may not be
359 representable if the chroma is subsampled (H.265 section 7.4.3.2.1).
360
361 @end table
362
363 @section hevc_mp4toannexb
364
365 Convert an HEVC/H.265 bitstream from length prefixed mode to start code
366 prefixed mode (as defined in the Annex B of the ITU-T H.265
367 specification).
368
369 This is required by some streaming formats, typically the MPEG-2
370 transport stream format (muxer @code{mpegts}).
371
372 For example to remux an MP4 file containing an HEVC stream to mpegts
373 format with @command{ffmpeg}, you can use the command:
374
375 @example
376 ffmpeg -i INPUT.mp4 -codec copy -bsf:v hevc_mp4toannexb OUTPUT.ts
377 @end example
378
379 Please note that this filter is auto-inserted for MPEG-TS (muxer
380 @code{mpegts}) and raw HEVC/H.265 (muxer @code{h265} or
381 @code{hevc}) output formats.
382
383 @section imxdump
384
385 Modifies the bitstream to fit in MOV and to be usable by the Final Cut
386 Pro decoder. This filter only applies to the mpeg2video codec, and is
387 likely not needed for Final Cut Pro 7 and newer with the appropriate
388 @option{-tag:v}.
389
390 For example, to remux 30 MB/sec NTSC IMX to MOV:
391
392 @example
393 ffmpeg -i input.mxf -c copy -bsf:v imxdump -tag:v mx3n output.mov
394 @end example
395
396 @section mjpeg2jpeg
397
398 Convert MJPEG/AVI1 packets to full JPEG/JFIF packets.
399
400 MJPEG is a video codec wherein each video frame is essentially a
401 JPEG image. The individual frames can be extracted without loss,
402 e.g. by
403
404 @example
405 ffmpeg -i ../some_mjpeg.avi -c:v copy frames_%d.jpg
406 @end example
407
408 Unfortunately, these chunks are incomplete JPEG images, because
409 they lack the DHT segment required for decoding. Quoting from
410 @url{http://www.digitalpreservation.gov/formats/fdd/fdd000063.shtml}:
411
412 Avery Lee, writing in the rec.video.desktop newsgroup in 2001,
413 commented that "MJPEG, or at least the MJPEG in AVIs having the
414 MJPG fourcc, is restricted JPEG with a fixed -- and *omitted* --
415 Huffman table. The JPEG must be YCbCr colorspace, it must be 4:2:2,
416 and it must use basic Huffman encoding, not arithmetic or
417 progressive. . . . You can indeed extract the MJPEG frames and
418 decode them with a regular JPEG decoder, but you have to prepend
419 the DHT segment to them, or else the decoder won't have any idea
420 how to decompress the data. The exact table necessary is given in
421 the OpenDML spec."
422
423 This bitstream filter patches the header of frames extracted from an MJPEG
424 stream (carrying the AVI1 header ID and lacking a DHT segment) to
425 produce fully qualified JPEG images.
426
427 @example
428 ffmpeg -i mjpeg-movie.avi -c:v copy -bsf:v mjpeg2jpeg frame_%d.jpg
429 exiftran -i -9 frame*.jpg
430 ffmpeg -i frame_%d.jpg -c:v copy rotated.avi
431 @end example
432
433 @section mjpegadump
434
435 Add an MJPEG A header to the bitstream, to enable decoding by
436 Quicktime.
437
438 @anchor{mov2textsub}
439 @section mov2textsub
440
441 Extract a representable text file from MOV subtitles, stripping the
442 metadata header from each subtitle packet.
443
444 See also the @ref{text2movsub} filter.
445
446 @section mp3decomp
447
448 Decompress non-standard compressed MP3 audio headers.
449
450 @section mpeg2_metadata
451
452 Modify metadata embedded in an MPEG-2 stream.
453
454 @table @option
455 @item display_aspect_ratio
456 Set the display aspect ratio in the stream.
457
458 The following fixed values are supported:
459 @table @option
460 @item 4/3
461 @item 16/9
462 @item 221/100
463 @end table
464 Any other value will result in square pixels being signalled instead
465 (see H.262 section 6.3.3 and table 6-3).
466
467 @item frame_rate
468 Set the frame rate in the stream.  This is constructed from a table
469 of known values combined with a small multiplier and divisor - if
470 the supplied value is not exactly representable, the nearest
471 representable value will be used instead (see H.262 section 6.3.3
472 and table 6-4).
473
474 @item video_format
475 Set the video format in the stream (see H.262 section 6.3.6 and
476 table 6-6).
477
478 @item colour_primaries
479 @item transfer_characteristics
480 @item matrix_coefficients
481 Set the colour description in the stream (see H.262 section 6.3.6
482 and tables 6-7, 6-8 and 6-9).
483
484 @end table
485
486 @section mpeg4_unpack_bframes
487
488 Unpack DivX-style packed B-frames.
489
490 DivX-style packed B-frames are not valid MPEG-4 and were only a
491 workaround for the broken Video for Windows subsystem.
492 They use more space, can cause minor AV sync issues, require more
493 CPU power to decode (unless the player has some decoded picture queue
494 to compensate the 2,0,2,0 frame per packet style) and cause
495 trouble if copied into a standard container like mp4 or mpeg-ps/ts,
496 because MPEG-4 decoders may not be able to decode them, since they are
497 not valid MPEG-4.
498
499 For example to fix an AVI file containing an MPEG-4 stream with
500 DivX-style packed B-frames using @command{ffmpeg}, you can use the command:
501
502 @example
503 ffmpeg -i INPUT.avi -codec copy -bsf:v mpeg4_unpack_bframes OUTPUT.avi
504 @end example
505
506 @section noise
507
508 Damages the contents of packets or simply drops them without damaging the
509 container. Can be used for fuzzing or testing error resilience/concealment.
510
511 Parameters:
512 @table @option
513 @item amount
514 A numeral string, whose value is related to how often output bytes will
515 be modified. Therefore, values below or equal to 0 are forbidden, and
516 the lower the more frequent bytes will be modified, with 1 meaning
517 every byte is modified.
518 @item dropamount
519 A numeral string, whose value is related to how often packets will be dropped.
520 Therefore, values below or equal to 0 are forbidden, and the lower the more
521 frequent packets will be dropped, with 1 meaning every packet is dropped.
522 @end table
523
524 The following example applies the modification to every byte but does not drop
525 any packets.
526 @example
527 ffmpeg -i INPUT -c copy -bsf noise[=1] output.mkv
528 @end example
529
530 @section null
531 This bitstream filter passes the packets through unchanged.
532
533 @section prores_metadata
534
535 Modify color property metadata embedded in prores stream.
536
537 @table @option
538 @item color_primaries
539 Set the color primaries.
540 Available values are:
541
542 @table @samp
543 @item auto
544 Keep the same color primaries property (default).
545
546 @item unknown
547 @item bt709
548 @item bt470bg
549 BT601 625
550
551 @item smpte170m
552 BT601 525
553
554 @item bt2020
555 @item smpte431
556 DCI P3
557
558 @item smpte432
559 P3 D65
560
561 @end table
562
563 @item transfer_characteristics
564 Set the color transfert.
565 Available values are:
566
567 @table @samp
568 @item auto
569 Keep the same transfer characteristics property (default).
570
571 @item unknown
572 @item bt709
573 BT 601, BT 709, BT 2020
574 @end table
575
576
577 @item matrix_coefficients
578 Set the matrix coefficient.
579 Available values are:
580
581 @table @samp
582 @item auto
583 Keep the same transfer characteristics property (default).
584
585 @item unknown
586 @item bt709
587 @item smpte170m
588 BT 601
589
590 @item bt2020nc
591 @end table
592 @end table
593
594 Set Rec709 colorspace for each frame of the file
595 @example
596 ffmpeg -i INPUT -c copy -bsf:v prores_metadata=color_primaries=bt709:color_trc=bt709:colorspace=bt709 output.mov
597 @end example
598
599 @section remove_extra
600
601 Remove extradata from packets.
602
603 It accepts the following parameter:
604 @table @option
605 @item freq
606 Set which frame types to remove extradata from.
607
608 @table @samp
609 @item k
610 Remove extradata from non-keyframes only.
611
612 @item keyframe
613 Remove extradata from keyframes only.
614
615 @item e, all
616 Remove extradata from all frames.
617
618 @end table
619 @end table
620
621 @anchor{text2movsub}
622 @section text2movsub
623
624 Convert text subtitles to MOV subtitles (as used by the @code{mov_text}
625 codec) with metadata headers.
626
627 See also the @ref{mov2textsub} filter.
628
629 @section trace_headers
630
631 Log trace output containing all syntax elements in the coded stream
632 headers (everything above the level of individual coded blocks).
633 This can be useful for debugging low-level stream issues.
634
635 Supports H.264, H.265, MPEG-2 and VP9.
636
637 @section vp9_metadata
638
639 Modify metadata embedded in a VP9 stream.
640
641 @table @option
642 @item color_space
643 Set the color space value in the frame header.
644 @table @samp
645 @item unknown
646 @item bt601
647 @item bt709
648 @item smpte170
649 @item smpte240
650 @item bt2020
651 @item rgb
652 @end table
653
654 @item color_range
655 Set the color range value in the frame header.  Note that this cannot
656 be set in RGB streams.
657 @table @samp
658 @item tv
659 @item pc
660 @end table
661 @end table
662
663 @section vp9_superframe
664
665 Merge VP9 invisible (alt-ref) frames back into VP9 superframes. This
666 fixes merging of split/segmented VP9 streams where the alt-ref frame
667 was split from its visible counterpart.
668
669 @section vp9_superframe_split
670
671 Split VP9 superframes into single frames.
672
673 @section vp9_raw_reorder
674
675 Given a VP9 stream with correct timestamps but possibly out of order,
676 insert additional show-existing-frame packets to correct the ordering.
677
678 @c man end BITSTREAM FILTERS