yading@10
|
1 @chapter Bitstream Filters
|
yading@10
|
2 @c man begin BITSTREAM FILTERS
|
yading@10
|
3
|
yading@10
|
4 When you configure your FFmpeg build, all the supported bitstream
|
yading@10
|
5 filters are enabled by default. You can list all available ones using
|
yading@10
|
6 the configure option @code{--list-bsfs}.
|
yading@10
|
7
|
yading@10
|
8 You can disable all the bitstream filters using the configure option
|
yading@10
|
9 @code{--disable-bsfs}, and selectively enable any bitstream filter using
|
yading@10
|
10 the option @code{--enable-bsf=BSF}, or you can disable a particular
|
yading@10
|
11 bitstream filter using the option @code{--disable-bsf=BSF}.
|
yading@10
|
12
|
yading@10
|
13 The option @code{-bsfs} of the ff* tools will display the list of
|
yading@10
|
14 all the supported bitstream filters included in your build.
|
yading@10
|
15
|
yading@10
|
16 Below is a description of the currently available bitstream filters.
|
yading@10
|
17
|
yading@10
|
18 @section aac_adtstoasc
|
yading@10
|
19
|
yading@10
|
20 @section chomp
|
yading@10
|
21
|
yading@10
|
22 @section dump_extradata
|
yading@10
|
23
|
yading@10
|
24 @section h264_mp4toannexb
|
yading@10
|
25
|
yading@10
|
26 Convert an H.264 bitstream from length prefixed mode to start code
|
yading@10
|
27 prefixed mode (as defined in the Annex B of the ITU-T H.264
|
yading@10
|
28 specification).
|
yading@10
|
29
|
yading@10
|
30 This is required by some streaming formats, typically the MPEG-2
|
yading@10
|
31 transport stream format ("mpegts").
|
yading@10
|
32
|
yading@10
|
33 For example to remux an MP4 file containing an H.264 stream to mpegts
|
yading@10
|
34 format with @command{ffmpeg}, you can use the command:
|
yading@10
|
35
|
yading@10
|
36 @example
|
yading@10
|
37 ffmpeg -i INPUT.mp4 -codec copy -bsf:v h264_mp4toannexb OUTPUT.ts
|
yading@10
|
38 @end example
|
yading@10
|
39
|
yading@10
|
40 @section imx_dump_header
|
yading@10
|
41
|
yading@10
|
42 @section mjpeg2jpeg
|
yading@10
|
43
|
yading@10
|
44 Convert MJPEG/AVI1 packets to full JPEG/JFIF packets.
|
yading@10
|
45
|
yading@10
|
46 MJPEG is a video codec wherein each video frame is essentially a
|
yading@10
|
47 JPEG image. The individual frames can be extracted without loss,
|
yading@10
|
48 e.g. by
|
yading@10
|
49
|
yading@10
|
50 @example
|
yading@10
|
51 ffmpeg -i ../some_mjpeg.avi -c:v copy frames_%d.jpg
|
yading@10
|
52 @end example
|
yading@10
|
53
|
yading@10
|
54 Unfortunately, these chunks are incomplete JPEG images, because
|
yading@10
|
55 they lack the DHT segment required for decoding. Quoting from
|
yading@10
|
56 @url{http://www.digitalpreservation.gov/formats/fdd/fdd000063.shtml}:
|
yading@10
|
57
|
yading@10
|
58 Avery Lee, writing in the rec.video.desktop newsgroup in 2001,
|
yading@10
|
59 commented that "MJPEG, or at least the MJPEG in AVIs having the
|
yading@10
|
60 MJPG fourcc, is restricted JPEG with a fixed -- and *omitted* --
|
yading@10
|
61 Huffman table. The JPEG must be YCbCr colorspace, it must be 4:2:2,
|
yading@10
|
62 and it must use basic Huffman encoding, not arithmetic or
|
yading@10
|
63 progressive. . . . You can indeed extract the MJPEG frames and
|
yading@10
|
64 decode them with a regular JPEG decoder, but you have to prepend
|
yading@10
|
65 the DHT segment to them, or else the decoder won't have any idea
|
yading@10
|
66 how to decompress the data. The exact table necessary is given in
|
yading@10
|
67 the OpenDML spec."
|
yading@10
|
68
|
yading@10
|
69 This bitstream filter patches the header of frames extracted from an MJPEG
|
yading@10
|
70 stream (carrying the AVI1 header ID and lacking a DHT segment) to
|
yading@10
|
71 produce fully qualified JPEG images.
|
yading@10
|
72
|
yading@10
|
73 @example
|
yading@10
|
74 ffmpeg -i mjpeg-movie.avi -c:v copy -bsf:v mjpeg2jpeg frame_%d.jpg
|
yading@10
|
75 exiftran -i -9 frame*.jpg
|
yading@10
|
76 ffmpeg -i frame_%d.jpg -c:v copy rotated.avi
|
yading@10
|
77 @end example
|
yading@10
|
78
|
yading@10
|
79 @section mjpega_dump_header
|
yading@10
|
80
|
yading@10
|
81 @section movsub
|
yading@10
|
82
|
yading@10
|
83 @section mp3_header_compress
|
yading@10
|
84
|
yading@10
|
85 @section mp3_header_decompress
|
yading@10
|
86
|
yading@10
|
87 @section noise
|
yading@10
|
88
|
yading@10
|
89 @section remove_extradata
|
yading@10
|
90
|
yading@10
|
91 @c man end BITSTREAM FILTERS
|