2 #------------------------------------------------------------------------------
3 # vorbis: file(1) magic for Ogg/Vorbis files
5 # From Felix von Leitner <leitner@fefe.de>
6 # Extended by Beni Cherniavsky <cben@crosswinds.net>
7 # Further extended by Greg Wooledge <greg@wooledge.org>
9 # Most (everything but the number of channels and bitrate) is commented
10 # out with `##' as it's not interesting to the average user. The most
11 # probable things advanced users would want to uncomment are probably
12 # the number of comments and the encoder version.
14 # FIXME: The first match has been made a search, so that it can skip
15 # over prepended ID3 tags. This will work for MIME type detection, but
16 # won't work for detecting other properties of the file (they all need
17 # to be made relative to the search). In any case, if the file has ID3
18 # tags, the ID3 information will be printed, not the Ogg information,
19 # so until that's fixed, this doesn't matter.
20 # FIXME[2]: Disable the above for now, since search assumes text mode.
23 #0 search/1000 OggS Ogg data
24 0 string OggS Ogg data
25 !:mime application/ogg
26 >4 byte !0 UNKNOWN REVISION %u
27 ##>4 byte 0 revision 0
29 ##>>14 lelong x (Serial %lX)
30 # non-Vorbis content: FLAC (Free Lossless Audio Codec, http://flac.sourceforge.net)
31 >>28 string \x7fFLAC \b, FLAC audio
32 # non-Vorbis content: Theora
33 >>28 string \x80theora \b, Theora video
34 # non-Vorbis content: Kate
35 >>28 string \x80kate\0\0\0\0 \b, Kate
38 >>>40 byte 0 utf8 encoding,
39 >>>40 byte !0 unknown character encoding,
40 >>>60 string >\0 language %s,
41 >>>60 string \0 no language set,
42 >>>76 string >\0 category %s
43 >>>76 string \0 no category set
44 # non-Vorbis content: Skeleton
45 >>28 string fishead\0 \b, Skeleton
48 # non-Vorbis content: Speex
49 >>28 string Speex\ \ \ \b, Speex audio
50 # non-Vorbis content: OGM
51 >>28 string \x01video\0\0\0 \b, OGM video
52 >>>37 string/c div3 (DivX 3)
53 >>>37 string/c divx (DivX 4)
54 >>>37 string/c dx50 (DivX 5)
55 >>>37 string/c xvid (XviD)
56 # --- First vorbis packet - general header ---
57 >>28 string \x01vorbis \b, Vorbis audio,
58 >>>35 lelong !0 UNKNOWN VERSION %lu,
59 ##>>>35 lelong 0 version 0,
62 >>>>39 ubyte 2 stereo,
63 >>>>39 ubyte >2 %u channels,
64 >>>>40 lelong x %lu Hz
65 # Minimal, nominal and maximal bitrates specified when encoding
66 >>>>48 string <\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff \b,
67 # The above tests if at least one of these is specified:
69 # Vorbis RC2 has a bug which puts -1000 in the min/max bitrate fields
71 # Vorbis 1.0 uses 0 instead of -1.
73 >>>>>>>52 lelong !-1000
74 >>>>>>>>52 lelong x <%lu
76 >>>>>>48 lelong x ~%lu
78 >>>>>>44 lelong !-1000
80 >>>>>>>>44 lelong x >%lu
81 >>>>>48 string <\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff bps
82 # -- Second vorbis header packet - the comments
83 # A kludge to read the vendor string. It's a counted string, not a
84 # zero-terminated one, so file(1) can't read it in a generic way.
85 # libVorbis is the only one existing currently, so I detect specifically
86 # it. The interesting value is the cvs date (8 digits decimal).
87 # Post-RC1 Ogg files have the second header packet (and thus the version)
88 # in a different place, so we must use an indirect offset.
89 >>>(84.b+85) string \x03vorbis
90 >>>>(84.b+96) string/c Xiphophorus\ libVorbis\ I \b, created by: Xiphophorus libVorbis I
91 >>>>>(84.b+120) string >00000000
92 # Map to beta version numbers:
93 >>>>>>(84.b+120) string <20000508 (<beta1, prepublic)
94 >>>>>>(84.b+120) string 20000508 (1.0 beta 1 or beta 2)
95 >>>>>>(84.b+120) string >20000508
96 >>>>>>>(84.b+120) string <20001031 (beta2-3)
97 >>>>>>(84.b+120) string 20001031 (1.0 beta 3)
98 >>>>>>(84.b+120) string >20001031
99 >>>>>>>(84.b+120) string <20010225 (beta3-4)
100 >>>>>>(84.b+120) string 20010225 (1.0 beta 4)
101 >>>>>>(84.b+120) string >20010225
102 >>>>>>>(84.b+120) string <20010615 (beta4-RC1)
103 >>>>>>(84.b+120) string 20010615 (1.0 RC1)
104 >>>>>>(84.b+120) string 20010813 (1.0 RC2)
105 >>>>>>(84.b+120) string 20010816 (RC2 - Garf tuned v1)
106 >>>>>>(84.b+120) string 20011014 (RC2 - Garf tuned v2)
107 >>>>>>(84.b+120) string 20011217 (1.0 RC3)
108 >>>>>>(84.b+120) string 20011231 (1.0 RC3)
109 # Some pre-1.0 CVS snapshots still had "Xiphphorus"...
110 >>>>>>(84.b+120) string >20011231 (pre-1.0 CVS)
111 # For the 1.0 release, Xiphophorus is replaced by Xiph.Org
112 >>>>(84.b+96) string/c Xiph.Org\ libVorbis\ I \b, created by: Xiph.Org libVorbis I
113 >>>>>(84.b+117) string >00000000
114 >>>>>>(84.b+117) string <20020717 (pre-1.0 CVS)
115 >>>>>>(84.b+117) string 20020717 (1.0)
116 >>>>>>(84.b+117) string 20030909 (1.0.1)
117 >>>>>>(84.b+117) string 20040629 (1.1.0 RC1)