xref: /freebsd/contrib/file/magic/Magdir/vorbis (revision 924226fba12cc9a228c73b956e1b7fa24c60b055)
1
2#------------------------------------------------------------------------------
3# $File: vorbis,v 1.26 2020/08/22 18:30:55 christos Exp $
4# vorbis:  file(1) magic for Ogg/Vorbis files
5#
6# From Felix von Leitner <leitner@fefe.de>
7# Extended by Beni Cherniavsky <cben@crosswinds.net>
8# Further extended by Greg Wooledge <greg@wooledge.org>
9#
10# Most (everything but the number of channels and bitrate) is commented
11# out with `##' as it's not interesting to the average user.  The most
12# probable things advanced users would want to uncomment are probably
13# the number of comments and the encoder version.
14#
15# FIXME: The first match has been made a search, so that it can skip
16# over prepended ID3 tags. This will work for MIME type detection, but
17# won't work for detecting other properties of the file (they all need
18# to be made relative to the search). In any case, if the file has ID3
19# tags, the ID3 information will be printed, not the Ogg information,
20# so until that's fixed, this doesn't matter.
21# FIXME[2]: Disable the above for now, since search assumes text mode.
22#
23# --- Ogg Framing ---
24#0		search/1000	OggS		Ogg data
250		string	OggS		Ogg data
26>4		byte		!0		UNKNOWN REVISION %u
27##>4		byte		0		revision 0
28>4		byte		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!:mime		audio/ogg
34>>28		string		\x80theora	\b, Theora video
35!:mime		video/ogg
36# non-Vorbis content: Kate
37>>28		string		\x80kate\0\0\0\0	\b, Kate (Karaoke and Text)
38!:mime		application/ogg
39>>>37		ubyte		x		v%u
40>>>38		ubyte		x		\b.%u,
41>>>40		byte		0		utf8 encoding,
42>>>40		byte		!0		unknown character encoding,
43>>>60		string		>\0		language %s,
44>>>60		string		\0		no language set,
45>>>76		string		>\0		category %s
46>>>76		string		\0		no category set
47# non-Vorbis content: Skeleton
48>>28		string		fishead\0	\b, Skeleton
49!:mime		video/ogg
50>>>36		leshort		x		v%u
51>>>40		leshort		x		\b.%u
52# non-Vorbis content: Speex
53>>28		string		Speex\ \ \ 	\b, Speex audio
54!:mime		audio/ogg
55# non-Vorbis content: OGM
56>>28		string		\x01video\0\0\0	\b, OGM video
57!:mime		video/ogg
58>>>37		string/c	div3		(DivX 3)
59>>>37		string/c	divx		(DivX 4)
60>>>37		string/c	dx50		(DivX 5)
61>>>37		string/c	xvid		(XviD)
62# --- First vorbis packet - general header ---
63>>28		string		\x01vorbis	\b, Vorbis audio,
64!:mime		audio/ogg
65>>>35		lelong		!0		UNKNOWN VERSION %u,
66##>>>35		lelong		0		version 0,
67>>>35		lelong		0
68>>>>39		ubyte		1		mono,
69>>>>39		ubyte		2		stereo,
70>>>>39		ubyte		>2		%u channels,
71>>>>40		lelong		x		%u Hz
72# Minimal, nominal and maximal bitrates specified when encoding
73>>>>48		string		<\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff	\b,
74# The above tests if at least one of these is specified:
75>>>>>52		lelong		!-1
76# Vorbis RC2 has a bug which puts -1000 in the min/max bitrate fields
77# instead of -1.
78# Vorbis 1.0 uses 0 instead of -1.
79>>>>>>52	lelong		!0
80>>>>>>>52	lelong		!-1000
81>>>>>>>>52	lelong		x		<%u
82>>>>>48		lelong		!-1
83>>>>>>48	lelong		x		~%u
84>>>>>44		lelong		!-1
85>>>>>>44	lelong		!-1000
86>>>>>>>44	lelong		!0
87>>>>>>>>44	lelong		x		>%u
88>>>>>48		string		<\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff	bps
89# -- Second vorbis header packet - the comments
90# A kludge to read the vendor string.  It's a counted string, not a
91# zero-terminated one, so file(1) can't read it in a generic way.
92# libVorbis is the only one existing currently, so I detect specifically
93# it.  The interesting value is the cvs date (8 digits decimal).
94# Post-RC1 Ogg files have the second header packet (and thus the version)
95# in a different place, so we must use an indirect offset.
96>>>(84.b+85)		string		\x03vorbis
97>>>>(84.b+96)		string/c	Xiphophorus\ libVorbis\ I	\b, created by: Xiphophorus libVorbis I
98>>>>>(84.b+120)		string		>00000000
99# Map to beta version numbers:
100>>>>>>(84.b+120)	string		<20000508	(<beta1, prepublic)
101>>>>>>(84.b+120)	string		20000508	(1.0 beta 1 or beta 2)
102>>>>>>(84.b+120)	string		>20000508
103>>>>>>>(84.b+120)	string		<20001031	(beta2-3)
104>>>>>>(84.b+120)	string		20001031	(1.0 beta 3)
105>>>>>>(84.b+120)	string		>20001031
106>>>>>>>(84.b+120)	string		<20010225	(beta3-4)
107>>>>>>(84.b+120)	string		20010225	(1.0 beta 4)
108>>>>>>(84.b+120)	string		>20010225
109>>>>>>>(84.b+120)	string		<20010615	(beta4-RC1)
110>>>>>>(84.b+120)	string		20010615	(1.0 RC1)
111>>>>>>(84.b+120)	string		20010813	(1.0 RC2)
112>>>>>>(84.b+120)	string		20010816	(RC2 - Garf tuned v1)
113>>>>>>(84.b+120)	string		20011014	(RC2 - Garf tuned v2)
114>>>>>>(84.b+120)	string		20011217	(1.0 RC3)
115>>>>>>(84.b+120)	string		20011231	(1.0 RC3)
116# Some pre-1.0 CVS snapshots still had "Xiphphorus"...
117>>>>>>(84.b+120)	string		>20011231	(pre-1.0 CVS)
118# For the 1.0 release, Xiphophorus is replaced by Xiph.Org
119>>>>(84.b+96)		string/c	Xiph.Org\ libVorbis\ I	\b, created by: Xiph.Org libVorbis I
120>>>>>(84.b+117)		string		>00000000
121>>>>>>(84.b+117)	string		<20020717	(pre-1.0 CVS)
122>>>>>>(84.b+117)	string		20020717	(1.0)
123>>>>>>(84.b+117)	string		20030909	(1.0.1)
124>>>>>>(84.b+117)	string		20040629	(1.1.0 RC1)
125>>>>>>(84.b+117)	string		20050304	(1.1.2)
126>>>>>>(84.b+117)	string		20070622	(1.2.0)
127>>>>>>(84.b+117)	string		20090624	(1.2.2)
128>>>>>>(84.b+117)	string		20090709	(1.2.3)
129>>>>>>(84.b+117)	string		20100325	(1.3.1)
130>>>>>>(84.b+117)	string		20101101	(1.3.2)
131>>>>>>(84.b+117)	string		20120203	(1.3.3)
132>>>>>>(84.b+117)	string		20140122	(1.3.4)
133>>>>>>(84.b+117)	string		20150105	(1.3.5)
134
135# non-Vorbis content: Opus https://tools.ietf.org/html/rfc7845#section-5
136>>28		string		OpusHead	\b, Opus audio,
137!:mime		audio/ogg
138>>>36		ubyte		>0x0F		UNKNOWN VERSION %u,
139>>>36		ubyte&0x0F	!0		version 0.%u,
140>>>>46		ubyte		>1
141>>>>>46		ubyte		!255		unknown channel mapping family %u,
142>>>>>37		ubyte		x		%u channels
143>>>>46		ubyte		0
144>>>>>37		ubyte		1		mono
145>>>>>37		ubyte		2		stereo
146>>>>46		ubyte		1
147>>>>>37		ubyte		1		mono
148>>>>>37		ubyte		2		stereo
149>>>>>37		ubyte		3		linear surround
150>>>>>37		ubyte		4		quadraphonic
151>>>>>37		ubyte		5		5.0 surround
152>>>>>37		ubyte		6		5.1 surround
153>>>>>37		ubyte		7		6.1 surround
154>>>>>37		ubyte		8		7.1 surround
155>>>>40		lelong		!0		\b, %u Hz (Input Sample Rate)