Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for L16 codec (uncompressed audio) #3116

Merged
merged 1 commit into from
Dec 19, 2022
Merged

Add support for L16 codec (uncompressed audio) #3116

merged 1 commit into from
Dec 19, 2022

Conversation

lminiero
Copy link
Member

@lminiero lminiero commented Dec 2, 2022

One of the hidden "secrets" in Chrome is that you can tell it, by munging the SDP, to send RTP packets with uncompressed audio data, instead of encoding them. This means that, instead of using Opus, G.711 or whatever else, the samples are sent exactly as they're captured. This audio format is called L16, and uses two bytes per sample.

In general, you can enable it in the SDP by using the L16/<samplerate>/<channels> rtpmap in the SDP, e.g.:

a=rtpmap:111 L16/16000

Chrome supports a few variants of those (not sure how many, I haven't tried them all), so to start using it with Janus I added support for two different versions: L16/16000 (uncompressed wideband) and L16/48000 (uncompressed fullband), in both cases mono only and not stereo (there will be time to expand on this).

In case you're wondering why support this at all (as uncompressed audio is very inefficient to send around), the main reason is facilitating the experimentation with WASM audio codecs. You may have heard about Lyra, a new audio codec with very low bandwidth: a WASM version of it has already surfaced, and so it would be cool to see how it works in a WebRTC context, even if it's not available as a codec in browsers themselves. A way to do that is basically use a combination of WASM codecs, L16 samples, and Insertable Frames: you basically ask the browser for uncompressed audio samples, and then you encode/decode them yourself, using Insertable Streams to "replace" the uncompressed audio data in the original RTP packets with the bytes that have been encoded with WASM. In order to test all this with Janus, you need support for L16 negotiation, which is what we're adding here.

I tested this briefly with plain L16, and it seems to be working as expected. The patch also supports postprocessing L16 recordings (which of course only works if the RTP packets actually contain L16 data, and not Insertable Streams replacements). In case you do plan to experiment with WASM codecs and Janus as well, please do let me know, so that we can share some results.

@lminiero lminiero added the multistream Related to Janus 1.x label Dec 2, 2022
@lminiero lminiero changed the title Add support for L16 codec (raw samples) Add support for L16 codec (uncompressed audio) Dec 2, 2022
@fippo
Copy link
Contributor

fippo commented Dec 2, 2022

can you please file an issue in https://github.com/w3c/webrtc-nv-use-cases requesting access to raw audio data?
The not-really-announced support for L16 has blown up earlier this year after a certain vendor did very much non-spec things with it. I think L16 is quite interesting as a standardized format for raw data.

@lminiero
Copy link
Member Author

Merging.

@lminiero lminiero merged commit e139a1c into master Dec 19, 2022
@lminiero lminiero deleted the l16 branch December 19, 2022 13:36
@baudneo
Copy link

baudneo commented Jan 10, 2023

Very nice, a project wz_mini_hacks, adds RTSP server to wyze cameras. It sends v2/v3 audio as L16/44100

a=rtpmap:97 L16/44100

At the moment, it causes the stream not to play in chrome until the audio stream is removed. Looking forward to support for more sampling rates.

Thank you for your work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
multistream Related to Janus 1.x
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants