Audio channel ordering is underspecified: "same as in the EncodedAudioChunk" is ambiguous for AAC, and layout information has no path through the API
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 25/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- html, javascript
- Ambito
- api, audio-video-rtc
Direzione di ricerca
Start with the WebCodecs Audio channel ordering section and the AudioDecoderConfig, AudioEncoderConfig, and AudioData definitions; compare them with Web Audio’s Channel Ordering requirements and the linked WPT PR. The issue proposes changes to channel ordering and possibly API fields for layout, but leaves the choice among proposals open. Done means reaching agreement on the required behavior and updating the specification and interoperability tests accordingly.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Problem
§ Audio channel ordering states:
When decoding, the ordering of the audio channels in the resulting AudioData MUST be the same as what is present in the EncodedAudioChunk. [...] In other terms, no channel reordering is performed when encoding and decoding.
NOTE: The container either implies or specifies the channel mapping: the channel attributed to a particular channel index.
This doesn't give a deterministic, interoperable result for common content, in particular AAC in MP4.
1. "Order present in the EncodedAudioChunk" is not well-defined for AAC
For AAC, the bitstream order of syntactic elements is not the decoder's output order. With channelConfiguration = 6 (5.1), the elements appear as SCE (C), CPE (L, R), CPE (Ls, Rs), LFE, so the "chunk order" is C, L, R, Ls, Rs, LFE.
Commonly used decoders differ in output order. Some reorder to WAVE/SMPTE order (L, R, C, LFE, Ls, Rs) such as Windows or FFmpeg, others output AAC-native order (Apple's AudioToolbox). Both readings arguably conform to the current text. The same file decoded in two conforming implementations can therefore produce different channel orders in AudioData.
The same ambiguity applies to Opus with channel mapping family 1 (Vorbis order) and to Vorbis. The spec doesn't say whether "the order in the chunk" means the coded stream order or the order the codec's own specification defines for output.
2. The NOTE is contradicted by the API: container information cannot reach the codec
The section ends with:
NOTE: The container either implies or specifies the channel mapping: the channel attributed to a particular channel index.
This puts the channel mapping in the container, but WebCodecs never sees the container. The only inputs a decoder receives are:
AudioDecoderConfig:codec,sampleRate,numberOfChannels, anddescription.descriptionis codec-level configuration such as the AAC AudioSpecificConfig, OpusHead or FLAC STREAMINFO, not container metadata.EncodedAudioChunk:type,timestamp,duration, and the coded payload.
Neither has a field for a container-level layout. Concretely:
- AAC in ISOBMFF: a
chnlbox (ISO/IEC 14496-12 / 23001-8) or a QuickTimechanbox in the sample entry has nowhere to go. - PCM in ISOBMFF (
ipcm/fpcm, ISO/IEC 23003-5): thechnlbox is the only layout information, and the PCM registration accepts nodescription. - Encoding:
AudioEncoderConfighas no layout field andAudioDatacarries none, so the encoder can't produce output a muxer could write a correctchnl/chanbox from. The producedEncodedAudioChunkMetadata.decoderConfigcarries no layout either.
The NOTE can only be read as "the application must interpret channel indices itself, using container data it parsed". That fails too. Per section 1, the application can't know whether the decoder output follows bitstream order, the codec's canonical order, or a reordered one, so it has no reliable way to apply the container's mapping to AudioData channel indices.
The NOTE therefore describes a mechanism that doesn't exist in the API. It should either be removed, or backed by an actual way to carry layout information (see proposal 2).
3. AudioData exposes no channel layout
AudioData only exposes numberOfChannels. Because of (1), an application can't determine which speaker a given channel index represents, even if it parsed the container itself. It doesn't know whether the decoder reordered.
Impact
An application that decodes 5.1 AAC from MP4 and renders it through Web Audio, which defines a specific 5.1 order (L, R, C, LFE, SL, SR), cannot write portable code. It must guess or sniff the user agent. The same applies to encoding: there is no way to tell an AudioEncoder which layout the input AudioData uses, so the encoder can't signal it correctly in the bitstream (e.g. AAC channelConfiguration or a PCE, Opus mapping table).
Proposals (not mutually exclusive)
-
Adopt the Web Audio channel ordering. Web Audio § Channel Ordering already defines a normative order (SPEAKER_FRONT_LEFT, SPEAKER_FRONT_RIGHT, SPEAKER_FRONT_CENTER, SPEAKER_LOW_FREQUENCY, SPEAKER_BACK_LEFT, ...) and requires implementations to "present the channels provided in the order defined below, skipping over those channels not present". User agents already apply this when decoding the same codecs via
decodeAudioData(), so the reordering logic already exists in implementations.WebCodecs should require:
- Decoding: when the codec configuration signals a speaker layout (e.g. AAC
channelConfigurationor a PCE with defined positions, Opus mapping family 1, Vorbis, FLAC),AudioDatachannels MUST be output in Web Audio channel order. - Encoding: input
AudioDatachannels are interpreted in Web Audio channel order, and the encoder MUST map them to the codec's own order and signalling. - Discrete layouts: when no speaker layout is signalled (e.g. Opus mapping families 2 and 255, PCM without layout information), channels are passed through in coded order with no speaker semantics.
- Decoding: when the codec configuration signals a speaker layout (e.g. AAC
-
Add an optional channel layout to
AudioDecoderConfigandAudioEncoderConfig, so container-level layout information (e.g.chnl) can be supplied and encoders can signal it. -
Expose the channel layout on
AudioData, so consumers can interpret channel indices without codec- or UA-specific knowledge.
Interop data
WPT PR: https://github.com/web-platform-tests/wpt/pull/64040
The test decodes 5.1 streams in which each channel carries a distinct tone, then identifies the speaker of each output channel.
| AAC + AudioSpecificConfig (MP4) | AAC (ADTS) | Opus (mapping family 1) | |
|---|---|---|---|
| Chrome | FL FR FC LFE BL BR | FL FR FC LFE BL BR | FL FR FC LFE BL BR |
| Firefox | FL FR FC LFE BL BR | FL FR FC LFE BL BR | FL FR FC LFE BL BR |
| Safari | FC FL FR BL BR LFE | FC FL FR BL BR LFE | not supported (Safari doesn't currently decode more than 2 channels of Opus) |
Coded channel order in the test streams:
- AAC, channelConfiguration 6: C, L, R, Ls, Rs, LFE
- Opus, channel mapping family 1 (Vorbis order): L, C, R, Ls, Rs, LFE
Chrome and Firefox already reorder the decoded output of both codecs to SMPTE/WAVE order, which is also the Web Audio order. That contradicts the current spec text, which says the order MUST be "the same as what is present in the EncodedAudioChunk" and that "no channel reordering is performed". Safari follows the spec text for AAC and outputs the coded order.
So the only engine that follows the spec produces output that no other engine matches, and that Web Audio consumers can't use without UA-specific remapping. The spec should be changed to match the majority behaviour (proposal 1), not the other way around.
Editorial
In the same section, "as what is preset in the given AudioData" should be "present".
- Lingua principale
- HTML
- Stelle
- 1.3k
- Fork
- 190
- Merge medio
- 1g 4h
- PR unite (30g)
- 12
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di w3c/webcodecs
-
privacy-needs-resolution
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 65/100
I maintainer di solito rispondono entro 1 giorno
-
editorial
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 68/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
w3c/webcodecs#983 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
w3c/webcodecs#978 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 55/100
w3c/webcodecs#973 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di w3c/webcodecs
Issue simili
-
ai-driven-fuzzing bug claude Minor
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
linagora/cozy-client#1769 ·
I maintainer di solito rispondono entro 1 giorno
-
[BUG] micronaut-serde-oracle-jdbc-json brings a second OJDBC driver onto the runtime classpathForse già presa @ZARAYACH l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
micronaut-projects/micronaut-serialization#1494 · 4 commenti ·
I maintainer di solito rispondono entro 2 giorni
-
Admin member of a research group cannot see the HX2 allocation until they've been added to itAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
-
bug
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 73/100
I maintainer di solito rispondono entro 2 giorni