You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add optimizeForLatency boolean flag to VideoDecoderConfig. #206
Some software decoders are optimized for throughput rather than latency via frame threading. We should provide a hint that a client prefers lower latency versus throughput.
Without this hint some configurations would require a client to call flush() after every decode() call to ensure they get a frame.
this is clear enough and not overly long, I think. I also like lowDelay.
Taking a step back, there are going to be lots of configurable switches, codec-specific settings and all that in the registry, but this is such an important, common and well understood switch that (I think) it makes sense to have something non-codec-specific.
I'd lean towards lowDelay then. The reason I originally went with optimizeForLatency is that lowDelay and lowLatency don't quite covey the best effort nature of the request. I.e., we don't always have any lee-way with hardware decoders. Would you expect this to be best-effort or should we force software in cases where we aren't sure we can make this guarantee?
Forcing software seems hard, since what hardware decoder can make guarantee this or not is likely a long-tail list.
Would you expect this to be best-effort or should we force software in cases where we aren't sure we can make this guarantee?
I'm torn, here is how I see things:
Authors can have this information, by using isConfigSupported and "require""deny" for hardware acceleration, with this new flag passed in, so advanced users that really know what they are doing can always be very specific (which I think is the minimum we can do for a low level API aimed at advanced users), if we make this "non-best-effort". I assume that if a particular set of parameter for isConfigSupported is accepted, then the decoding will be able to proceed as such, and not modified. Similarly, if even in software it's not possible to do low-latency (I seem to recall this to be a thing, but I'm not sure), it's best to be explicit, some use-cases really do require low-latency decoding.
This is when the fact that the hardware/software decoder can't do low-latency is known (then we can discuss on what the meaning of low-latency is, I guess, that's an orthogonal issue).
There is also the case where going low latency requires a software decoder, but the software decoder cannot do enough fps for the video to be useful in real-time (I'm thinking those Windows 10 laptops based on ARM, that can do vp9 without any issue in hardware but struggle doing it in software, where it's barely possible if at all). So then what should be the answer? Maybe we do want to add something to MediaCapabilities, where the API shape lends itself a bit more to this kind of assessment.
So yes, I guess this is hard, but it's possible, so not doing it when it's better to do it is hard to justify, when it unlocks a very clear and measurable benefit for developers and users.
Interesting. I like the idea of using isConfigSupported but am wary of using an in-UA-test for this since it seems counter to the low level nature of the API. I.e., if this were a native app I'd expect it should use the API to test support on its own for something that can't be answered without a decoding test. I agree that MediaCapabilities feels like a better home for such questions.
Additionally, I think we do have to stray a bit into what low latency means unfortunately :) Nominally I think we're both using it to mean 1-in-1-out, but that behavior can be stream dependent (e.g., b-frames can preclude this behavior). So adding a UA test which just checks a curated stream may be not be the answer an author is looking for.
As such I'm inclined to consider this best effort and ignore it during isConfigSupported.
I agree with what @dalecurtis said in his last comment. I think we need something somewhere that authors can query to have high level info. @chcunningham mentioned during the editor call yesterday that he had the feeling that MediaCapabilities were too high level, but I think it might well just be fine. We can discuss it as a follow-up.
There is always the possibility to log a developer console message or something ("optimizeForLowLatency" requested but the bytestream contains b-frames).
Activity
padenot commentedon Apr 30, 2021
Fully agree. To some extent, this is also related to software vs. hardware encoder choice in common setups.
chcunningham commentedon Apr 30, 2021
Editors call: concept looks good. @padenot @aboba : pls bikeshed on name w/ priority
dalecurtis commentedon Apr 30, 2021
Bike shed colors:
I don't have any strong preference. We call it low delay mode internally.
marcello3d commentedon Apr 30, 2021
AudioContext calls it "latencyHint": https://developer.mozilla.org/en-US/docs/Web/API/AudioContextOptions/latencyHint
dalecurtis commentedon Apr 30, 2021
Yeah we also have https://github.com/WICG/media-latency-hint/blob/main/explainer.md but I think those are slightly different than what we're trying to convey here.
padenot commentedon May 3, 2021
this is clear enough and not overly long, I think. I also like
lowDelay.Taking a step back, there are going to be lots of configurable switches, codec-specific settings and all that in the registry, but this is such an important, common and well understood switch that (I think) it makes sense to have something non-codec-specific.
dalecurtis commentedon May 3, 2021
I'd lean towards
lowDelaythen. The reason I originally went withoptimizeForLatencyis thatlowDelayandlowLatencydon't quite covey the best effort nature of the request. I.e., we don't always have any lee-way with hardware decoders. Would you expect this to be best-effort or should we force software in cases where we aren't sure we can make this guarantee?Forcing software seems hard, since what hardware decoder can make guarantee this or not is likely a long-tail list.
padenot commentedon May 4, 2021
I'm torn, here is how I see things:
Authors can have this information, by using
isConfigSupportedand"require""deny"for hardware acceleration, with this new flag passed in, so advanced users that really know what they are doing can always be very specific (which I think is the minimum we can do for a low level API aimed at advanced users), if we make this "non-best-effort". I assume that if a particular set of parameter forisConfigSupportedis accepted, then the decoding will be able to proceed as such, and not modified. Similarly, if even in software it's not possible to do low-latency (I seem to recall this to be a thing, but I'm not sure), it's best to be explicit, some use-cases really do require low-latency decoding.This is when the fact that the hardware/software decoder can't do low-latency is known (then we can discuss on what the meaning of low-latency is, I guess, that's an orthogonal issue).
When this is not known, we can imagine punting to the implementation to make it known, with an in-UA-benchmark (example from Gecko to return accurate information for
MediaCapabilities: https://searchfox.org/mozilla-central/source/dom/media/Benchmark.cpp, but this is for throughput and not latency). For us, it's stored locally on the device and periodically updated (say, when decoders are updated).There is also the case where going low latency requires a software decoder, but the software decoder cannot do enough fps for the video to be useful in real-time (I'm thinking those Windows 10 laptops based on ARM, that can do vp9 without any issue in hardware but struggle doing it in software, where it's barely possible if at all). So then what should be the answer? Maybe we do want to add something to
MediaCapabilities, where the API shape lends itself a bit more to this kind of assessment.So yes, I guess this is hard, but it's possible, so not doing it when it's better to do it is hard to justify, when it unlocks a very clear and measurable benefit for developers and users.
dalecurtis commentedon May 4, 2021
Interesting. I like the idea of using
isConfigSupportedbut am wary of using an in-UA-test for this since it seems counter to the low level nature of the API. I.e., if this were a native app I'd expect it should use the API to test support on its own for something that can't be answered without a decoding test. I agree that MediaCapabilities feels like a better home for such questions.Additionally, I think we do have to stray a bit into what low latency means unfortunately :) Nominally I think we're both using it to mean 1-in-1-out, but that behavior can be stream dependent (e.g., b-frames can preclude this behavior). So adding a UA test which just checks a curated stream may be not be the answer an author is looking for.
As such I'm inclined to consider this best effort and ignore it during
isConfigSupported.chcunningham commentedon May 12, 2021
Triage note: marking 'extension', as this is defining a new attribute.
chcunningham commentedon Jul 7, 2021
@padenot, thoughts on Dale's last reply?
padenot commentedon Jul 8, 2021
I agree with what @dalecurtis said in his last comment. I think we need something somewhere that authors can query to have high level info. @chcunningham mentioned during the editor call yesterday that he had the feeling that
MediaCapabilitieswere too high level, but I think it might well just be fine. We can discuss it as a follow-up.There is always the possibility to log a developer console message or something (
"optimizeForLowLatency" requested but the bytestream contains b-frames).dalecurtis commentedon Jul 26, 2021
@padenot are you okay with the
optimizeForLatencyname given the conclusion that it'll function as a hint?padenot commentedon Jul 27, 2021
Yes, this name sounds good, thanks.
Add optimizeForLatency to the spec.