GithubHelp home page GithubHelp logo

Comments (8)

jyavenard avatar jyavenard commented on August 22, 2024

Nor is the MediaSource one.

For a promise based API; the use if MediaCapabilities may be more suited.

from webcodecs.

padenot avatar padenot commented on August 22, 2024

The reasoning behind this is that the Web Codecs version (especially for the video side of things) goes much more in depth (and isn't based on the mime type alone), and provides an authoritative answer based on the current characteristics of the host, that can change over time (so it isn't generally possible to add a caching layer to avoid system calls, things we'd usually do to avoid speccing an async method).

An example would be:

let videoCharacteristics = { 
  codec: "avc1.64001e',
  width: 3840,
  height: 2160,
  framerate: 60,
  hardwareAcceleration: "prefer-hardware"
};
VideoEncoder.isTypeSupported().then(s => {
  console.log(s.supported);
});

which is a reasonable thing to ask: can the browser encode h264 high profile, 4k at 60Hz in hardware (as to not strain the CPU because the developer knows full well that the input frames will be already on the GPU).

This can return positively, and a minute later, this can return negatively because e.g. the GPU that did support encoding with those characteristics has been unplugged.

MediaCapabilities can also more or less answer this question (and is async for the same reasons), but is one API level higher: it deals in terms of webrtc, recording, talks about power efficiency, smoothness. Those are not relevant for the Web Codecs user who wants to know if a VideoEncoder.configure(...) will succeed without having to attempt to initialize a temporary VideoEncoder.

Besides, as shown in implementation today, the set of codecs supported by Web Codecs and other APIs is different.

HTMLMediaElement, including MediaSource are at the top of the API abstraction level and are playback-only anyway.

from webcodecs.

annevk avatar annevk commented on August 22, 2024

Okay, but the video one is called isConfigSupported() if I understand it correctly. This method is called isTypeSupported() and only takes a MIME type (as a string).

I was looking at whatwg/html#6324 which wants a "simple" MIME type-based query as well and it made me wonder how this one would be different.

from webcodecs.

padenot avatar padenot commented on August 22, 2024

#152 (review) and #213 has lots of background on this.

from webcodecs.

jyavenard avatar jyavenard commented on August 22, 2024

and provides an authoritative answer based on the current characteristics of the host, that can change over time (so it isn't generally possible to add a caching layer to avoid system calls, things we'd usually do to avoid speccing an async method).

But by the time the promise is resolved, the answer may already be obsolete regardless. So using a promise or a sync call do not resolve the issue that By the time you create the encoder, those characteristics may no longer be supported for the incoming encoder.

from webcodecs.

padenot avatar padenot commented on August 22, 2024

This is not a problem that can be solved by a specification, only at the application level by handling failures, that are to be expected. The promise allows getting the best info possible in this dynamic environment, the sync version doesn't.

https://w3c.github.io/webcodecs/#config-support mentions this.

from webcodecs.

dalecurtis avatar dalecurtis commented on August 22, 2024

As background, canPlayType() has always been a pain to implement due to its synchronous nature. In Chrome, it requires blocking / synchronous coordination between 2+ processes on the render thread to answer authoritatively. I'm strongly against ever shipping any synchronous media detection API in any form again.

from webcodecs.

padenot avatar padenot commented on August 22, 2024

Let's close this.

from webcodecs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.