Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can a HTML 5 video tag have multiple MP4 sources with different codecs?

Tags:

html

video

mp4

I'm thinking about the fact that the higher the MP4 profile we go, the better the video quality gets...

This brings me to a question I thought I'd ask the experts!

Can a HTML 5 video tag have multiple MP4 sources with different codecs? Something like:

<video>
    <source src="video.webm" type='video/webm; codecs="vp8, vorbis"' />
    <source src="high.mp4" type='video/mp4; codecs="avc1.64001E, mp4a.40.2"' />
    <source src="main.mp4" type='video/mp4; codecs="avc1.4D401E, mp4a.40.2"' />
    <source src="baseline.mp4" type='video/mp4; codecs="avc1.58A01E, mp4a.40.2"' />
</video>

The first MP4 video being a high profile video, the second main profile, and the third baseline profile.

On an iPhone 3G, will the baseline one be played?

On an iPhone 4S, will the high one be played instead?

A follow up question: if the high profile video is below the baseline profile video in the source list, which one will play on an iPhone 4G?

(Thanks for reading and especially if you reply. :)

like image 546
bjfletcher Avatar asked Mar 27 '14 20:03

bjfletcher


People also ask

How do you provide multiple video file formats to a video tag?

The <video> tag is one of the HTML5 elements. It is used to embed video in an HTML document. Browsers don't all support the same video formats, so you should provide multiple video formats for correct rendering. A path to the video file is nested inside the <source> tag, or src attribute.

Can we include multiple sources for a single player in HTML?

You can provide several source tags and the user agent should play the first one it can handle.

What video format does HTML5 video element support?

The HTML5 video format capabilities include three options to play: MP4, WebM, and Ogg.

Which amongst the following video formats is not supported by HTML5 video tags?

". wmv" video files are not supported by any browser.

Which of the following is true about video tag in HTML5?

Q 4 - Which of the following is true about 'video' tag in HTML5? A - HTML5 supports <video> tag which is used to embed a video file in an HTML or XHTML document.

How many source tags can be contained inside a single video tag?

Video Tag with 2 Source Tags Note: The controls attribute displays the video controllers in the above example; if it is not present, the video can only be played by writing Javascript code.


1 Answers

According to Mozilla, <video> can contain an arbitrary number of <source> tags. Also, the first source tag with a compatible video file for the current device/browser should be played.

Apple themselves confirm that the <source> tags should be in the developer's preferred fall-through order, from which I'd assume that Mobile Safari, too, will pick the first file it can play.

So, from what I was able to dig up, there is no static way of preferring a particular file for a particular browser/device combination. You'd probably have to do some detection based on the provided User Agent string and only supply the proper files (but that's not possible with plain HTML).

like image 96
Cobra_Fast Avatar answered Oct 01 '22 22:10

Cobra_Fast