UNPKG

avguesser

Version:

Guess the type of an AV file based on its header

2 lines (1 loc) 1.19 kB
function e(e){var r;if(e.buffer){var a=e;r=new Uint32Array(a.buffer,a.byteOffset,~~(a.byteLength/4))}else{r=new Uint32Array(e,0,~~(e.byteLength/4))}function t(e,r,a,t){return{success:!0,format:e,audio:!!r,video:!!a,image:!!t}}switch(r[0]){case 1297239878:return t("aiff",1,0,0);case 1974609456:return t("asf",1,1,0);case 1684960046:return t("au",1,0,0);case 1179011410:switch(r[2]){case 541677121:return t("avi",1,1,0);case 1163280727:return t("wav",1,0,0);case 1346520407:return t("webp",0,1,1)}break;case 1717985635:return t("caf",1,0,0);case 1130450022:return t("flac",1,0,0);case 22432838:return t("flv",1,1,0);case 944130375:return t("gif",0,1,1);case 2749318426:return t("matroska",1,1,0);case 1399285583:return t("ogg",1,1,0);case 1196314761:return t("png",0,0,1);case 1179472430:return t("rm",1,1,0);case 2771273:case 2836809:case 704662861:case 721440077:return t("tiff",0,0,1);case 1802532471:return t("wv",1,0,0)}switch(16777215&r[0]){case 1823:return t("dv",1,1,0);case 16767231:return t("jpeg",0,0,1);case 3359817:return t("mp3",1,0,0);case 65536:return t("mpeg",1,1,0)}return 1887007846===r[1]?t("mp4",1,1,0):71==(255&r[0])?t("mpegts",1,1,0):{success:!1}}export{e as guess};