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