# \&audiocodec

Viewer-Side Option! ([`&view`](https://docs.vdo.ninja/advanced-settings/mixer-scene-parameters/view), [`&scene`](https://docs.vdo.ninja/advanced-settings/mixer-scene-parameters/scene), [`&room`](https://docs.vdo.ninja/advanced-settings/setup-parameters/room), [`&solo`](https://docs.vdo.ninja/advanced-settings/mixer-scene-parameters/and-solo))

## Options

Example: `&audiocodec=opus`

| Value  | Description                       |
| ------ | --------------------------------- |
| `opus` | default; selects audio codec opus |
| `red`  | selects audio codec [red](#red)   |
| `pcmu` | selects audio codec pcmu          |
| `pcma` | selects audio codec pcma          |
| `isac` | selects audio codec isac          |
| `g722` | selects audio codec g722          |
| `pcm`  | selects audio codec [pcm](#pcm)   |

## Details

`&audiocodec` on the viewer side can let you specify the audio codec; `opus` (default), `pcmu`, `pcma`, `isac`, `g722`, `red` and `pcm`.

#### red

`&audiocodec=red` is pretty much like sending two opus streams, with one as a backup in case of packet loss; support in Chromium 97 and up, but the only way I can so far tell that it is working is to check if the audio bitrate has doubled.

When using [`&proaudio`](https://docs.vdo.ninja/advanced-settings/audio-parameters/and-proaudio), [`&stereo`](https://docs.vdo.ninja/advanced-settings/audio-parameters/stereo), or higher than [`&audiobitrate=216`](https://docs.vdo.ninja/advanced-settings/audio-parameters/audiobitrate) with this, the resulting bitrate may not actually double. I don't quite understand what's going on here, if its still working or not, so to be safe when using [`&proaudio`](https://docs.vdo.ninja/advanced-settings/audio-parameters/and-proaudio) or [`&stereo`](https://docs.vdo.ninja/advanced-settings/audio-parameters/stereo), along with `&audiocodec=red`, I set the bitrate to 216 by default, which will then result in a sending bitrate of around 440-kbps.

I've tried to enable RED-mode to work with PCM audio, but so far it will only work with OPUS audio.

#### pcm

`&audiocodec=pcm` now will support 48khz and 44.1khz mono playback (48khz default), and if [`&stereo`](https://docs.vdo.ninja/advanced-settings/audio-parameters/stereo) is used, it changes to two-channel stereo 32khz.

The existing [`&samplerate=44100`](https://docs.vdo.ninja/advanced-settings/audio-parameters/and-samplerate) option can lower the sample rate of this pcm mode (down to 8khz even), and hence the resulting audio bitrate. Since PCM is raw, [`&audiobitrate`](https://docs.vdo.ninja/advanced-settings/audio-parameters/audiobitrate) won't work, so expect 550 to 1200-kbps in just audio bitrates per viewer.

There may be clicking when using PCM mode (L16) if you are on a bad connection, as PCM doesn't have much in the way of error correction.  You'll need to address this yourself probably with post-processing if any issue.

#### Future options

In the near future you'll be able to send PCM audio via [`&chunked`](https://docs.vdo.ninja/advanced-settings/settings-parameters/and-chunked) mode, which will guarantees delivery of all packets sent, however there may be buffering issues if your connection can't keep up with bandwidth requirements.

Currently [`&chunked`](https://docs.vdo.ninja/advanced-settings/settings-parameters/and-chunked) mode does work with OPUS-audio though; please provide feedback and requests if you use it. Chunked mode does not support [WHIP/WHEP](https://docs.vdo.ninja/steves-helper-apps/whip-and-whep-tooling) or [Meshcast](https://docs.vdo.ninja/advanced-settings/meshcast-parameters/and-meshcast).

## Related

{% content-ref url="../video-parameters/codec" %}
[codec](https://docs.vdo.ninja/advanced-settings/video-parameters/codec)
{% endcontent-ref %}

{% content-ref url="minptime-3" %}
[minptime-3](https://docs.vdo.ninja/advanced-settings/audio-parameters/minptime-3)
{% endcontent-ref %}
