The HTML Media Capture specification defines an HTML form extension that facilitates user access to a device's media capture mechanism, such as a camera, or microphone, from within a file upload control.

There have been no substantive changes since the W3C W3C Last Call Working Draft 19 June 2014.

The CR exit criterion is two interoperable deployed implementations of each feature. No features are marked as 'at-risk'. The group will create an Implementation Report.

Introduction

The HTML Media Capture specification extends the HTMLInputElement interface with a capture attribute. The capture attribute allows authors to declaratively request use of a media capture mechanism, such as a camera or microphone, from within a file upload control, for capturing media on the spot.

This extension is specifically designed to be simple and declarative, and covers a subset of the media capture functionality of the web platform. Specifically, the extension does not provide detailed author control over capture. Use cases requiring more fine-grained author control may be met by using another specification, Media Capture and Streams [[GETUSERMEDIA]]. For example, access to real-time media streams from the hosting device is out of scope for this specification.

This specification defines conformance criteria that apply to a single product: the user agent that implements the interfaces that it contains.

Implementations that use ECMAScript to implement the APIs defined in this specification must implement them in a manner consistent with the ECMAScript Bindings defined in the Web IDL specification [[!WEBIDL]], as this specification uses that specification and terminology.

Terminology

The input element, HTMLInputElement interface, accept attribute, and File Upload state are defined in [[!HTML5]].

The FileList interface is defined in [[FILE-API]].

The term boolean attribute and the concept reflect are defined in [[!HTML5]].

In this specification, the term capture control type refers to a specialized type of a file picker control that is optimized, for the user, for directly capturing media of a MIME type specified by the accept attribute, using a media capture mechanism.

The term media capture mechanism refers to a device's local media capture device, such as a camera or microphone.

Security and privacy considerations

A User Agent implementation of this specification is advised to seek user consent before initiating capture of content by microphone or camera. This may be necessary to meet regulatory, legal and best practice requirements related to the privacy of user data. In addition, the User Agent implementation is advised to provide an indication to the user when an input device is enabled and make it possible for the user to terminate such capture. Similarly, the User Agent is advised to offer user control, such as to allow the user to:

This specification builds upon the security and privacy protections provided by the <input type="file"> [[HTML5]] and the [[FILE-API]] specifications; in particular, it is expected that any offer to start capturing content from the user’s device would require a specific user interaction on an HTML element that is entirely controlled by the user agent.

Implementors should take care to prevent additional leakage of privacy-sensitive data from captured media. For instance, embedding the user’s location in the metadata of captured media (e.g. EXIF) might transmit more private data than the user is expecting.

The capture attribute

This section is normative.

When an input element's type attribute is in the File Upload state, and its accept attribute is specified, the rules in this section apply.

        partial interface HTMLInputElement {
            [CEReactions] attribute boolean capture;
        };
      

The capture attribute is a boolean attribute that, if specified, indicates that the capture of media directly from the device's environment using a media capture mechanism is preferred.

The capture IDL attribute MUST reflect the respective content attribute of the same name.

When the capture attribute is specified, the user agent SHOULD invoke a file picker of the specific capture control type.

When the capture attribute is specified, the user agent MUST NOT save the captured media to any data storage, local or remote.

When scripts gain access to the files selected from the file picker (represented by a FileList object), they can use various mechanisms to store the captured media. These mechanisms are out of scope for this specification.

If the accept attribute's value is set to a MIME type that has no associated capture control type, the user agent MUST act as if there was no capture attribute.

Examples

The following examples demonstrate how to give hints that it is preferred for the user to capture media of a specific MIME type using the media capture capabilities of the hosting device. Both a simple declarative example using an HTML form, as well as a more advanced example including scripting, are presented.

When an input element's accept attribute is set to image/* and the capture attribute is specified as in the Example 1 or Example 4, the file picker may render as presented on the right side. When the attribute is not specified, the file picker may render as represented on the left side.

A File picker control in the File Upload (left) and Image Capture state (right).