54

I am wondering if the HTML5 <video> tag now supports playback of .avi format video files.

Vertexwahn
  • 7,709
  • 6
  • 64
  • 90
phuang07
  • 981
  • 1
  • 9
  • 18

4 Answers4

47

Short answer: No. Use WebM or Ogg instead.

This article covers just about everything you need to know about the <video> element, including which browsers support which container formats and codecs.

Richard Poole
  • 3,946
  • 23
  • 29
  • 21
    Why there is no direct answer here? It is better to have short answer even through there is a link for detail answer. – Nish Apr 20 '15 at 05:58
  • 10
    The direct answer is "no". Technically – Rap Jan 18 '16 at 21:49
20

There are three formats with a reasonable level of support: H.264 (MPEG-4 AVC), OGG Theora (VP3) and WebM (VP8). See the wiki linked by Sam for which browsers support which; you will typically need at least one of those plus Flash fallback.

Whilst most browsers won't touch AVI, there are some browser builds that expose all the multimedia capabilities of the underlying OS to <video>. These browser will indeed be able to play AVI, as long as they have matching codecs installed (AVI can contain about a million different video and audio formats). In particular Safari on OS X with QuickTime, or Konqi with GStreamer.

Personally I think this is an absolutely disastrous idea, as it exposes a very large codec codebase to the net, a codebase that was mostly not written to be resistant to network attacks. One of the worst drawbacks of media player plugins was the huge number of security holes they made available to every web page exploit. Let's not make this mistake again.

bobince
  • 528,062
  • 107
  • 651
  • 834
  • 1
    @jQueryAngryBird: As the answer says, most browsers do not. You could target the Windows Media Player and/or QuickTime plugin to try to play AVI or WMV but it's yesterday's solution and will work for a declining subset of devices. Better to convert to MP4/WebM. – bobince Sep 23 '14 at 12:13
6

The current HTML5 draft specification does not specify which video formats browsers should support in the video tag. User agents are free to support any video formats they feel are appropriate.

http://en.wikipedia.org/wiki/HTML5_video

thenengah
  • 42,557
  • 33
  • 113
  • 157
  • @jQueryAngryBird: did you even read the answer? HTML *does not* specify which codecs to use. You can use any codec you want. It's up to the user to install the appropriate codecs in their browser. – Jörg W Mittag Sep 23 '14 at 09:39
2

The HTML specification never specifies any content formats. That's not its job. There's plenty of standards organizations that are more qualified than the W3C to specify video formats.

That's what content negotiation is for.

  • The HTML specification doesn't specify any image formats for the <img> element.
  • The HTML specification doesn't specify any style sheet languages for the <style> element.
  • The HTML specification doesn't specify any scripting languages for the <script> element.
  • The HTML specification doesn't specify any object formats for the <object> and embed elements.
  • The HTML specification doesn't specify any audio formats for the <audio> element.

Why should it specify one for the <video> element?

Jörg W Mittag
  • 363,080
  • 75
  • 446
  • 653