Please refer to the errata for this document, which may include normative corrections.
See also translations.
Copyright © 2012 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 is the Recommendation of the Media Fragments URI 1.0 (basic) specification. It has been produced by the Media Fragments Working Group, which is part of the W3C Video on the Web Activity. W3C publishes a technical report as a Recommendation to indicate that the document is believed to be stable, and to encourage implementation by the developer community.
If you wish to make comments regarding this document, please send them to [email protected] mailing list ( public archive).
Only editorial changes were made as a result of the Proposed Recommendation phase (See diff). An implementation report is available.
This document has been reviewed by W3C Members, by software developers, and by other W3C groups and interested parties, and is endorsed by the Director as a W3C Recommendation. It is a stable document and may be used as reference material or cited from another document. W3C's role in making the Recommendation is to draw attention to the specification and to promote its widespread deployment. This enhances the functionality and interoperability of the Web.
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 queries
3.4 Combining URI fragments and URI queries
4 Media Fragments Syntax
4.1 General Structure
4.2 Fragment Dimensions
4.2.1 Temporal Dimension
4.2.2 Spatial Dimension
5 Media Fragments Processing
5.1 Processing Media Fragment URI
5.1.1 Processing name-value components
5.1.2 Processing name-value lists
5.2 Protocol for URI fragment and query resolution in HTTP
6 Media Fragments Semantics
6.1 Valid Media Fragment URIs
6.1.1 Valid temporal dimension
6.1.2 Valid spatial dimension
6.2 Errors detectable based on the URI syntax
6.2.1 Errors on the general URI level
6.2.2 Errors on the temporal dimension
6.2.3 Errors on the spatial dimension
6.3 Errors detectable based on information of the source media
6.3.1 Errors on the general level
6.3.2 Errors on the temporal dimension
6.3.3 Errors on the spatial dimension
7 Notes to Implementors (non-normative)
7.1 Browsers Rendering Media Fragments
7.2 Clients Displaying Media Fragments
7.3 All Media Fragment Clients
7.4 Media Fragment Servers
7.5 Media Fragment Web Applications
A References
B Collected ABNF Syntax for URI (Non-Normative)
C Acknowledgements (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 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.
The registration of URI fragment construction rules, as expressed in Section 4.11 of RFC 4288, is a SHOULD-requirement. The Media Fragment Working Group has no authority to update registries of all targeted media types. An analysis of all media type registrations showed that only a few media type registration in the audio/*, image/*, video/* branches are currently defining fragments or fragment semantics (see for example the fragment definition for SVG in SVG 1.1, chapter 17). 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 with respect to 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.
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.
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.
For user agents that natively support the media fragment syntax, but have to use their own seeking approach, a complementary specification provides an optimisation that can make the byte offset seeking more efficient. It requires a conformant server with which the user agent will follow a protocol defined in the separate Media Fragments 1.0 URI (advanced) document where the user agent asks the server to do the byte range mapping for the media fragment address itself and send back the appropriate byte ranges. This approach can not be done through the URI, but has to be done through adding protocol headers. User agents that interact with a conformant server to follow this protocol will receive the appropriate byte ranges directly and will not need to do costly seeking over the network.
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.
The names and values can be arbitrary Unicode strings, encoded in UTF-8 and percent-encoded as per RFC 3986. Here are some examples of URIs with name-value pairs in the fragment component, to demonstrate the general structure:
http://www.example.com/example.ogv#t=10,20 http://www.example.com/example.ogv#track=audio&t=10,20 http://www.example.com/example.ogv#id=Cap%C3%ADtulo%202
While arbitrary name-value pairs can be encoded in this manner, this specification defines a fixed set of dimensions. The dimension keyword name is encoded in the name component, while dimension-specific syntax is encoded in the value component.
Section 5.1.1 Processing name-value components defines in more detail how to process the name-value pair syntax, arriving at a list of name-value Unicode string pairs. The syntax definitions in 4.2 Fragment Dimensions apply to these Unicode strings.
Media fragments support addressing the media along two dimensions (in the basic version):
Media fragments support also addressing the media along two additional dimensions (in the advanced version defined in Media Fragments 1.0 URI (advanced)):
this dimension denotes one or more tracks in the original media, such as "the english audio and the video track";
this dimension denotes a named temporal fragment within the original media, such as "chapter 2", and can be seen as a convenient way of specifying a temporal fragment.
All dimensions are logically independent and can be combined. The outcome is independent of the order of the dimensions. The id
dimension is however a shortcut for the temporal dimension and combining both dimensions need to be treated as described in section 6.2.1 Errors on the general URI level. The track
dimension refers to one of a set of parallel media streams (e.g. "the english audio track for a video"), not to a (possibly self-contained) section of the source media (e.g. "Audio track 2 of a CD").
Temporal clipping is specified as Normal Play Time (npt) RFC 2326. It can also be specified as SMPTE timecodes SMPTE or as real-world clock time (clock) RFC 2326 in the advanced version described in the Media Fragments 1.0 URI (advanced) document. 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-mmss = npt-mm ":" npt-ss [ "." *DIGIT] 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-mmss / npt-hhmmss
Examples:
t=npt:10,20 # => results in the time interval [10,20) 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)
This section defines the different exchange scenarios for the situations explained in section 3 URI fragment and URI query over the HTTP protocol.
The formal grammar defined in the section 4 Media Fragments Syntax describes what producers of media fragment should output. It is not taking into account possible percent-encoding that are valid according to RFC 3986 and the grammar is not a specification of how a media fragment should be parsed. Therefore, section 5.1 Processing Media Fragment URI defines how to parse media fragment URIs.
This sections defines how to parse media fragment URIs defined in section 4 Media Fragments Syntax, along with notes on some of the caveats to be aware of. Implementors are free to use any equivalent technique(s).
Parse the octet string according to the namevalues syntax, yielding a list of name-value pairs, where name and value are both octet string. In accordance with RFC 3986, the name and value components must be parsed and separated before percent-encoded octets are decoded.
For each name-value pair:
Decode percent-encoded octets in name and value as defined by RFC 3986. If either name or value are not valid percent-encoded strings, then remove the name-value pair from the list.
Convert name and value to Unicode strings by interpreting them as UTF-8. If either name or value are not valid UTF-8 strings, then remove the name-value pair from the list.
Note that the output is well defined for any input.
Examples:
Input | Output | Notes |
---|---|---|
"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=%xy&t=1" | [("t", "1")] | invalid percent-encoding |
"id=%E4r&t=1" | [("t", "1")] | invalid UTF-8 |
While the processing defined in this section is 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:
"&" is the only primary separator for name-value pairs, but some server-side languages also treat ";" as a separator.
name-value pairs with invalid percent-encoding should be ignored, but some server-side languages silently mask such errors.
The "+" character should not be treated specially, but some server-side languages replace it with a space (" ") character.
Multiple occurrences of the same name must be preserved, but some server-side languages only preserve the last occurrence.
Given the dimensions defined in section 4.2 Fragment Dimensions, each has a pair of production rules that corresponds to the name and value component respectively:
Keyword | Dimension |
---|---|
t | 4.2.1 Temporal Dimension |
xywh | 4.2.2 Spatial Dimension |
track | Media Fragments 1.0 URI (advanced) |
id | Media Fragments 1.0 URI (advanced) |
Initially, all dimensions are undefined.
For each name-value pair:
If name matches a keyword in the above table, interpret value as per the corresponding section.
Otherwise, the name-value pair does not represent a media fragment dimension. Validators should emit a warning. User agents must ignore the name-value pair.
Note: Because the name-value pairs are processed in order, the last valid occurence of any dimension is the one that is used.
For each dimension, a number of valid media fragments and their semantics are presented.
To describe the different cases for temporal media fragments, we make the following definitions:
Further, as stated in section 4.2.1 Temporal Dimension, temporal intervals are half-open (i.e. the begin time is considered part of the interval whereas the end time is considered to be the first time point that is not part of the interval). Thus, if we state below that "the media is played from x to y", this means that the frame corresponding to y will not be played.
For t=a,b with a <= b, the following temporal fragments are valid:
To describe the different cases for spatial media fragments, we make the following definitions:
The following spatial fragments are valid:
t
, xywh
, track
and id
) are considered as known dimensions. All other dimensions are considered as unknown. Unknown dimensions SHOULD be ignored by the user agent.track
dimension is an exception to this rule: multiple track dimensions are allowed (e.g. #track=1&track=2 selects both tracks 1 and 2).id
dimension combined with a temporal dimension results in multiple occurrences of the temporal dimension (see previous item).To describe the different cases for temporal media fragments, we use the definitions from 6.1.1 Valid temporal dimension. The invalidity of the following temporal fragments can only be detected by the user agent if it knows the duration (for non-existent temporal fragments) and the frame rate of the source media.
e
.e
.To describe the different cases for spatial media fragments, we use the definitions from 6.1.2 Valid spatial dimension. The invalidity of the following spatial fragments can only be detected by the user agent if it knows the resolution of the source media.
The sub-sections are not mutually exclusive. Hence, an implementer of a web browser as a media fragment client should read the sections 7.1 Browsers Rendering Media Fragments, 7.2 Clients Displaying Media Fragments and 7.3 All Media Fragment Clients.
The pixel coordinates defined in the section 4.2.2 Spatial Dimension are intended to be identical to the intrinsic width and height defined in HTML5. For spatial URI fragments, the next section describes two distinct use cases, highlighting and cropping. HTML rendering clients, however, are expected to implement cropping as the default rendering mechanism.
unichar = <any Unicode code point> unistring = *unichar ; defined in RFC 5234 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 / ":" / "@" fragment = *( pchar / "/" / "?" ) ; defined in RFC 2326 npt-sec = 1*DIGIT [ "." *DIGIT ] ; definitions taken npt-hhmmss = npt-hh ":" npt-mm ":" npt-ss [ "." *DIGIT] ; from RFC 2326 npt-mmss = npt-mm ":" npt-ss [ "." *DIGIT] 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 ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 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 = ( timesegment / spacesegment / tracksegment / idsegment ) *( "&" ( timesegment / spacesegment / tracksegment / idsegment ) timesegment = timeprefix "=" timeparam timeprefix = %x74 ; "t" timeparam = npttimedef / smptetimedef / clocktimedef npttimedef = [ deftimeformat ":"] ( npttime [ "," npttime ] ) / ( "," npttime ) npttime = npt-sec / npt-mmss / 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 = unistring idsegment = idprefix "=" idparam idprefix = %x69.64 ; "id" idparam = unistring
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.), Chris Double (Mozilla Foundation), Michael Hausenblas (DERI Galway at the National University of Ireland, Galway, Ireland), Jack Jansen (CWI), Philip Jägenstedt (Opera Software), Yves Lafon (W3C), 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), Nobuhisa Shiraishi (NEC Corporation), David Singer (Apple, Inc.), Thomas Steiner (Google, Inc.), Raphaël Troncy (EURECOM), Davy Van Deursen (IBBT),
The people who have contributed to discussions on [email protected] are also gratefully acknowledged. In particular: Olivier Aubert, Werner Bailer, Tobias Bürger, Pierre-Antoine Champin, Cyril Concolato, Fantasai, Franck Denoual, Martin J. Dürst, Jean Pierre Evain, Ken Harrenstien, Kilroy Hughes, Ryo Kawaguchi, Wim Van Lancker, Véronique Malaisé, Henrik Nordstrom, Christoph Päper, Yannick Prié, Yves Raimond, Julian Reschke, Sam Sneddon, Felix Sasaki, Jakub Sendor, Philip Taylor, Christian Timmerer, Jorrit Vermeiren, Jeroen Wijering, Munjo Yu and Boris Zbarsky.