Skip to content

Add optimizeForLatency boolean flag to VideoDecoderConfig. #206

Closed

Description

@dalecurtis

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.

Activity

  1. padenot commented on Apr 30, 2021

    @padenot
    Collaborator

    Fully agree. To some extent, this is also related to software vs. hardware encoder choice in common setups.

  2. chcunningham commented on Apr 30, 2021

    @chcunningham
    Collaborator

    Editors call: concept looks good. @padenot @aboba : pls bikeshed on name w/ priority

  3. dalecurtis commented on Apr 30, 2021

    @dalecurtis
    ContributorAuthor

    Bike shed colors:

    • lowLatency : bool
    • optimizeForLowLatency : bool
    • lowDelay : bool
    • optimizeForLowDelay : bool

    I don't have any strong preference. We call it low delay mode internally.

  4. dalecurtis commented on Apr 30, 2021

    @dalecurtis
    ContributorAuthor

    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.

  5. padenot commented on May 3, 2021

    @padenot
    Collaborator

    lowLatency : bool

    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.

  6. dalecurtis commented on May 3, 2021

    @dalecurtis
    ContributorAuthor

    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.

  7. padenot commented on May 4, 2021

    @padenot
    Collaborator

    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).

    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.

  8. dalecurtis commented on May 4, 2021

    @dalecurtis
    ContributorAuthor

    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.

  9. added
    extension
    on May 12, 2021
  10. chcunningham commented on May 12, 2021

    @chcunningham
    Collaborator

    Triage note: marking 'extension', as this is defining a new attribute.

  11. chcunningham commented on Jul 7, 2021

    @chcunningham
    Collaborator

    As such I'm inclined to consider this best effort and ignore it during isConfigSupported.

    @padenot, thoughts on Dale's last reply?

  12. padenot commented on Jul 8, 2021

    @padenot
    Collaborator

    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).

  13. dalecurtis commented on Jul 26, 2021

    @dalecurtis
    ContributorAuthor

    @padenot are you okay with the optimizeForLatency name given the conclusion that it'll function as a hint?

  14. padenot commented on Jul 27, 2021

    @padenot
    Collaborator

    Yes, this name sounds good, thanks.

  15. added a commit that references this issue on Jul 28, 2021
    cb67b30
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

    extension

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions