# `Membrane.Opus.Encoder`
[🔗](https://github.com/membraneframework/membrane_opus_plugin/blob/v0.21.0/lib/membrane_opus/encoder.ex#L1)

This element performs encoding of Opus audio into a raw stream. You'll need to parse the stream and then package it into a container in order to use it.

## Element options

Passed via struct `t:Membrane.Opus.Encoder.t/0`

- `application`  

  ```
  allowed_applications()
  ```
  
  Default value: `:audio`  
  Output type (similar to compression amount).
  
  See https://opus-codec.org/docs/opus_api-1.3.1/group__opus__encoder.html#gaa89264fd93c9da70362a0c9b96b9ca88.

- `bitrate`  

  ```
  allowed_bitrates()
  ```
  
  Default value: `:auto`  
  Explicit control of the Opus codec bitrate.
  This can be :auto (default, OPUS_BITRATE_AUTO), :max (OPUS_BITRATE_MAX) or a value from 500 to 512000 bits per second.
  
  See https://www.opus-codec.org/docs/html_api/group__opusencoder.html and https://www.opus-codec.org/docs/html_api/group__encoderctls.html#ga0bb51947e355b33d0cb358463b5101a7

- `signal_type`  

  ```
  allowed_signal_types()
  ```
  
  Default value: `:auto`  
  Explicit control of the Opus signal type.
  This can be :auto (default, OPUS_SIGNAL_AUTO), :voice (OPUS_SIGNAL_VOICE) or :music (OPUS_SIGNAL_MUSIC)
  
  See https://www.opus-codec.org/docs/html_api/group__opusencoder.html and https://www.opus-codec.org/docs/html_api/group__encoderctls.html#gaaa87ccee4ae46aa6c9528e03c5122b89

- `input_stream_format`  

  ```
  RawAudio.t()
  ```
  
  Default value: `nil`  
  Input type - used to set input sample rate and channels.

## Pads

### `:input`

Accepted formats:
```
%RawAudio{sample_format: :s16le, channels: channels, sample_rate: sample_rate}
when channels in @allowed_channels and sample_rate in @allowed_sample_rates
```
```
Membrane.RemoteStream
```

Direction: | `:input`
Availability: | `:always`
Flow control: | `:auto`

### `:output`

Accepted formats:
```
%Opus{self_delimiting?: false}
```

Direction: | `:output`
Availability: | `:always`
Flow control: | `:auto`

# `allowed_applications`

```elixir
@type allowed_applications() :: :voip | :audio | :low_delay
```

# `allowed_bitrates`

```elixir
@type allowed_bitrates() ::
  :auto
  | :max
  | 10000
  | 24000
  | 32000
  | 64000
  | 96000
  | 128_000
  | 256_000
  | 450_000
```

# `allowed_channels`

```elixir
@type allowed_channels() :: 1 | 2
```

# `allowed_sample_rates`

```elixir
@type allowed_sample_rates() :: 8000 | 12000 | 16000 | 24000 | 48000
```

# `allowed_signal_types`

```elixir
@type allowed_signal_types() :: :auto | :voice | :music
```

# `t`

```elixir
@type t() :: %Membrane.Opus.Encoder{
  application: allowed_applications(),
  bitrate: allowed_bitrates(),
  input_stream_format: Membrane.RawAudio.t(),
  signal_type: allowed_signal_types()
}
```

Struct containing options for `Membrane.Opus.Encoder`

# `options`

```elixir
@spec options() :: keyword()
```

Returns description of options available for this module

---

*Consult [api-reference.md](api-reference.md) for complete listing*
