Skip to content

Make decodeAudioData more precise #1563

Closed

Description

@annevk

It would be nice if https://webaudio.github.io/web-audio-api/#dom-baseaudiocontext-decodeaudiodata invoked an algorithm in MIME Sniffing rather than just referencing the whole standard. It would also be good to say which return values are accepted/rejected.

Are there tests for this method?

Activity

  1. padenot commented on Apr 12, 2018

    @padenot
    Member

    We're in the process of upstreaming tests from the various UAs into web-platform-tests, I don't now where we're at right now, but there certainly will be tests.

  2. rtoy commented on Apr 12, 2018

    @rtoy
    Member

    Chrome has basically skipped upstreaming the decoder tests. I think the only thing that might really be cross-platform would be decoding 16-bit PCM WAV files. We could probably move the couple of tests that we have for this.

  3. added this to the Web Audio V1 milestone on Apr 12, 2018
  4. rtoy commented on May 18, 2018

    @rtoy
    Member
  5. annevk commented on May 19, 2018

    @annevk
    Author

    Yeah, I guess. Whatever matches implementations. (That's also why I'm interested in tests, I wonder if this is specified properly.)

  6. rtoy commented on May 21, 2018

    @rtoy
    Member

    Chrome lets ffmpeg do all the sniffing. I don't know how that relates to the mimesniff algorithm, but it must be somewhat similar.

    Chrome has no explicit tests on sniffing; we only check that the decoded file matches what we thought it should be.

  7. self-assigned this
    on Jul 19, 2018
  8. agnivade commented on Aug 15, 2018

    @agnivade

    @rtoy - Does that mean a web server cannot reliably sniff audio content without calling into ffmpeg ?

    Because without any algorithm it is not possible to reliably do mime sniffing.

    Context:
    I would like to implement mime sniffing for mp3s in Go's http server. But that is blocked on whatwg/mimesniff#70. Which is blocked on this issue. Would appreciate any leads on this.

  9. rtoy commented on Aug 15, 2018

    @rtoy
    Member

    @agnivade: Don't have anything really to add. Mime sniffing is just a heuristic anyway, right?

  10. agnivade commented on Aug 16, 2018

    @agnivade

    Sure, that maybe. But there are major differences between the mime sniffing algorithm in https://mimesniff.spec.whatwg.org/#signature-for-mp3-without-id3 and the actual algorithm used by mozilla
    https://dxr.mozilla.org/mozilla-central/source/toolkit/components/mediasniffer/mp3sniff.c.

    We should fix that. I tried to implement what was in mimesniff and it failed for every possible mp3 out there. I don't believe that should be the case.

  11. annevk commented on Aug 16, 2018

    @annevk
    Author

    It's not exactly a heuristic. It determines whether or not a byte stream can be played back and needs to be interoperable across implementations.

  12. added a commit that references this issue on Oct 31, 2018
    495c359
  13. added a commit that references this issue on Nov 7, 2018
    bad956a
  14. added a commit that references this issue on Jan 17, 2019
    0e943c1
  15. guest271314 commented on Feb 2, 2020

    @guest271314
  16. GPHemsley commented on Sep 9, 2021

    @GPHemsley

    I'm not sure that #1781 sufficiently addressed this.

    For starters, it's pointing to the wrong mimesniff algorithm. The rules for sniffing audio and video specifically are what is intended to be used for sniffing in an audio or video context (such as <audio> or <video>). This is distinct from the algorithm identifying audio or video in a browsing context, which is meant to be much more restrictive and geared towards balancing security and legacy content.

    Secondly, the spec for decodeAudioData() still contains:

    The buffer passed to decodeAudioData() has its content-type determined by sniffing, as described in [mimesniff].

    Which I believe is what @annevk was referring to as vague.

  17. guest271314 commented on Sep 10, 2021

    @guest271314
  18. padenot commented on Sep 15, 2021

    @padenot
    Member

    I'm not sure that #1781 sufficiently addressed this.

    I agree, it's not enough. I've filed #2378 as a follow-up and will address the issues you describe there. Thanks for reporting!

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions