riff 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. #------------------------------------------------------------------------------
  2. # $File: riff,v 1.22 2011/09/06 11:00:06 christos Exp $
  3. # riff: file(1) magic for RIFF format
  4. # See
  5. #
  6. # http://www.seanet.com/users/matts/riffmci/riffmci.htm
  7. #
  8. # AVI section extended by Patrik Rådman <patrik+file-magic@iki.fi>
  9. #
  10. 0 string RIFF RIFF (little-endian) data
  11. # RIFF Palette format
  12. >8 string PAL \b, palette
  13. >>16 leshort x \b, version %d
  14. >>18 leshort x \b, %d entries
  15. # RIFF Device Independent Bitmap format
  16. >8 string RDIB \b, device-independent bitmap
  17. >>16 string BM
  18. >>>30 leshort 12 \b, OS/2 1.x format
  19. >>>>34 leshort x \b, %d x
  20. >>>>36 leshort x %d
  21. >>>30 leshort 64 \b, OS/2 2.x format
  22. >>>>34 leshort x \b, %d x
  23. >>>>36 leshort x %d
  24. >>>30 leshort 40 \b, Windows 3.x format
  25. >>>>34 lelong x \b, %d x
  26. >>>>38 lelong x %d x
  27. >>>>44 leshort x %d
  28. # RIFF MIDI format
  29. >8 string RMID \b, MIDI
  30. # RIFF Multimedia Movie File format
  31. >8 string RMMP \b, multimedia movie
  32. # RIFF wrapper for MP3
  33. >8 string RMP3 \b, MPEG Layer 3 audio
  34. # Microsoft WAVE format (*.wav)
  35. >8 string WAVE \b, WAVE audio
  36. !:mime audio/x-wav
  37. >>20 leshort 1 \b, Microsoft PCM
  38. >>>34 leshort >0 \b, %d bit
  39. >>20 leshort 2 \b, Microsoft ADPCM
  40. >>20 leshort 6 \b, ITU G.711 A-law
  41. >>20 leshort 7 \b, ITU G.711 mu-law
  42. >>20 leshort 8 \b, Microsoft DTS
  43. >>20 leshort 17 \b, IMA ADPCM
  44. >>20 leshort 20 \b, ITU G.723 ADPCM (Yamaha)
  45. >>20 leshort 49 \b, GSM 6.10
  46. >>20 leshort 64 \b, ITU G.721 ADPCM
  47. >>20 leshort 80 \b, MPEG
  48. >>20 leshort 85 \b, MPEG Layer 3
  49. >>20 leshort 0x2001 \b, DTS
  50. >>22 leshort =1 \b, mono
  51. >>22 leshort =2 \b, stereo
  52. >>22 leshort >2 \b, %d channels
  53. >>24 lelong >0 %d Hz
  54. # Corel Draw Picture
  55. >8 string CDRA \b, Corel Draw Picture
  56. !:mime image/x-coreldraw
  57. # AVI == Audio Video Interleave
  58. >8 string AVI\040 \b, AVI
  59. !:mime video/x-msvideo
  60. >>12 string LIST
  61. >>>20 string hdrlavih
  62. >>>>&36 lelong x \b, %lu x
  63. >>>>&40 lelong x %lu,
  64. >>>>&4 lelong >1000000 <1 fps,
  65. >>>>&4 lelong 1000000 1.00 fps,
  66. >>>>&4 lelong 500000 2.00 fps,
  67. >>>>&4 lelong 333333 3.00 fps,
  68. >>>>&4 lelong 250000 4.00 fps,
  69. >>>>&4 lelong 200000 5.00 fps,
  70. >>>>&4 lelong 166667 6.00 fps,
  71. >>>>&4 lelong 142857 7.00 fps,
  72. >>>>&4 lelong 125000 8.00 fps,
  73. >>>>&4 lelong 111111 9.00 fps,
  74. >>>>&4 lelong 100000 10.00 fps,
  75. # ]9.9,10.1[
  76. >>>>&4 lelong <101010
  77. >>>>>&-4 lelong >99010
  78. >>>>>>&-4 lelong !100000 ~10 fps,
  79. >>>>&4 lelong 83333 12.00 fps,
  80. # ]11.9,12.1[
  81. >>>>&4 lelong <84034
  82. >>>>>&-4 lelong >82645
  83. >>>>>>&-4 lelong !83333 ~12 fps,
  84. >>>>&4 lelong 66667 15.00 fps,
  85. # ]14.9,15.1[
  86. >>>>&4 lelong <67114
  87. >>>>>&-4 lelong >66225
  88. >>>>>>&-4 lelong !66667 ~15 fps,
  89. >>>>&4 lelong 50000 20.00 fps,
  90. >>>>&4 lelong 41708 23.98 fps,
  91. >>>>&4 lelong 41667 24.00 fps,
  92. # ]23.9,24.1[
  93. >>>>&4 lelong <41841
  94. >>>>>&-4 lelong >41494
  95. >>>>>>&-4 lelong !41708
  96. >>>>>>>&-4 lelong !41667 ~24 fps,
  97. >>>>&4 lelong 40000 25.00 fps,
  98. # ]24.9,25.1[
  99. >>>>&4 lelong <40161
  100. >>>>>&-4 lelong >39841
  101. >>>>>>&-4 lelong !40000 ~25 fps,
  102. >>>>&4 lelong 33367 29.97 fps,
  103. >>>>&4 lelong 33333 30.00 fps,
  104. # ]29.9,30.1[
  105. >>>>&4 lelong <33445
  106. >>>>>&-4 lelong >33223
  107. >>>>>>&-4 lelong !33367
  108. >>>>>>>&-4 lelong !33333 ~30 fps,
  109. >>>>&4 lelong <32224 >30 fps,
  110. ##>>>>&4 lelong x (%lu)
  111. ##>>>>&20 lelong x %lu frames,
  112. # Note: The tests below assume that the AVI has 1 or 2 streams,
  113. # "vids" optionally followed by "auds".
  114. # (Should cover 99.9% of all AVIs.)
  115. # assuming avih length = 56
  116. >>>88 string LIST
  117. >>>>96 string strlstrh
  118. >>>>>108 string vids video:
  119. >>>>>>&0 lelong 0 uncompressed
  120. # skip past vids strh
  121. >>>>>>(104.l+108) string strf
  122. >>>>>>>(104.l+132) lelong 1 RLE 8bpp
  123. >>>>>>>(104.l+132) string/c cvid Cinepak
  124. >>>>>>>(104.l+132) string/c i263 Intel I.263
  125. >>>>>>>(104.l+132) string/c iv32 Indeo 3.2
  126. >>>>>>>(104.l+132) string/c iv41 Indeo 4.1
  127. >>>>>>>(104.l+132) string/c iv50 Indeo 5.0
  128. >>>>>>>(104.l+132) string/c mp42 Microsoft MPEG-4 v2
  129. >>>>>>>(104.l+132) string/c mp43 Microsoft MPEG-4 v3
  130. >>>>>>>(104.l+132) string/c fmp4 FFMpeg MPEG-4
  131. >>>>>>>(104.l+132) string/c mjpg Motion JPEG
  132. >>>>>>>(104.l+132) string/c div3 DivX 3
  133. >>>>>>>>112 string/c div3 Low-Motion
  134. >>>>>>>>112 string/c div4 Fast-Motion
  135. >>>>>>>(104.l+132) string/c divx DivX 4
  136. >>>>>>>(104.l+132) string/c dx50 DivX 5
  137. >>>>>>>(104.l+132) string/c xvid XviD
  138. >>>>>>>(104.l+132) string/c h264 H.264
  139. >>>>>>>(104.l+132) string/c wmv3 Windows Media Video 9
  140. >>>>>>>(104.l+132) string/c h264 X.264 or H.264
  141. >>>>>>>(104.l+132) lelong 0
  142. ##>>>>>>>(104.l+132) string x (%.4s)
  143. # skip past first (video) LIST
  144. >>>>(92.l+96) string LIST
  145. >>>>>(92.l+104) string strlstrh
  146. >>>>>>(92.l+116) string auds \b, audio:
  147. # auds strh length = 56:
  148. >>>>>>>(92.l+172) string strf
  149. >>>>>>>>(92.l+180) leshort 0x0001 uncompressed PCM
  150. >>>>>>>>(92.l+180) leshort 0x0002 ADPCM
  151. >>>>>>>>(92.l+180) leshort 0x0006 aLaw
  152. >>>>>>>>(92.l+180) leshort 0x0007 uLaw
  153. >>>>>>>>(92.l+180) leshort 0x0050 MPEG-1 Layer 1 or 2
  154. >>>>>>>>(92.l+180) leshort 0x0055 MPEG-1 Layer 3
  155. >>>>>>>>(92.l+180) leshort 0x2000 Dolby AC3
  156. >>>>>>>>(92.l+180) leshort 0x0161 DivX
  157. ##>>>>>>>>(92.l+180) leshort x (0x%.4x)
  158. >>>>>>>>(92.l+182) leshort 1 (mono,
  159. >>>>>>>>(92.l+182) leshort 2 (stereo,
  160. >>>>>>>>(92.l+182) leshort >2 (%d channels,
  161. >>>>>>>>(92.l+184) lelong x %d Hz)
  162. # auds strh length = 64:
  163. >>>>>>>(92.l+180) string strf
  164. >>>>>>>>(92.l+188) leshort 0x0001 uncompressed PCM
  165. >>>>>>>>(92.l+188) leshort 0x0002 ADPCM
  166. >>>>>>>>(92.l+188) leshort 0x0055 MPEG-1 Layer 3
  167. >>>>>>>>(92.l+188) leshort 0x2000 Dolby AC3
  168. >>>>>>>>(92.l+188) leshort 0x0161 DivX
  169. ##>>>>>>>>(92.l+188) leshort x (0x%.4x)
  170. >>>>>>>>(92.l+190) leshort 1 (mono,
  171. >>>>>>>>(92.l+190) leshort 2 (stereo,
  172. >>>>>>>>(92.l+190) leshort >2 (%d channels,
  173. >>>>>>>>(92.l+192) lelong x %d Hz)
  174. # Animated Cursor format
  175. >8 string ACON \b, animated cursor
  176. # SoundFont 2 <mpruett@sgi.com>
  177. >8 string sfbk SoundFont/Bank
  178. # MPEG-1 wrapped in a RIFF, apparently
  179. >8 string CDXA \b, wrapped MPEG-1 (CDXA)
  180. >8 string 4XMV \b, 4X Movie file
  181. # AMV-type AVI file: http://wiki.multimedia.cx/index.php?title=AMV
  182. >8 string AMV\040 \b, AMV
  183. #
  184. # XXX - some of the below may only appear in little-endian form.
  185. #
  186. # Also "MV93" appears to be for one form of Macromedia Director
  187. # files, and "GDMF" appears to be another multimedia format.
  188. #
  189. 0 string RIFX RIFF (big-endian) data
  190. # RIFF Palette format
  191. >8 string PAL \b, palette
  192. >>16 beshort x \b, version %d
  193. >>18 beshort x \b, %d entries
  194. # RIFF Device Independent Bitmap format
  195. >8 string RDIB \b, device-independent bitmap
  196. >>16 string BM
  197. >>>30 beshort 12 \b, OS/2 1.x format
  198. >>>>34 beshort x \b, %d x
  199. >>>>36 beshort x %d
  200. >>>30 beshort 64 \b, OS/2 2.x format
  201. >>>>34 beshort x \b, %d x
  202. >>>>36 beshort x %d
  203. >>>30 beshort 40 \b, Windows 3.x format
  204. >>>>34 belong x \b, %d x
  205. >>>>38 belong x %d x
  206. >>>>44 beshort x %d
  207. # RIFF MIDI format
  208. >8 string RMID \b, MIDI
  209. # RIFF Multimedia Movie File format
  210. >8 string RMMP \b, multimedia movie
  211. # Microsoft WAVE format (*.wav)
  212. >8 string WAVE \b, WAVE audio
  213. >>20 leshort 1 \b, Microsoft PCM
  214. >>>34 leshort >0 \b, %d bit
  215. >>22 beshort =1 \b, mono
  216. >>22 beshort =2 \b, stereo
  217. >>22 beshort >2 \b, %d channels
  218. >>24 belong >0 %d Hz
  219. # Corel Draw Picture
  220. >8 string CDRA \b, Corel Draw Picture
  221. # AVI == Audio Video Interleave
  222. >8 string AVI\040 \b, AVI
  223. # Animated Cursor format
  224. >8 string ACON \b, animated cursor
  225. # Notation Interchange File Format (big-endian only)
  226. >8 string NIFF \b, Notation Interchange File Format
  227. # SoundFont 2 <mpruett@sgi.com>
  228. >8 string sfbk SoundFont/Bank
  229. #------------------------------------------------------------------------------
  230. # Sony Wave64
  231. # see http://www.vcs.de/fileadmin/user_upload/MBS/PDF/Whitepaper/Informations_about_Sony_Wave64.pdf
  232. # 128 bit RIFF-GUID { 66666972-912E-11CF-A5D6-28DB04C10000 } in little-endian
  233. 0 string riff\x2E\x91\xCF\x11\xA5\xD6\x28\xDB\x04\xC1\x00\x00 Sony Wave64 RIFF data
  234. # 128 bit + total file size (64 bits) so 24 bytes
  235. # then WAVE-GUID { 65766177-ACF3-11D3-8CD1-00C04F8EDB8A }
  236. >24 string wave\xF3\xAC\xD3\x11\x8C\xD1\x00\xC0\x4F\x8E\xDB\x8A \b, WAVE 64 audio
  237. !:mime audio/x-w64
  238. # FMT-GUID { 20746D66-ACF3-11D3-8CD1-00C04F8EDB8A }
  239. >>40 search/256 fmt\x20\xF3\xAC\xD3\x11\x8C\xD1\x00\xC0\x4F\x8E\xDB\x8A \b
  240. >>>&10 leshort =1 \b, mono
  241. >>>&10 leshort =2 \b, stereo
  242. >>>&10 leshort >2 \b, %d channels
  243. >>>&12 lelong >0 %d Hz
  244. #------------------------------------------------------------------------------
  245. # MBWF/RF64
  246. # see EBU – TECH 3306 http://tech.ebu.ch/docs/tech/tech3306-2009.pdf
  247. 0 string RF64\xff\xff\xff\xffWAVEds64 MBWF/RF64 audio
  248. !:mime audio/x-wav
  249. >40 search/256 fmt\x20 \b
  250. >>&6 leshort =1 \b, mono
  251. >>&6 leshort =2 \b, stereo
  252. >>&6 leshort >2 \b, %d channels
  253. >>&8 lelong >0 %d Hz