1. 程式人生 > >常用MIME型別(Mp4的mime型別設定)

常用MIME型別(Mp4的mime型別設定)

前兩天在遇到了一個h5寫的mp4視訊網頁在某些電腦中開啟後只下載而不播放的問題(大部分電腦都播放正確,而有些電腦在開啟網頁時就會變成迅雷下載,下載完成也不會播放)。

html如下:

  1. <video id="video" class="uk-cover-object uk-position-absolute uk-hidden-touch" width="640" height="360" muted loop autoplay src="~/video/first.mp4" poster="~/images/banner.jpg">
  2. 您的瀏覽器不支援當前的視訊格式!
  3. </video>

後來發現是伺服器MIME配置有問題, 原來伺服器配置的MIME type為:application/octet-stream。改為video/mp4之後就好了。

那麼,application/octet-stream和video/mp4有什麼區別呢?

1、先看一下mime type的定義,維基百科中的解釋很好,特此摘抄過來:

一個MIME型別包括一個型別(type),一個子型別(subtype)。此外可以加上一個或多個可選引數(optional parameter)。其格式為

型別名 / 子型別名 [ ; 可選引數 ]

目前已被註冊的型別名有application

audioexampleimagemessagemodelmultiparttext,以及videochemical是一個非官方的常用型別名。[1]此外,非標準的型別名一般會加上x-字首,但這種做法已經過時。[2]

子型別名通常是一個媒體形式被冠以的名稱,不過子型別名中也會有其它資訊,包括廠商資訊、產品資訊、分類資訊(子型別會被歸進一個樹狀的分類結構中)、字尾等等。樹結構分類資訊以被.相互連線的字串表示。每一個由.分隔開的部分又可以加上與其以-相連線的附加資訊。此外,子型別名中也會有放在最後,與前面的內容以+相連線的字尾。因此,一個媒體型別的格式可以被更加細地表示為:

型別名 / [ 樹結構分類資訊(中間可能有一個或多個“.”) ] 子型別名(中間可能有一個或多個“-”) [ + 字尾 ] [ ; 可選引數 ]

2、再看看這兩種的型別的用途:

application/octet-stream:任意的二進位制檔案(通常做為通知瀏覽器下載檔案);

video/mp4MP4

下面附上常見的mimetype配置列表

Video Type Extension MIME Type
Flash .flv video/x-flv
MPEG-4 .mp4 video/mp4
iPhone Index .m3u8 application/x-mpegURL
iPhone Segment .ts video/MP2T
3GP Mobile .3gp video/3gpp
QuickTime .mov video/quicktime
A/V Interleave .avi video/x-msvideo
Windows Media .wmv video/x-ms-wmv

