Comments (8)
Nor is the MediaSource one.
For a promise based API; the use if MediaCapabilities may be more suited.
from webcodecs.
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.
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.
#152 (review) and #213 has lots of background on this.
from webcodecs.
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.
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.
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.
Let's close this.
from webcodecs.
Related Issues (20)
- Receiving Uncompressed Webcam Data without Browser Compression HOT 5
- After how many decode should the codec process the frames? HOT 10
- Clarify `reset()` behaviour when multiple things are being output HOT 3
- key-frame request handling when scalability mode is not L1T1 for encoder HOT 6
- Clarify the `Clone configuration` algorithm HOT 4
- Figure out what should happen to the unused bits in 10-bits and 12-bits pixel formats
- Rephrase non-normative uses of RFC2119 keywords HOT 1
- Web Audio API compatibility HOT 1
- Assign VideoFrame resource to [[resource reference]] in BufferSource constructor HOT 4
- VideoFrameBufferInit metadata field missing
- sourceWidthBytes from sampleWidth, not sampleHeight
- Vekil
- Sporadic build failures HOT 4
- Define scope for w3c candidate recommendation HOT 3
- Candidate Recommendation tracking issue
- VideoFrame copyTo() behavior with non-RGBA/RGBX/BGRA/BGRX formats HOT 1
- VideoPixelFormat enum values do not follow casing rule guidelines HOT 2
- EncodedAudioChunkInit should probably also support AllowSharedBufferSource HOT 1
- Issue
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from webcodecs.