Copyright © 2010 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C liability, trademark and document use rules apply.
This section describes the status of this document at the time of its publication. Other documents may supersede this document. A list of current W3C publications and the latest revision of this technical report can be found in the W3C technical reports index at http://www.w3.org/TR/.
This 24 June 2010 Last Call Working Draft of the Media Fragments URI 1.0 specification is an update of the previous Media Fragments URI 1.0 of 14 April 2010. It meets the requirements specified in the Use cases and requirements for Media Fragments document and incorporates all comments received. This document is intended to be published and maintained as a W3C Recommendation after review and refinement. It has been produced by the Media Fragments Working Group, which is part of the W3C Video on the Web Activity.
The Media Fragments Working Group believes to have addressed all issues brought forth through previous Working Draft iterations. The Working Group encourages feedback about this document by developers and researchers who have interest in multimedia content addressing and retrieval on the web and by developers and researchers who have interest in Semantic Web technologies for content description and annotation. Please send comments about this document to public-media-fragment@w3.org mailing list (public archive) by 27 August 2010.
Publication as a Working Draft does not imply endorsement by the W3C Membership. This is a draft document and may be updated, replaced or obsoleted by other documents at any time. It is inappropriate to cite this document as other than work in progress.
This document was produced by a group operating under the 5 February 2004 W3C Patent Policy. W3C maintains a public list of any patent disclosures made in connection with the deliverables of the group; that page also includes instructions for disclosing a patent. An individual who has actual knowledge of a patent which the individual believes contains Essential Claim(s) must disclose the information in accordance with section 6 of the W3C Patent Policy.
1 Introduction
2 Standardisation Issues
2.1 Terminology
2.2 Media Fragments Standardisation
2.2.1 URI Fragments
2.2.2 URI Queries
3 URI fragment and URI query
3.1 When to choose URI fragments? When to choose URI queries?
3.2 Resolving URI fragments within the user agent
3.3 Resolving URI fragments with server help
3.4 Resolving URI fragments in a proxy cacheable manner
3.5 Resolving URI queries
3.6 Combining URI fragments and URI queries
4 Media Fragments Syntax
4.1 General Structure
4.2 URL Serialization
4.3 Fragment Dimensions
4.3.1 Temporal Dimension
4.3.1.1 Normal Play Time (NPT)
4.3.1.2 SMPTE time codes
4.3.1.3 Wall-clock time code
4.3.2 Spatial Dimension
4.3.3 Track Dimension
4.3.4 Named Dimension
4.3.5 Common Syntax
5 Media Fragments Processing
5.1 Protocol for URI fragment Resolution in HTTP
5.1.1 UA mapped byte ranges
5.1.1.1 UA requests URI fragment for the first time
5.1.1.2 UA requests URI fragment it already has buffered
5.1.1.3 UA requests URI fragment of a changed resource
5.1.2 Server mapped byte ranges
5.1.2.1 Server mapped byte ranges with corresponding binary data
5.1.2.2 Server mapped byte ranges with corresponding binary data and codec setup data
5.1.2.3 Proxy cacheable server mapped byte ranges
5.1.3 Server triggered redirect
5.2 Protocol for URI query Resolution in HTTP
6 Media Fragments Semantics
6.1 Errors on the General URI level
6.1.1 Non-existent dimension:
6.1.2 Under-specified Dimension
6.2 Errors on the temporal dimensions
6.2.1 Valid requests
6.2.2 Empty
6.2.3 Non-existent
6.2.4 Validity error
6.3 Errors on the spatial dimensions
6.4 Errors on the track dimensions
6.5 Errors on the named dimensions
7 Notes to Implementors
7.1 Clients Displaying Media Fragments
7.2 All Media Fragment Clients
7.3 Media Fragment Servers
8 Conclusions
8.1 Qualification of Media Resources
A References
B Collected ABNF Syntax for URI (Non-Normative)
C Collected ABNF Syntax for HTTP Headers (Non-Normative)
D Notes on parsing media fragment URIs (Non-Normative)
D.1 Processing name-value components
D.2 Processing name-value lists
E Acknowledgements (Non-Normative)
F Change Log (Non-Normative)
The aim of this specification is to enhance the Web infrastructure for supporting the addressing and retrieval of subparts of time-based Web resources, as well as the automated processing of such subparts for reuse. Example uses are the sharing of such fragment URIs with friends via email, the automated creation of such fragment URIs in a search engine interface, or the annotation of media fragments with RDF. Such use case examples as well as other side conditions on this specification and a survey of existing media fragment addressing approaches are provided in the requirements Use cases and requirements for Media Fragments document that accompanies this specification document.
The media fragment URIs specified in this document have been implemented and demonstrated to work with media resources over the HTTP protocol. This specification is not defining the protocol aspect of RTSP handling of media fragment. We expect the media fragment URI syntax to be generic and a possible mapping between this syntax and RTSP messages is currently drafted at http://www.w3.org/2008/WebVideo/Fragments/wiki/UA_Server_RTSP_Communication. This may or may not be part of a future document authored by the Media Fragments Working Group. Existing media formats in their current representations and implementations provide varying degrees of support for this specification. It is expected that over time, media formats, media players, Web Browsers, media and Web servers, as well as Web proxies will be extended to adhere to the full specification. This specification will help make video a first-class citizen of the World Wide Web.
The keywords MUST, MUST NOT, SHOULD and SHOULD NOT are to be interpreted as defined in RFC 2119.
According to RFC 3986, the term "URI" does not include relative references. In this document, we consider both URIs and relative references. Consequently, we use the term "URI reference" as defined in RFC 3986 (section 4.1). For simplicity reasons, this document, however, only uses the term "media fragment URI" in place of "media fragment URI reference".
The following terms are used frequently in this document and need to be clearly understood:
The basis for the standardisation of media fragment URIs is the URI specification, RFC 3986. Providing media fragment identification information in URIs refers here to the specification of the structure of a URI fragment or a URI query. This document will explain how URI fragments and URI queries are structured to identify media fragments. It normalises the name-value parameters used in URI fragments and URI queries to address media fragments. These build on existing CGI parameter conventions.
In this section, we look at implications of standardising the structure of media fragment URIs.
The URI specification RFC 3986 says about the format of a URI fragment in Section 3.5:
"The fragment's format and resolution is [..] dependent on the media type [RFC2046] of a potentially retrieved representation. [..] Fragment identifier semantics are independent of the URI scheme and thus cannot be redefined by scheme specifications."
This essentially means that only media type definitions (as registered through the process defined in RFC 4288) are able to introduce a standard structure on URI fragments for that mime type. One part of the registration process of a media type can include information about how fragment identifiers in URIs are constructed for use in conjunction with this media type.
Note that the registration of URI fragment construction rules as expressed in Section 4.11 of RFC 4288 is only a SHOULD-requirement. An analysis of all media type registrations showed that there is not a single media type registration in the audio/*, image/*, video/* branches that is currently defining fragments or fragment semantics.
The Media Fragment WG has no authority to update registries of all targeted media types. To the best of our knowledge there are only few media types that actually have a specified fragment format even if it is not registered with the media type: these include Ogg, MPEG-4, and MPEG-21. Further, only a small number of software packages actually supports these fragment formats. For all others, the semantics of the fragment are considered to be unknown.
As such, the intention of this document is to propose a specification to all media type owners in the audio/*, image/*, and video/* branches for a structured approach to URI fragments and for specification of commonly agreed dimensions to address media fragments (i.e. subparts of a media resource) through URI fragments. We recommend media type owners to harmonize their existing schemes with the ones proposed in this document and update or add the fragment semantics specification to their media type registration.
The URI specification RFC 3986 says about the format of a URI query in Section 3.4:
"The query component [..] serves to identify a resource within the scope of the URI's scheme and naming authority (if any). [..] Query components are often used to carry identifying information in the form of "key=value" pairs [..]."
URI query specifications are more closely linked to the URI scheme, some of which do not even use a query component. We are mostly concerned with the HTTP RFC 2616 and the RTP/RTSP rfc2326 protocols here, which both support query components. HTTP says nothing about how a URI query has to be interpreted. RTSP explicitly says that fragment and query identifiers do not have a well-defined meaning at this time, with the interpretation left to the RTSP server.
The URI specification RFC 3986 says generally that the data within the URI is often parsed by both the user agent and one or more servers. It refers in particular to HTTP in Section 7.3:
"In HTTP, for example, a typical user agent will parse a URI into its five major components, access the authority's server, and send it the data within the authority, path, and query components. A typical server will take that information, parse the path into segments and the query into key/value pairs, and then invoke implementation-specific handlers to respond to the request."
Since the interpretation of query components resides with the functionality of servers, the intention of this document wrt query components is to recommend standard name-value pair formats for use in addressing media fragments through URI queries. We recommend server and server-type software providers to harmonize their existing schemes in use with media resources to support the nomenclature proposed in this specification.
Editorial note | |
This section is non-normative |
To address a media fragment, one needs to find ways to convey the fragment information. This specification builds on URIs RFC 3986. Every URI is defined as consisting of four parts, as follows:
<scheme name> : <hierarchical part> [ ? <query> ] [ # <fragment> ]
There are therefore two possibilities for representing the media fragment addressing in URIs: the URI query part or the URI fragment part.
For media fragment addressing, both approaches - URI query and URI fragment - are useful.
There are different types of media fragment addressing in this specification. As noted in the Use cases and requirements for Media Fragments document (section "Fitness Conditions on Media Containers/Resources"): not all container formats and codecs are "fit" for supporting the different types of fragment URIs. "Fitness" relates to the fact that a media fragment can be extracted from the primary resource without syntax element modifications or transcoding of the bitstream.
Resources that are "fit" can therefore be addressed with a URI fragment. Resources that are "conditionally fit" can be addressed with a URI fragment with an additional retrieval action that retrieves the modified syntax elements but leaves the codec data untouched. Resources that are "unfit" require transcoding. Such transcoded media fragments cannot be addressed with URI fragments, but only with URI queries.
Therefore, when addressing a media fragment with the URI mechanism, the author has to know whether this media fragment can be produced from the (primary) resource itself without any transcoding activities or whether it requires transcoding. In the latter case, the only choice is to use a URI query and to use a server that supports transcoding and delivery of a (primary) derivative resource to satisfy the query.
Editorial note: Raphael | |
Should we not foresee future "smart" media caches that would be able to actually cache range request in other units than bytes? |
A combination of a URI query for a media fragment with a URI fragment yields a URI fragment resolution on top of the newly created resource. Since a URI with a query part creates a new resource, we have to do the fragment offset on the new resource. This is simply a conformant behaviour to the URI standard RFC 3986.
For example, http://www.example.org/video.ogv?t=60,100#t=20
will lead to the 20s fragment offset being applied to the new
resource starting at 60 going to 100. Thus, the reply to this is a 40s long resource whose playback will start at an offset of 20s.
Editorial note: Silvia | |
We should at the end of the document set up a table with all the different addressing types and http headers and say what we deem is conformant and how to find out whether a server or user agent is conformant or not. |
Guiding principles for the definition of the media fragments syntax were as follows:
Here are some examples of URIs with name-value pairs, to demonstrate the general structure:
This ABNF syntax defines the structure of media fragment URI components.
Media fragments support fragmenting the media along four dimensions:
this dimension denotes a named section of the original media, such as "chapter 2".
Editorial note: Philip | |
We need to decide what do with this and validity. One suggested option has been to require non-MF extensions to use a vendor prefix. |
The name dimension cannot be combined with the other dimensions, because the semantics depend on the underlying source media format: some media formats support naming of temporal extents, others support naming of groups of tracks, etc. Error semantics are discussed in 6 Media Fragments Semantics.
A conformant server or user agent will need to be able to parse a random URI query or fragment string for a media resource and identify the relevant parts. E.g. the relevant field-value pair out of a media fragment URI like this http://www.example.com/video.ogv#&&=&=tom;jerry=&t=34&t=meow:0#
is t=34
.
A specification of the parsing algorithm to extract these from an actual URI can be found in D.1 Processing name-value components and D.2 Processing name-value lists. Note that the URI works on octet strings, but the parsed name-value pairs are unicode strings, since percent-encoding is resolved. The following definitions apply to these unicode strings.
Temporal clipping can be specified either as Normal Play Time (npt) RFC 2326, as SMPTE timecodes, SMPTE, or as real-world clock time (clock) RFC 2326. Begin and end times are always specified in the same format. The format is specified by name, followed by a colon (:
), with npt:
being the default.
In this version of the media fragments specification there is no extensibility mechanism to add time format specifiers.
Normal Play Time can either be specified as seconds, with an optional fractional part to indicate miliseconds, or as colon-separated hours, minutes and seconds (again with an optional fraction). Minutes and seconds must be specified as exactly two digits, hours and fractional seconds can be any number of digits. The hours, minutes and seconds specification for NPT is a convenience only, it does not signal frame accuracy. The specification of the "npt:" identifier is optional since NPT is the default time scheme. This specification builds on the RTSP specification of NPT RFC 2326.
npt-sec = 1*DIGIT [ "." *DIGIT ] ; definitions taken npt-hhmmss = npt-hh ":" npt-mm ":" npt-ss [ "." *DIGIT] ; from RFC 2326 npt-hh = 1*DIGIT ; any positive number npt-mm = 2DIGIT ; 0-59 npt-ss = 2DIGIT ; 0-59 npttimedef = [ deftimeformat ":"] ( npttime [ "," npttime ] ) / ( "," npttime ) deftimeformat = %x6E.70.74 ; "npt" npttime = npt-sec / npt-hhmmss
Examples:
t=npt:10,20 # => results in the time interval [10,20) t=npt:120, # => results in the time interval [120,end) t=npt:,121.5 # => results in the time interval [0,121.5) t=0:02:00,121.5 # => results in the time interval [120,121.5) t=npt:120,0:02:01.5 # => also results in the time interval [120,121.5)
Wall-clock time codes are a way to address real-world clock time that is associated typically with a live video stream. These are the same time codes that are being used by RTSP RFC 2326, by SMIL SMIL, and by HTML5 HTML 5. The scheme uses ISO 8601 UTC timestamps (http://www.iso.org/iso/date_and_time_format). The format separates the date from the time with a "T" character and the string ends with "Z", which includes time zone capabilities. To that effect, the ABNF grammar is referring to RFC 3339, which include the relevant part of ISO 8601 in ABNF form. The time scheme identifier is "clock".
datetime = <date-time, defined in RFC 3339> clocktimedef = clockformat ":"( clocktime [ "," clocktime ] ) / ( "," clocktime ) clockformat = %x63.6C.6F.63.6B ; "clock" clocktime = (datetime / walltime / date) ; WARNING: if your date-time contains '+' (or any other reserved character, per RFC 3986), ; it should be percent-encoded when used in a URI.
For convenience, the definition is copied here
; defined in RFC 3339 ; date-fullyear = 4DIGIT date-month = 2DIGIT ; 01-12 date-mday = 2DIGIT ; 01-28, 01-29, 01-30, 01-31 based on ; month/year time-hour = 2DIGIT ; 00-23 time-minute = 2DIGIT ; 00-59 time-second = 2DIGIT ; 00-58, 00-59, 00-60 based on leap second ; rules time-secfrac = "." 1*DIGIT time-numoffset = ("+" / "-") time-hour ":" time-minute time-offset = "Z" / time-numoffset partial-time = time-hour ":" time-minute ":" time-second [time-secfrac] full-date = date-fullyear "-" date-month "-" date-mday full-time = partial-time time-offset date-time = full-date "T" full-time
Examples:
t=clock:2009-07-26T11:19:01Z,2009-07-26T11:20:01Z # => results in a 1 min interval # on 26th Jul 2009 from 11hrs, 19min, 1sec t=clock:2009-07-26T11:19:01Z # => starts on 26th Jul 2009 from 11hrs, 19min, 1sec t=clock:,2009-07-26T11:20:01Z # => ends on 26th Jul 2009 from 11hrs, 20min, 1sec
As the allowed track names are determined by the original source media, this information has to be known before construction of the media fragment. There is no support for generic media type names (audio, video) across container formats: most container formats allow multiple tracks of each media type, which would lead to ambiguities. Note that there are existing discovery mechanisms for retrieving the track names of a media resource, such as the Rich Open multitrack media Exposition format (ROE) ROE or the Media Annotations API Media Annotations.
Editorial note: Davy | |
We can also reference the HTML5 Media Multitrack API here, when it's mentioned in the HTML5 spec. |
DIGIT = <DIGIT, defined in RFC 4234> pchar = <pchar, defined in RFC 3986> unreserved = <unreserved, defined in RFC 3986> pct-encoded = <pct-encoded, defined in RFC 3986> fragment = <pct-encoded, defined in RFC 3986> utf8string = *( unreserved / pct-encoded ":" / "@" ) ; utf-8 character ; encoded using rfc3896 rules.
This section defines the different exchange scenarios for the different situations explained in section 3 URI fragment and URI query over the HTT¨protocol.
This section defines the protocol steps in HTTP RFC 2616 to resolve and deliver a media fragment specified as a URI fragment.
Editorial note | |
This section is ready to implement. |
As described in section 3.2 Resolving URI fragments within the user agent, the most optimal case is a user agent that knows how to map media fragments to byte ranges. This is the case typically where a user agent has already downloaded those parts of a media resource that allow it to do or guess the mapping, e.g. headers or a resource, or an index of a resource.
In this case, the HTTP exchanges are exactly the same as for any other Web resource where byte ranges are requested RFC 2616.
How the UA retrieves the byte ranges is dependent on the media type of the media resource. We here show examples with only one byte range retrieval per time range, which may in practice turn into several such retrieval actions necessary to acquire the correct time range.
Here are the three principle cases a media fragment enabled UA and a media Server will encounter:
A user requests a media fragment URI:
So, the UA serves the decoded resource to the User our of its existing buffer.
As described in section 3.3 Resolving URI fragments with server help, some User Agents cannot undertake the fragment-to-byte mapping themselves, because the mapping is not obvious. This typically applies to media formats where the setup of the decoding pipeline does not imply knowledge of how to map fragments to byte ranges, e.g. Ogg without OggIndex. Thus, the User Agent would be capable of decoding a continuous resource, but would not know which bytes to request for a media fragment.
In this case, the User Agent could either guess what byte ranges it has to retrieve and the retrieval action would follow the previous case. Or it could hope that the server provides a special service, which would allow it to retrieve the byte ranges with a simple request of the media fragment ranges. Thus, the HTTP request of the User Agent will include a request for the fragment hoping that the server can do the byte range mapping and send back the appropriate byte ranges. This is realized by introducing new dimensions for the HTTP Range header, next to the byte dimension.
The specification for all new Range Request Header dimensions is given through the following ABNF as an extension to the HTTP Range Request Header definition (see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.35.2):
Range = "Range" ":" ranges-specifier ranges-specifier = byte-ranges-specifier | fragment-specifier ; ; note that ranges-specifier is extended from RFC 2616 ; to cover alternate fragment range specifiers ; fragment-specifier = "include-setup" | fragment-range *( "," fragment-range ) [ ";" "include-setup" ] fragment-range = time-ranges-specifier | track-ranges-specifier | name-ranges-specifier ; ; note that this doesn't capture the restriction to one fragment dimension occurring ; maximally once only in the fragment-specifier definition. ; time-ranges-specifier = npttimeoption / smptetimeoption / clocktimeoption npttimeoption = pfxdeftimeformat "=" npt-sec "-" [ npt-sec ] smptetimeoption = pfxsmpteformat "=" frametime "-" [ frametime ] clocktimeoption = pfxclockformat "=" datetime "-" [ datetime ] track-ranges-specifier = trackprefix "=" trackparam *( ";" trackparam ) name-ranges-specifier = nameprefix "=" nameparam
This specification is meant to be analogous to the one in URIs, but it is a bit stricter. The time unit is not optional. For instance, it can be "npt", "smpte", "smpte-25", "smpte-30", "smpte-30-drop" or "clock" for temporal. Where "ntp" is used for a temporal range, only specification in seconds is possible. Where "clocktime" is used for a temporal range, only "datetime" is possible and "walltime" is fully specified in HHMMSS with fraction and full timezone. Indeed, all optional elements in the URI specification basically become required in the Range header.
There is an optional 'include-setup' flag on the fragment range specifier - this flag signals to the server whether delivery of the decoder setup information (i.e. typically file header information) is also required as part of the reply to this request. This can help avoid an extra roundtrip where a Media Fragment URI is, e.g. directly typed into a Web browser.
If there were multiple track parameters provided in the media fragment URI, they are all aggregated together here in a single track ranges specifier, where the track names are separated by semi-colon. Note that if a track name did include a semi-colon in the media fragment URI, it is now percent escaped.
Note that the specification does not foresee a Range dimension for spatial media fragments since they are typically resolved and interpreted by the User Agent (i.e., spatial fragment extraction is not performed on server-side) for the following reasons:
spatial media fragments are typically not expressible in terms of byte ranges. Spatial fragment extraction would thus require transcoding operations resulting in new resources rather than fragments of the original media resource. As described in section 3 URI fragment and URI query, spatial fragment extraction is in this case better represented by URI queries.
When a User Agent receives an extracted spatial media fragment, it is not trivial to visualize the context of this fragment (see also section 7.1 Clients Displaying Media Fragments). More specifically, spatial context requires a meaningful background, which will not be available at the User Agent when the spatial fragment is extracted by the server.
Editorial note: Davy | |
Special attention should be paid for named fragments and more specifically when a named fragment represents a spatial fragment. We should clearly describe 1. what named fragments are and 2. how they are resolved. |
Next to the introduction of new dimensions for the HTTP Range request header, we also introduce a new HTTP response header, called Content-Range-Mapping, which provides the mapping of the retrieved byte range to the original Range request, which was not in bytes. It serves two purposes:
It Indicates the actual mapped range in terms of fragment dimensions. This is necessary since the server might not be able to provide a byte range mapping that corresponds exactly to the requested range. Therefore, the User Agent needs to be aware of this variance.
It provides context information regarding the parent resource in case the Range request contained a temporal dimension. More specifically, the header contains the start and end time of the parent resource. This way, the User Agent is able to understand and visualize the temporal context of the media fragment.
The specification for the Content-Range-Mapping header is based on the specification of the Content-Range header (see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.16) and is shown below. Note that the Content-Range-Mapping header adds in case of the temporal dimension the instance start and end in terms of seconds after a slash "/" character in analogy to the Content-Range header. Also, we introduce an extension to the Accept-Ranges header (see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.5).
The UA has to check if a local copy of the requested fragment is available in its buffer. If it is, we revert back to the processing described in sections 5.1.1.2 UA requests URI fragment it already has buffered and 5.1.1.3 UA requests URI fragment of a changed resource, since the UA already knows the mapping to byte ranges. If the requested fragment is not available in its buffer, the UA sends an HTTP request to the server, including a Range header with temporal dimension. The request is shown below:
UA (1) → Proxy (2) → Origin Server (3):
GET /video.ogv HTTP/1.1 Host: www.example.com Accept: video/* Range: t:npt=10-20
If the server does not understand a Range header, it MUST ignore the header field that includes that range-set. This is in sync to the HTTP RFC RFC 2616. This means that where a server does not support media fragments, the complete resource will be delivered. It also means that we can combine both, byte range and fragment range headers in one request, since the server will only react to the Range header it understands.
Assuming the server can map the given Range to one or more byte ranges, it will reply with these in a 206 HTTP response. Where multiple byte ranges are required to satisfy the Range request, these are transmitted as a multipart message-body. The media type for this purpose is called "multipart/byteranges". This is in sync with the HTTP RFC RFC 2616.
Here is the reply to the example above, assuming a single byte range is sufficient:
Origin Server (3) → Proxy (4) → UA (5):
HTTP/1.1 206 Partial Content Accept-Ranges: bytes, t, track, id Content-Length: 3743 Content-Type: video/ogg Content-Range: bytes 19147-22880/35614993 Content-Range-Mapping: { t:npt 9.85-21.16/0.0-653.79 } = { bytes 19147-22880/35614993 } Etag: "b7a60-21f7111-46f3219476580" {binary data}
Note the presence of the new reply header called Content-Range-Mapping, which provides the mapping of the retrieved byte range to the original Content-Range request, which was not in bytes. As we return both, byte and temporal ranges, the UA and any intermediate caching proxy is enabled to map byte positions with time offsets and fall back to byte range request where the fragment is re-requested. Also note that through the extended list in the Accept-Ranges it is possible to identify which fragment schemes a server supports.
In the case where a media fragment results in a multipart message-body, the Content-Range headers will be spread throughout the binary data ranges, but the Content-Range-Mapping of the media fragment will only be with the main header. Note that requesting track fragments typically result in multipart message-bodies, on condition that the parent resource is characterized by interleaved tracks. For example:
Origin Server (3) → Proxy (4) → UA (5):
HTTP/1.1 206 Partial Content Accept-Ranges: bytes, t, track, id Content-Length: 3743 Content-Type: video/ogg Content-Range-Mapping: { track audio1;video1 } = { bytes 123-2589, 14560-27891,58909-81230/35614993 } Content-type: multipart/byteranges; boundary=THIS_STRING_SEPARATES Etag: "b7a60-21f7111-46f3219476580" --THIS_STRING_SEPARATES Content-type: video/ogg Content-Range: bytes 123-2589/35614993 {binary data} --THIS_STRING_SEPARATES Content-type: video/ogg Content-Range: bytes 14560-27891/35614993 {binary data} --THIS_STRING_SEPARATES Content-type: video/ogg Content-Range: bytes 58909-81230/35614993 {binary data} --THIS_STRING_SEPARATES--
Note that a caching proxy that does not understand a Range header must not cache "206 Partial Content" responses as per HTTP RFC RFC 2616. Thus, the new Range requests won't be cached by legacy Web proxies.
Analogous to section 5.1.2.1 Server mapped byte ranges with corresponding binary data, the server can map the given Range to one or more byte ranges, it will reply with these in a 206 HTTP response. Additionally, the server adds the bytes corresponding with the requested setup information to the response. Since this setup information usually appears in front of a media resource, the response typically results in a multipart message-body. The response is shown below:
Origin Server (3) → Proxy (4) → UA (5):
HTTP/1.1 206 Partial Content Accept-Ranges: bytes, t, track, id Content-Length: 3795 Content-Type: video/ogg Content-Range-Mapping: { t:npt 11.85-21.16/0.0-653.79;include-setup } = { bytes 0-52,19147-22880/35614993 } Content-type: multipart/byteranges; boundary=THIS_STRING_SEPARATES Etag: "b7a60-21f7111-46f3219476580" --THIS_STRING_SEPARATES Content-type: video/ogg Content-Range: bytes 0-52/35614993 {binary data} --THIS_STRING_SEPARATES Content-type: video/ogg Content-Range: bytes 19147-22880/35614993 {binary data} --THIS_STRING_SEPARATES--
Note that the Content-Range-Mapping header indicates that the codec setup information is included in the response. In this example, the response consists of two parts of byte ranges: the first part corresponds to the setup information, the second part corresponds to the requested fragment.
As described in section 3.4 Resolving URI fragments in a proxy cacheable manner, the server mapped byte ranges approach can be extended to play with existing caching Web proxy infrastructure. This is important, since video is a huge bandwidth eater in the current Internet and falling back to using existing Web proxy infrastructure is important, particularly since progressive download and direct access mechanisms for video rely heavily on this functionality. Over time, the proxy infrastructure will learn how to cache media fragment URIs directly as described in the previous section and then will not require this extra effort.
To enable media-fragment-URI-supporting UAs to make their retrieval cacheable, we introduce some extra HTTP headers, which will help tell the server and the proxy what to do. There is an Accept-Range-Redirect request header which signals to the server that only a redirect to the correct byte ranges is necessary and the result should be delivered in the Range-Redirect header.
The ABNF for these additional two HTTP headers is given as follows:
Let's play it through on an example. A user requests a media fragment URI:
The UA has to check if a local copy of the requested fragment is available in its buffer. In our case here, it is not. If it was, we would revert back to the processing described in sections 5.1.1.2 UA requests URI fragment it already has buffered and 5.1.1.3 UA requests URI fragment of a changed resource, since the UA already knows the mapping to byte ranges. The UA issues a HTTP GET request with the fragment and requesting to retrieve just the mapping to byte ranges:
UA (1) → Proxy (2) → Origin Server (3):
GET /video.ogv HTTP/1.1 Host: www.example.com Accept: video/* Range: t:npt=10-20 Accept-Range-Redirect: bytes
The server converts the given time range to a byte range and sends an empty reply that refers the UA to the right byte range for the correct time range.
Origin Server (3) → Proxy (4) → UA (5):
HTTP/1.1 307 Temporary Redirect Location: http://www.example.com/video.ogv Accept-Ranges: bytes, t, track, id Content-Length: 0 Content-Type: video/ogg Content-Range-Mapping: { t:npt 11.85-21.16/0.0-653.79 } = { bytes 19147-22880/* } Range-Redirect: 19147-22880 Vary: Accept-Range-Redirect
Note that codec setup information can also be requested in combination with the Accept-Range-Redirect header, which can be realized by adding the 'include-setup' flag to the Range request header.
The UA proceeds to put the actual fragment request through as a normal byte range request as in section 5.1.1.1 UA requests URI fragment for the first time:
UA (5) → Proxy (6) → Origin Server (7):
GET /video.ogv HTTP/1.1 Host: www.example.com Accept: video/* Range: 19147-22880
The Origin Server puts the data together and sends it to the UA:
Origin Server (7) → Proxy (8) → UA (9):
HTTP/1.1 206 Partial Content Accept-Ranges: bytes, t, track, id Content-Length: 3743 Content-Type: video/ogg Content-Range: bytes 19147-22880/35614993 Etag: "b7a60-21f7111-46f3219476580" {binary data}
The UA decodes the data and displays it from the requested offset. The caching Web proxy in the middle has now cached the byte range, since it adhered to the normal byte range request protocol. All existing caching proxies will work with this. New caching Web proxies may learn to interpret media fragments natively, so won't require the extra packet exchange described in this section.
When a server decides not to serve the requested media fragment in terms of byte ranges (i.e., serving the requested media fragment as specified in section 5.1.2 Server mapped byte ranges), it can redirect the UA to a representation of this fragment (for instance by transforming the media fragment URI into a media fragment query, as specified in section 5.2 Protocol for URI query Resolution in HTTP). This is particularly useful in cases where too many byte ranges would need to e extracted to satisfy the range request.
A user requests a media fragment URI using a URI fragment:
User → UA (1):
http://www.example.com/video.ogv#track=video1
Subsequently, the UA requests the media fragment from the server using the Range header:
UA (1) → Proxy (2) → Origin Server (3):
GET /video.ogv HTTP/1.1 Host: www.example.com Accept: video/* Range: track=video1
The server decides not to serve the requested media fragment in terms of byte ranges (for instance, because the track media fragment results in too many byte ranges). The server redirects the UA to an alternate representation. For example, the URI fragment can be transformed into a URI query. Further, a Link header is added stating that the redirected location is a fragment of the originally requested resource.
Origin Server (3) → Proxy (4) → UA (5):
HTTP/1.1 307 Temporary Redirect Location: http://www.example.com/video.ogv?track=video1 Accept-Ranges: bytes, t, track, id Content-Length: 0 Content-Type: video/ogg Link: <http://www.example.com/video.ogv#track=video1>; rel="fragment" Vary: *
Editorial note: Davy | |
We need to register the 'fragment' Link Relation Web Linking. |
Finally, the UA follows the redirect, which in this case corresponds to the process specified in section 5.2 Protocol for URI query Resolution in HTTP.
The server can also decide to combine a redirect and a media fragment URI:
User → UA (1):
http://www.example.com/video.ogv#track=video1&t=10,20
The UA requests the media fragment to the server using the Range header:
UA (1) → Proxy (2) → Origin Server (3):
GET /video.ogv HTTP/1.1 Host: www.example.com Accept: video/* Range: track=video1,t:npt=10-20
The server decides not to serve the requested media fragment in terms of byte ranges and redirects the UA to an alternate representation. However, in this case, the server decides to handle the track fragment through a URI query and the temporal fragment through a URI fragment:
Origin Server (3) → Proxy (4) → UA (5):
HTTP/1.1 307 Temporary Redirect Location: http://www.example.com/video.ogv?track=video1#t=10,20 Accept-Ranges: bytes, t, track, id Content-Length: 0 Content-Type: video/ogg Link: <http://www.example.com/video.ogv#track=video1&t=10,20>; rel="fragment" Vary: *
Finally, the UA follows the redirect, which in this case corresponds to the process specified in section 5.2 Protocol for URI query Resolution in HTTP for the track fragment, combined with the process specified in section 5.1.2 Server mapped byte ranges for the temporal fragment.
This section describes the protocol steps used in HTTP RFC 2616 to resolve and deliver a media fragment specified as a URI query.
A user requests a media fragment URI using a URI query:
User → UA (1):
http://www.example.com/video.ogv?t=10,20
This is a full resource, so it is a simple HTTP retrieval process. The UA has to check if a local copy of the requested resource is available in its buffer. If yes, it does a conditional GET with e.g. an If-Modified-Since and If-None-Match HTTP header.
Assuming the resource has not been retrieved before, the following is sent to the server:
UA (1) → Proxy (2) → Origin Server (3):
GET /video.ogv?t=10,20 HTTP/1.1 Host: www.example.com Accept: video/*
If the server doesn't understand these query parameters, it typically ignores them and returns the complete resource. This is not a requirement by the URI or the HTTP standard, but the way it is typically implemented in Web browsers.
A media fragment supporting server has to create a complete media resource for the URI query, which in the case of Ogg requires creation of a new resource by adapting the existing Ogg file headers and combining them with the extracted byte range that relates to the given fragment. Some of the codec data may also need to be re-encoded since, e.g. t=10 does not fall clearly on a decoding boundary, but the retrieved resource must match as closely as possible the URI query. This new resource is sent back as a reply:
Origin Server (3) → Proxy (4) → UA (5):
HTTP/1.1 200 OK Content-Length: 3782 Content-Type: video/ogg Etag: "b7a60-21f7111-46f3219476580" Link: <http://www.example.com/video.ogv#t=10,20>; rel="alternate" {binary data}
Note that a Link header MAY be provided indicating the relationship between the requested URI query and the original media fragment URI. This enables the UA to retrieve further information about the original resource, such as its full length. In this case, the user agent is also enable to choose to display the dimensions of the primary resource or the ones created by the query.
The UA serves the decoded resource to the user. Caching in Web proxies works as it has always worked - most modern Web servers and UAs implement a caching strategy for URIs that contain a query using one of the three methods for marking freshness: heuristic freshness analysis, the Cache-Control header, or the Expires header. In this case, many copies of different segments of the original resource video.ogv may end up in proxy caches. An intelligent media proxy in future may devise a strategy to buffer such resources in a more efficient manner, where headers and byte ranges are stored differently.
Further, media fragment URI queries can be extended to enable UAs to use the Range-Redirect HTTP header to also revert back to a byte range request. This is analogous to section 5.1.2.3 Proxy cacheable server mapped byte ranges.
Note that a server that does not support media fragments through either URI fragment or query addressing will return the full resource in either case. It is therefore not possible to first try URI fragment addressing and when that fails to try URI query addressing.
Errors can occur at several levels:
For this, we make the following definitions:
Editorial note: Raphael | |
The following paragraph is controversial since it could lead to non-interoperable implementations. |
Editorial note: Silvia | |
If the UA needs to retrieve a large part of the resource or even the full resource, it will probably decide to make multiple range requests rather than a single one. If the resource is, however, small, it may decide to just retrieve the full resource without a range request. The UA should make this choice given context information, e.g. if it knows that it will be a lot of data, it will retrieve it in smaller chunks. If it chooses to request the full resource in one go and not make use of a Range request, the result will be a 200 rather than a 206. |
The resolved time segment is empty.
Effect: retrieve whatever the browser needs to set up playback, but otherwise nothing
The value resolves to a non-existent fragment.
If the UA is already set up for decoding the resource and it can identify that the fragment is non-existent (i.e. knows about start and end times), it will avoid undertaking an unnecessary retrieval action. Otherwise it will undertake the RANGE retrieval request with the 'include-setup' as specified in section 5.1.2.2 Server mapped byte ranges with corresponding binary data and codec setup data and will receive a 206 with just the setup data. If the UA is set up for decoding, but cannot identify that the fragment is non-existent and does the retrieval action without the 'include-setup', it will result in a 416.
Effect: retrieve whatever the browser needs to set up playback, but otherwise nothing
The value cannot be parsed for the dimension.
If the UA is already set up for decoding the resource, it will identify that the fragment is invalid and avoid undertaking an unnecessary retrieval action. Otherwise it will undertake the RANGE retrieval request with the 'include-setup' as specified in section 5.1.2.2 Server mapped byte ranges with corresponding binary data and codec setup data and will receive a 206 with just the setup data.
Examples:
Effect: retrieve whatever the browser needs to set up playback, but otherwise nothing
Editorial note: Silvia | |
This list still has to be provided. |
; defined in RFC 4234 ALPHA = %x41-5A / %x61-7A ; A-Z / a-z DIGIT = %x30-39 ; 0-9 HEXDIG = DIGIT / "A" / "B" / "C" / "D" / "E" / "F" ; defined in RFC 3986 unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~" pct-encoded = "%" HEXDIG HEXDIG sub-delims = "!" / "$" / "&" / "'" / "(" / ")" / "*" / "+" / "," / ";" / "=" pchar = unreserved / pct-encoded / sub-delims / ":" / "@" ; defined in RFC 2326 npt-sec = 1*DIGIT [ "." *DIGIT ] ; definitions taken npt-hhmmss = npt-hh ":" npt-mm ":" npt-ss [ "." *DIGIT] ; from RFC 2326 npt-hh = 1*DIGIT ; any positive number npt-mm = 2DIGIT ; 0-59 npt-ss = 2DIGIT ; 0-59 ; defined in RFC 3339 date-fullyear = 4DIGIT date-month = 2DIGIT ; 01-12 date-mday = 2DIGIT ; 01-28, 01-29, 01-30, 01-31 based on ; month/year time-hour = 2DIGIT ; 00-23 time-minute = 2DIGIT ; 00-59 time-second = 2DIGIT ; 00-58, 00-59, 00-60 based on leap second ; rules time-secfrac = "." 1*DIGIT time-numoffset = ("+" / "-") time-hour ":" time-minute time-offset = "Z" / time-numoffset partial-time = time-hour ":" time-minute ":" time-second [time-secfrac] full-date = date-fullyear "-" date-month "-" date-mday full-time = partial-time time-offset date-time = full-date "T" full-time ; Mediafragment definitions segment = mediasegment / *( pchar / "/" / "?" ) ; augmented fragment ; definition taken from ; RFC 3986 utf8string = *( unreserved / pct-encoded / ":" / "@" ) ; utf-8 character ; encoded using rfc3896 rules. ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Common Prefixes ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; deftimeformat = %x6E.70.74 ; "npt" pfxdeftimeformat = %x74.3A.6E.70.74 ; "t:npt" smpteformat = %x73.6D.70.74.65 ; "smpte" / %x73.6D.70.74.65.2D.32.35 ; "smpte-25" / %x73.6D.70.74.65.2D.33.30 ; "smpte-30" / %x73.6D.70.74.65.2D.33.30.2D.64.72.6F.70 ; "smpte-30-drop" pfxsmpteformat = %x74.3A.73.6D.70.74.65 ; "t:smpte" / %x74.3A.73.6D.70.74.65.2D.32.35 ; "t:smpte-25" / %x74.3A.73.6D.70.74.65.2D.33.30 ; "t:smpte-30" / %x74.3A.73.6D.70.74.65.2D.33.30.2D.64.72.6F.70 ; "t:smpte-30-drop" clockformat = %x63.6C.6F.63.6B ; "clock" pfxclockformat = %x74.3A.63.6C.6F.63.6B ; "clock" ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Media Segment ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; mediasegment = namesegment / axissegment axissegment = ( timesegment / spacesegment / tracksegment ) *( "&" ( timesegment / spacesegment / tracksegment ) ; ; note that this does not capture the restriction of only one timesegment or spacesegment ; in the axisfragment definition, unless we list explicitely all the cases, ; timesegment = timeprefix "=" timeparam timeprefix = %x74 ; "t" timeparam = npttimedef / smptetimedef / clocktimedef npttimedef = [ deftimeformat ":"] ( npttime [ "," npttime ] ) / ( "," npttime ) npttime = npt-sec / npt-hhmmss smptetimedef = smpteformat ":"( frametime [ "," frametime ] ) / ( "," frametime ) frametime = 1*DIGIT ":" 2DIGIT ":" 2DIGIT [ ":" 2DIGIT [ "." 2DIGIT ] ] clocktimedef = clockformat ":"( clocktime [ "," clocktime ] ) / ( "," clocktime ) clocktime = (datetime / walltime / date) datetime = date-time ; inclusion of RFC 3339 spacesegment = xywhprefix "=" xywhparam xywhprefix = %x78.79.77.68 ; "xywh" xywhparam = [ xywhunit ":" ] 1*DIGIT "," 1*DIGIT "," 1*DIGIT "," 1*DIGIT xywhunit = %x70.69.78.65.6C ; "pixel" / %x70.65.72.63.65.6E.74 ; "percent" tracksegment = trackprefix "=" trackparam trackprefix = %x74.72.61.63.6B ; "track" trackparam = utf8string namesegment = nameprefix "=" nameparam nameprefix = %x69.64 ; "id" nameparam = utf8string
; defined in RFC 2616 CHAR = [any US-ASCII character (octets 0 - 127)] token = 1*[any CHAR except CTLs or separators]` first-byte-pos = 1*DIGIT last-byte-pos = 1*DIGIT bytes-unit = "bytes" range-unit = bytes-unit | other-range-unit byte-range-resp-spec = (first-byte-pos "-" last-byte-pos) Range = "Range" ":" ranges-specifier Accept-Ranges = "Accept-Ranges" ":" acceptable-ranges ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; HTTP Request Headers ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ranges-specifier = byte-ranges-specifier | fragment-specifier ; ; note that ranges-specifier is extended from RFC 2616 ; to cover alternate fragment range specifiers ; fragment-specifier = "include-setup" | fragment-range *( "," fragment-range ) [ ";" "include-setup" ] fragment-range = time-ranges-specifier | track-ranges-specifier | name-ranges-specifier ; ; note that this doesn't capture the restriction to one fragment dimension occurring ; maximally once only in the fragment-specifier definition. ; time-ranges-specifier = timeprefix ":" time-ranges-options time-ranges-options = npttimeoption / smptetimeoption / clocktimeoption npttimeoption = deftimeformat "=" npt-sec "-" [ npt-sec ] smptetimeoption = smpteformat "=" frametime "-" [ frametime ] clocktimeoption = clockformat "=" datetime "-" [ datetime ] track-ranges-specifier = trackprefix "=" trackparam *( ";" trackparam ) name-ranges-specifier = nameprefix "=" nameparam ;; Accept-Range-Redirect = "Accept-Range-Redirect" ":" bytes-unit ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; HTTP Response Headers ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Content-Range-Mapping = "Content-Range-Mapping" ":" '{' ( content-range-mapping-spec [ ";" def-include-setup ] ) / def-include-setup '}' '=' '{' byte-content-range-mapping-spec '}' def-include-setup = %x69.6E.63.6C.75.64.65.2D.73.65.74.75.70 ; "include-setup" byte-range-mapping-spec = bytes-unit SP byte-range-resp-spec *( "," byte-range-resp-spec ) "/" ( instance-length / "*" ) content-range-mapping-spec = time-mapping-spec | track-mapping-spec | name-mapping-spec time-mapping-spec = timeprefix ":" time-mapping-options time-mapping-options = npt-mapping-option / smpte-mapping-option / clock-mapping-option npt-mapping-option = deftimeformat SP npt-sec "-" npt-sec "/" [ npt-sec ] "-" [ npt-sec ] smpte-mapping-option = smpteformat SP frametime "-" frametime "/" [ frametime ] "-" [ frametime ] clock-mapping-option = clockformat SP datetime "-" datetime "/" [ datetime ] "-" [ datetime ] track-mapping-spec = trackprefix SP trackparam *( ";" trackparam ) name-mapping-spec = nameprefix SP nameparam ;; acceptable-ranges = 1#range-unit *( "," 1#range-unit )| "none" ; ; note this does not represent the restriction that range-units can only appear once at most; ; this has also been adapted from RFC 2616 ; to allow multiple range units. ; other-range-unit = token | timeprefix | trackprefix | nameprefix ;; Range-Redirect = "Range-Redirect" ":" byte-range-resp-spec *( "," byte-range-resp-spec )
Editorial note: Raphael | |
To generate a simple figure that shows this processing: URI parsing (percent decoding) => name=value pairs => (rfc2047encoding) HTTP |
To parse a name-value component, perform the following steps:
To decode a percent-encoded string, perform the following steps:
Note that when parsing a name-value component ,the output is well defined for any input. Examples:
input | output | comments |
---|---|---|
"t=1" | [("t", "1")] | simple case |
"t=1&t=2" | [("t", "1"), ("t", "2")] | repeated name |
"a=b=c" | [("a", "b=c")] | "=" in value |
"a&b=c" | [("a", ""), ("b", "c")] | missing value |
"%74=%6ept%3A%310" | [("t", "npt:10")] | unnecssary percent-encoding |
"id=J%E4genstedt&t=1" | [("t", "1")] | invalid percent-encoding (not UTF-8) |
While the algorithms defined in this section are designed to be largely compatible with the parsing of the URI query component in many HTTP server environments, there are incompatible differences that implementors should be aware of:
To convert a name-value list into a set of media fragment dimensions , perform the following steps:
This document is the work of the W3C Media Fragments Working Group. Members of the Working Group are (at the time of writing, and in alphabetical order): Eric Carlson (Apple, Inc.), Michael Hausenblas (DERI Galway at the National University of Ireland, Galway, Ireland), Philip Jägenstedt (Opera Software), Jack Jansen (CWI), Yves Lafon (W3C), Wonsuk Lee (Electronics and Telecommunications Research Institute), Erik Mannens (IBBT), Thierry Michel (W3C/ERCIM), Guillaume (Jean-Louis) Olivrin (Meraka Institute), Soohong Daniel Park (Samsung Electronics Co., Ltd.), Conrad Parker (W3C Invited Experts), Silvia Pfeiffer (W3C Invited Experts), David Singer (Apple, Inc.), Raphaël Troncy (EURECOM), Davy Van Deursen (IBBT),
The people who have contributed to discussions on public-media-fragment@w3.org are also gratefully acknowledged. In particular: Olivier Aubert, Werner Bailer, Pierre-Antoine Champin, Cyril Concolato, Franck Denoual, Martin J. Dürst, Jean Pierre Evain, Ken Harrenstien, Kilroy Hughes, Ryo Kawaguchi, Wim Van Lancker, Véronique Malaisé, Henrik Nordstrom, Yannick Prié, Yves Raimond, Julian Reschke, Sam Sneddon, Felix Sasaki, Jakub Sendor, Philip Taylor, Christian Timmerer, Jorrit Vermeiren, Jeroen Wijering and Munjo Yu.