最後,貼一個比較全的列表(轉自:http://www.freeformatter.com/mime-types-list.html):

Name MIME Type / Internet Media Type File Extension More Details
CoolTalk x-conference/x-cooltalk .ice
SGI Movie video/x-sgi-movie .movie
Audio Video Interleave (AVI) video/x-msvideo .avi
Microsoft Windows Media Audio/Video Playlist video/x-ms-wmx .wmx
FLI/FLC Animation Format video/x-fli .fli
Open Web Media Project - Video video/webm .webm
Vivo video/vnd.vivo .viv
DECE MP4 video/vnd.uvvu.mp4 .uvu
Microsoft PlayReady Ecosystem Video video/vnd.ms-playready.media.pyv .pyv
MPEG Url video/vnd.mpegurl .mxu
FAST Search & Transfer ASA video/vnd.fvt .fvt
DECE Video video/vnd.dece.video .uvv
DECE SD Video video/vnd.dece.sd .uvs
DECE PD Video video/vnd.dece.pd .uvp
DECE Mobile Video video/vnd.dece.mobile .uvm
DECE High Definition Video video/vnd.dece.hd .uvh
Quicktime Video video/quicktime .qt
Ogg Video video/ogg .ogv
MPEG Video video/mpeg .mpeg
MPEG-4 Video video/mp4 .mp4
Motion JPEG 2000 video/mj2 .mj2
JPEG 2000 Compound Image File Format video/jpm .jpm
JPGVideo video/jpeg .jpgv
YAML Ain't Markup Language / Yet Another Markup Language text/yaml .yaml
vCalendar text/x-vcalendar .vcs
Pascal Source File text/x-pascal .p
Java Source File text/x-java-source,java .java
Fortran Source File text/x-fortran .f
Assembler Source File text/x-asm .s
Wireless Markup Language Script (WMLScript) text/vnd.wap.wmlscript .wmls
Wireless Markup Language (WML) text/vnd.wap.wml .wml
J2ME App Descriptor text/vnd.sun.j2me.app-descriptor .jad
In3D - 3DML text/vnd.in3d.spot .spot
In3D - 3DML text/vnd.in3d.3dml .3dml
Graphviz text/vnd.graphviz .gv
FLEXSTOR text/vnd.fmi.flexstor .flx
mod_fly / fly.cgi text/vnd.fly .fly
Curl - Source Code text/vnd.curl.scurl .scurl
Curl - Manifest File text/vnd.curl.mcurl .mcurl
Curl - Detached Applet text/vnd.curl.dcurl .dcurl
Curl - Applet text/vnd.curl .curl
URI Resolution Services text/uri-list .uri
Turtle (Terse RDF Triple Language) text/turtle .ttl
Tab Seperated Values text/tab-separated-values .tsv
Standard Generalized Markup Language (SGML) text/sgml .sgml
Rich Text Format (RTF) text/richtext .rtx
PRS Lines Tag text/prs.lines.tag .dsc
BAS Partitur Format text/plain-bas .par
HyperText Markup Language (HTML) text/html .html
Comma-Seperated Values text/csv .csv
Cascading Style Sheets (CSS) text/css .css
Virtual Reality Modeling Language model/vrml .wrl
Virtue VTU model/vnd.vtu .vtu
Virtue MTS model/vnd.mts .mts
Gen-Trix Studio model/vnd.gtw .gtw
Geometric Description Language (GDL) model/vnd.gdl .gdl
Autodesk Design Web Format (DWF) model/vnd.dwf .dwf
COLLADA model/vnd.collada+xml .dae
Mesh Data Type model/mesh .msh
Initial Graphics Exchange Specification (IGES) model/iges .igs
Email Message message/rfc822 .eml
X Window Dump image/x-xwindowdump .xwd
X PixMap image/x-xpixmap .xpm
X BitMap image/x-xbitmap .xbm
Silicon Graphics RGB Bitmap image/x-rgb .rgb
Portable Pixmap Format image/x-portable-pixmap .ppm
Portable Graymap Format image/x-portable-graymap .pgm
Portable Bitmap Format image/x-portable-bitmap .pbm
Portable Anymap Image image/x-portable-anymap .pnm
Portable Network Graphics (PNG) (x-token) image/x-png .png
PICT Image image/x-pict .pic
PCX Image image/x-pcx .pcx
Corel Metafile Exchange (CMX) image/x-cmx .cmx
CMU Image image/x-cmu-raster .ras
Portable Network Graphics (PNG) (Citrix client) image/x-citrix-png .png
JPEG Image (Citrix client) image/x-citrix-jpeg .jpeg, .jpg
WebP Image image/webp .webp
eXtended Image File Format (XIFF) image/vnd.xiff .xif
WAP Bitamp (WBMP) image/vnd.wap.wbmp .wbmp
FlashPix image/vnd.net-fpx .npx
EDMICS 2000 image/vnd.fujixerox.edmics-rlc .rlc
EDMICS 2000 image/vnd.fujixerox.edmics-mmr .mmr
FlashPix image/vnd.fpx .fpx
FastBid Sheet image/vnd.fastbidsheet .fbs
DWG Drawing image/vnd.dwg .dwg
Close Captioning - Subtitle image/vnd.dvb.subtitle .sub
DjVu image/vnd.djvu .djvu
DECE Graphic image/vnd.dece.graphic .uvi
Photoshop Document image/vnd.adobe.photoshop .psd
Tagged Image File Format image/tiff .tiff
Scalable Vector Graphics (SVG) image/svg+xml .svg
BTIF image/prs.btif .btif
Portable Network Graphics (PNG) image/png .png
JPEG Image (Progressive) image/pjpeg .pjpeg
OpenGL Textures (KTX) image/ktx .ktx