> For the complete documentation index, see [llms.txt](https://docs.vdo.ninja/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.vdo.ninja/advanced-settings/audio-parameters/and-preferaudiocodec.md).

# \&preferaudiocodec

Reference for the \&preferaudiocodec URL parameter in VDO.Ninja including behavior examples and related options.

#### **Description**

Sets the preferred audio codec for outgoing streams, allowing the sender to specify which audio codec they prefer to use.

#### **Sender-Side Option**

This parameter influences which audio codec is negotiated during the WebRTC connection setup.

#### **Usage**

* **`&preferaudiocodec=opus`** - Prefer Opus codec (default for most browsers)
* **`&preferaudiocodec=red`** - Prefer RED (redundancy encoding) for packet loss resilience
* **`&preferaudiocodec=g722`** - Prefer G.722 codec

#### **Examples**

```
https://vdo.ninja/?push=streamID&preferaudiocodec=opus
https://vdo.ninja/?push=streamID&preferaudiocodec=red
https://vdo.ninja/?push=streamID&whipout=whipserver&preferaudiocodec=g722
```

#### **Details**

* The parameter sets a preference, but the final codec is negotiated between peers
* Both sender and receiver must support the codec for it to be used
* Primarily intended for debugging or WHIP publishing scenarios
* Codec names are case-insensitive (converted to lowercase)

#### **Available Codecs**

* **opus** - Default, high-quality codec with good compression
* **red** - Redundancy encoding, better for poor network conditions
* **g722** - Traditional telephony codec, wider compatibility

#### **Notes**

* Not all browsers support all codecs
* Using RED codec may limit bitrate to 216 kbps
* This is an advanced parameter mainly for debugging or specific use cases
* WHIP servers may require specific codecs

{% hint style="info" %}
The native Ninja OBS Plugin has its own **Audio RED (Experimental)** setting. When enabled, it offers RFC 2198 RED and can carry one previous Opus frame with the current frame; each viewer either selects that mapping or falls back to plain Opus. `&preferaudiocodec=red` configures a VDO.Ninja browser publisher and does not turn on the plugin setting.
{% endhint %}

#### **Related Parameters**

* [`&audiocodec`](https://docs.vdo.ninja/advanced-settings/audio-parameters/minptime-1.md) - Forces a specific audio codec (viewer-side)
* [`&audiobitrate`](https://docs.vdo.ninja/advanced-settings/audio-parameters/audiobitrate.md) - Sets the audio bitrate
* [`&whipout`](https://docs.vdo.ninja/advanced-settings/whip-parameters/and-whipout.md) - Publishes via WHIP protocol


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.vdo.ninja/advanced-settings/audio-parameters/and-preferaudiocodec.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
