htmlvideohtml5-videomp4webm

webm before or after mp4 in HTML5 video element?


Every tutorial/explanation I see out there that discusses HTML5 video format fallbacks use this type of markup as an example:

<video autoplay>  
  <source src="/myvideo.mp4" type="video/mp4">  
  <source src="/myvideo.webm" type="video/webm">  
  Sorry, your browser doesn't support HTML5 video.  
</video> 

So my question, why does everyone suggest to put the MP4 before the Webm format? If your browser supports Webm, it almost definitely supports MP4... The above markup essentially ensures that the more efficient Webm video will never be used, even though it has arguably better compression and will reduce bandwidth. Why is this?

Am I missing something about the way video fallbacks work?


Solution

  • It has to do with backwards compatibility with iOS 3 devices. iPads running iOS 3 had a bug that prevented them from noticing anything but the first video source listed.

    MP4 video type was the only supported video format, so if the mp4 version of the video is not the first source, it is ignored.

    So, if you want to deliver video to iPad owners who haven’t yet upgraded iOS, you will need to list your MP4 file first, followed by the rest of the video formats.

    Read more