Skip to content

WebCodecs API #175

Closed
Closed

Description

@BearCooder

Description

The WebCodecs API gives web developers low-level access to the individual frames of a video stream and chunks of audio. It is useful for web applications that require full control over the way media is processed. For example, video or audio editors, and video conferencing.

Source

Read more in this web dev article

Rationale

There are several online editors for editing and processing audio and video files on the internet these days. Such websites eliminate the need for downloading and installing heavy-duty software on your computer. All you need to do is search for online editing tools, and Google will provide you with all the websites providing this service.

From the programmer’s perspective, building such web applications can be difficult. There are a lot of features that they need to implement to make a functional online video editor. And without a doubt, APIs will come into play.

WebCodecs API is a powerful web API that lets developers access the individual frames of a video. It also helps developers to encode and decode audio and video files. It does all this by working on a separate thread. This way, the site responsiveness is not compromised by the processing load.

The API provides access to a lot of features, for instance,

  • Raw video frames
    
  • Image decoder
    
  • Audio/Video encoders and decoders
    
  • Audio data
    

The WebCodecs API is under the hood used by several other APIs. For instance, Web Audio API, MediaRecoder API, WebRTC API, etc., all use WebCodecs for processing audio and video.

The WebCodecs API consists of a lot of different interfaces, but almost all of them are not supported by Firefox and Safari.

Specification

W3C

Tests

No response

Activity

  1. added this to the milestone on Oct 2, 2022
  2. foolip commented on Oct 3, 2022

    @foolip
    Member

    Tests are here: https://wpt.fyi/results/webcodecs

    The tests were written mainly by @dalecurtis @Djuffin @sandersdan @tguilbert-google @chcunningham. Can any of you say something about how complete this test suite currently is?

  3. sandersdan commented on Oct 3, 2022

    @sandersdan

    The test suite does not test every single specified detail; the spec is flexible enough that it is difficult to do so. It was mostly developed in parallel with Chrome's implementation, so there is substantial coverage, but there may also be a few Chrome-isms that slipped in.

  4. dalecurtis commented on Oct 3, 2022

    @dalecurtis

    I feel it's pretty robust. We tried to add tests for every feature or corner case of the API during development. @padenot indicated it was working pretty well for Mozilla so far. Any feedback you want to add Paul?

    That said, there are some gaps in interop between various potentially hardware accelerated features like canvas, hardware decoding, hardware backed capture and how they interact with VideoFrame and the decoders, encoders.

    Unfortunately Chromium's WPT system isn't running on systems with GPU backing, so we had to write those tests in a different framework (called GPU tests in Chromium). Basic tests exist in the wpt suite, but different hardware can make all the difference in some cases. I think this is just a limitation of Chromium's WPT setup, so we could port them from the mix of js/python/pixel_difference_harness that they use currently to wpt. @Djuffin who knows more here.

  5. padenot commented on Oct 6, 2022

    @padenot

    We're still in early implementation, and we're adding tests when we see things missing, and plan to continue adding tests, but generally they've been useful.

  6. moved this to Proposed in Interop 2023on Oct 7, 2022
  7. removed this from the milestone on Oct 7, 2022
  8. foolip commented on Nov 11, 2022

    @foolip
    Member

    In the MDN short survey on APIs & JavaScript, "Web Codecs (AudioDecoder, VideoDecoder, etc.)" was selected by ~21% of survey takers, putting it in the top third of options. (There is some uncertainty as with any survey data.)

  9. gsnedders commented on Nov 30, 2022

    @gsnedders
    Member

    We said in the last meeting we'd take a closer look at this.

    We believe the vast majority of developer interest here is for the video APIs (i.e., VideoDecoder, VideoEncoder, EncodedVideoChunk, VideoFrame, and VideoColorSpace), and as such we'd rather the scope of the focus area be defined as those (i.e., excluding image and audio decoder/encoders). As I understand it, there are negligible performance benefits in the case of audio and images, and it doesn't provide any additional functionality, albeit it does provide them with a cleaner API.

  10. AshleyScirra commented on Nov 30, 2022

    @AshleyScirra

    FWIW, the WebCodecs ImageDecoder provides a way to split animated images (e.g. GIF, APNG) in to separate frames, and the audio encoders allow faster-than-realtime encoding, both of which are not easily possible with other APIs and are important to us.

  11. dalecurtis commented on Nov 30, 2022

    @dalecurtis

    +1 to @AshleyScirra's comment plus some clarifying points for ImageDecoder:

    • AFAIK there's actually no other way on the web platform to extract frames from an animated image short of WASM; by spec drawImage/texImage/createImageBitmap always use the first frame (I was also surprised).
    • By the numbers ImageDecoder has more usage than the other APIs (Google Docs being the largest user).

    I agree the audio parts are less used at this time, though all RTC related developers have expressed interest. However, until about a month ago the APIs lacked the necessary RTC knobs:

  12. youennf commented on Dec 5, 2022

    @youennf

    I do not dispute the usefulness of all WebCodec features.
    AIUI, WebCodecs video support is enabling applications that are simply not possible otherwise(say HD support where WASM is not an option). It does not seem to be the case for the other parts of WebCodecs.
    Hence the proposal to make video higher priority/make short term efforts on testing/ensuring WebCodecs video conformance.
    The other WebCodec parts could then follow.

  13. added
    accepted
    on Feb 1, 2023
  14. nairnandu commented on Feb 1, 2023

    @nairnandu
    Contributor

    Thank you for proposing WebCodecs API for inclusion in Interop 2023.

    We are pleased to let you know that this proposal was accepted as part of the Web Codecs (video) focus area. You can follow the progress of this Focus Area on the Interop 2023 dashboard.

    For an overview of our process, see the proposal selection summary. Thank you for contributing to Interop 2023!

    Posted on behalf of the Interop team.

  15. dalecurtis commented on Feb 3, 2023

    @dalecurtis

    Thanks! I worked on this over at https://bugs.chromium.org/p/chromium/issues/detail?id=1412203 -- when 112 releases to dev channel we should be at 100% on the Chromium side.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    acceptedfocus-area-proposal

    Type

    No type

    Projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions