Warning:
This wiki has been archived and is now read-only.
ChangeProposals/NoVideoContentType
No <video> Content-Type
Written by Philip Jägenstedt.
Summary
Simplify <video>
for implementors and authors by ignoring the Content-Type
HTTP header, thereby removing the need to mention application/octet-stream
at all.
Note: All proposed changes to <video>
should also apply to <audio>
.
Contents
Rationale
ISSUE-145 is about the mention of the codecs
parameter for the application/octet-stream
type.
The only reason that application/octet-stream
is mentioned in the spec at all is because it tries to reach some kind of compromise on how to deal with the Content-Type
HTTP header. The current state of implementations is a mess, as summarized by Ian Hickson:
- "Microsoft's position is, as far as I can tell, that there's no point looking at the Content-Type header, [...]"
- "Safari does crazy things right now that we won't go into; [...]"
- "Chrome right now sniffs like IE, [...]"
- "Opera does what the spec suggests. [...]"
- "Mozilla respects the Content-Type religiously, [...]"
The currently specified handling of Content-Type
has concrete negative side-effects for both implementors and authors, outlined in the following sections.
Rather than continuing to maintain this mess, we should jump directly to the most sane of the likely outcomes, which is to always ignore Content-Type
for <video>
.
Issues for Implementors
- Because
application/octet-stream
is special-cased incanPlayType
, the same code path cannot be used forcanPlayType
as for checkingContent-Type
and<source type>
. - In the resource fetch algorithm, if the resource is transferred using many HTTP byte range requests, it's unclear if
Content-Type
should be checked on the first request, or on every request. Either would be problematic:- Checking it only once is inconsistent because on subsequent requests,
Content-Type
may have changed, but this would be ignored. - Checking it for every request could amount to very many times during the playback of a long video. If the underlying media framework must be queried each time, it could be time-consuming. Introducing caching to work around it increases the risk of bugs.
- Checking it only once is inconsistent because on subsequent requests,
- In order to be compatible with what is sent in
Content-Type
, implementations must support several synonymous MIME types. This is exposed viacanPlayType
, where there was no legacy to consider originally, creating unnecessary room for incompatibilities. For example, Firefox supports 4 different MIME types for WAVE, Opera supports 3 and Chrome supports 2. (source)
Issues for Authors
- Because of the way
application/octet-stream
is special-cased, the result ofcanPlayType
is subtly different from howContent-Type
and<source type>
are treated, which is confusing. For example,canPlayType("application/octet-stream")
returns""
, whilecanPlayType("application/octet-stream;")
returns"maybe"
. Yet, using either value inContent-Type
should cause the user agent to use sniffing to determine the resource type and try decoding it. - Many servers are not configured to serve the correct
Content-Type
for audio and video types:- Authors who are not aware of the requirements on
Content-Type
will go through time-consuming debugging before eventually learning how to configure their server. - Authors who cannot control what
Content-Type
HTTP header is sent by their server will be unable to use<video>
at all.
- Authors who are not aware of the requirements on
Details
- Remove all mention of
application/octet-stream
from the<video>
section, especially:- The special-casing of
application/octet-stream
from thecanPlayType
method.
- The special-casing of
- Remove all mention of
Content-Type
from the<video>
section, especially:- The following case from the resource fetch algorithm: "If the media resource is found to have Content-Type metadata that, when parsed as a MIME type (including any codecs described by the codecs parameter, if the parameter is defined for that type), represents a type that the user agent knows it cannot render (even if the actual media data is in a supported format)"
Impact
Positive Effects
- The behavior of
<video>
with respect toContent-Type
is aligned with how e.g.<img>
already works. - No more time is spent maintaining an unstable situation on which it is very unlikely implementations will converge.
- Implementations of
<video>
are simplified. - The incentive for supporting many different equivalent MIME types in
canPlayType
and<source type>
is removed, as they come only from legacyContent-Type
issues. - Some legacy MIME types, such as
audio/x-pn-wav
, can likely be removed from implementations ofcanPlayType
. - Using
<video>
becomes simpler for authors.
Negative Effects
- Video will always play in a
<video>
context but may fail in a top-level browsing content, depending on theContent-Type
and what sniffing is used. (This is already the situation for images.) -
Content-Type
as the definitive mechanism for type information in HTTP is undermined even further.
Conformance Classes Changes
User Agents
Risks
- Failure to standardize sniffing of video types may result in poor interoperability. This is already the case, as the spec currently requires sniffing after checking
Content-Type
. However, the risk does increases somewhat when more implementations switch to always sniffing.
Note: Work on standardized sniffing for audio and video types has already begun in Media Type Sniffing.
References
- ISSUE-145
- <video> application/octet-stream thread started by Philip Jägenstedt
- video/@src vs application/octet-stream thread forked by Julian Reschke
- Video with MIME type application/octet-stream thread half-way summary by Ian Hickson
- Video with MIME type application/octet-stream thread final summary by Ian Hickson
- Media Type Sniffing Internet-Draft
Articles and documentation for <video>
that mention Content-Type
:
- http://diveintohtml5.org/video.html#video-mime-types
- http://www.html5rocks.com/tutorials/video/basics/#toc-markup
- http://dev.opera.com/articles/view/everything-you-need-to-know-about-html5-video-and-audio/
- https://developer.mozilla.org/en/HTML/Element/video#Server_support
- https://developer.mozilla.org/en/Configuring_servers_for_Ogg_media
Stack Overflow questions where the root cause was an incorrect Content-Type
:
- http://stackoverflow.com/questions/2643447/html5-video-mp4-and-ogv-problems-in-safari-and-firefox-but-chrome-is-all-good/2644341
- http://stackoverflow.com/questions/2756414/ogg-video-not-playing-in-firefox
- http://stackoverflow.com/questions/2964193/html5-video-problem
- http://stackoverflow.com/questions/3525984/firefox-to-play-ogg