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