Jan 14, 2026 · Updated Oct 14, 2026

<span aria-hidden="true" id="what-is-an-audio-codec"></span>

# What is an audio codec?

![Kevin van Zonneveld](/assets/images/teammates/avatar-kvz-4.jpg)

**Kevin van Zonneveld**

Co-founder · Amsterdam, The Netherlands · Show bio

[](https://x.com/kvz)[](https://github.com/kvz)

An audio codec (coder/decoder) is the algorithm that compresses and decompresses sound. It decides how audio is stored or streamed, how large the file is for a given quality, and which devices can play it back. Picking the right codec is a balance of fidelity, bitrate, latency, and compatibility.

<span aria-hidden="true" id="codec-vs-container"></span>

## Codec vs. container

A codec is not the same thing as a container. A container (such as MP4, MKV, or WebM) is the wrapper that can hold one or more audio and video streams, plus metadata. The codec is the actual compression method used inside that container. For example, an MP4 file often contains AAC audio, while a WebM file typically contains Opus or Vorbis audio.

<span aria-hidden="true" id="how-audio-codecs-work"></span>

## How audio codecs work

Raw digital audio is usually stored as PCM (pulse‑code modulation). PCM is accurate, but large. A codec reduces size by applying compression. Lossless codecs compress PCM without removing information. Lossy codecs go further by discarding details that are less audible to the human ear (psychoacoustic modeling), which yields much smaller files at the cost of some quality.

<span aria-hidden="true" id="lossy-lossless-and-uncompressed"></span>

## Lossy, lossless, and uncompressed

* **Lossy**: removes data to shrink files. Best for streaming and general listening when size matters. Examples: MP3, AAC, Opus.
* **Lossless**: preserves all information while still compressing. Best for mastering, archival, and professional workflows. Examples: FLAC, ALAC.
* **Uncompressed**: uses PCM encoding without compression. Best for editing pipelines that need zero compression overhead. PCM is commonly stored in WAV or AIFF containers; those containers are not codecs.

<span aria-hidden="true" id="key-settings-that-affect-quality-and-size"></span>

## Key settings that affect quality and size

* **Bitrate**: the most direct lever for size and quality. Higher bitrate usually means better quality. Variable bitrate (VBR) adapts to complexity; constant bitrate (CBR) is predictable.
* **Sample rate**: the amount of samples per second (e.g., 44.1 kHz, 48 kHz). Higher rates capture more detail, but increase size.
* **Channels**: mono, stereo, or multichannel. The more channels, the larger the size.
* **Bit depth**: mainly relevant for lossless/uncompressed audio (e.g., 16‑bit vs. 24‑bit).

<span aria-hidden="true" id="common-audio-codecs-and-when-to-use-them"></span>

## Common audio codecs and when to use them

* **AAC**: a strong default for music and general playback; excellent compatibility in MP4.
* **MP3**: legacy, still widely supported, but less efficient than AAC or Opus at the same bitrate.
* **Opus**: great for voice, real‑time, and low‑bitrate streaming; excellent quality at small sizes.
* **FLAC**: lossless compression for archiving and distribution of high‑quality audio.
* **PCM**: uncompressed audio encoding for editing pipelines and interchange, commonly stored in WAV or AIFF containers.

<span aria-hidden="true" id="how-to-choose-the-right-codec"></span>

## How to choose the right codec

* **Streaming or podcasts**: AAC or Opus, depending on device support requirements.
* **Voice or real‑time**: Opus for low latency and efficiency.
* **Archival or mastering**: FLAC or uncompressed PCM in a WAV container.
* **Maximum compatibility**: MP3 still wins on legacy devices, but AAC is broadly supported too.

<span aria-hidden="true" id="encode-audio-using-transloadit"></span>

## Encode audio using Transloadit

Our [🤖 /audio/encode](/docs/robots/audio-encode.md) Robot lets you convert audio to popular codecs with a few parameters. Here’s a minimal example that converts an upload to MP3 at 128 kbps:

For the storage Step, create your own named Amazon S3 [Template Credential](/c/template-credentials/) and replace `YOUR_AWS_CREDENTIALS` with its saved name. Use a private bucket with S3 Block Public Access enabled and do not supply ACL or grant headers. The `bucket-default` setting omits the generated ACL header; it does not make a bucket private. Reading private results requires separate read authorization; a returned URL does not grant access.

```json
{
  "steps": {
    "encode_mp3": {
      "robot": "/audio/encode",
      "use": ":original",
      "preset": "mp3",
      "bitrate": 128000
    },
    "store": {
      "robot": "/s3/store",
      "use": "encode_mp3",
      "credentials": "YOUR_AWS_CREDENTIALS",
      "acl": "bucket-default"
    }
  }
}

```

Need lossless output? Choose an appropriate lossless preset; increasing `bitrate` does not make a lossy codec lossless. For different sample rates, set `sample_rate` accordingly.

##### Audio Encoding

[High-quality FLAC encoding](/demos/audio-encoding/encode-into-flac.md)

##### Audio Encoding

[Encoding with a specific bit rate](/demos/audio-encoding/encode-with-different-bitrate-and-samplerate.md)

##### Audio Encoding

[Loudness Normalization](/demos/audio-encoding/normalize-volume-in-audio.md)

<span aria-hidden="true" id="next-steps"></span>

## Next steps

* Explore [Audio Encoding](/services/audio-encoding.md) and browse the [🤖 /audio/encode](/docs/robots/audio-encode.md) docs.
* Need help choosing a codec? Reach out at <hello@transloadit.com>.

[#audio-encoding-service](/blog/tags/audio-encoding-service.md)[#audio-encode-robot](/blog/tags/audio-encode-robot.md)

### Join 25k+ developers

Sign up for our [monthly newsletter](/newsletters.md) to receive direct links to 3 exclusive tech — and 2 product updates. No less, no more.

Email address

Subscribe

One email a month. Unsubscribe anytime.

## File uploading and encoding. Made simple.

Trusted by Coursera and The New York Times for a reliable API, top-notch support, and open source like [Uppy](https://uppy.io) and [Tus](https://tus.io).

[Try it free](/c/signup/)[Request a demo](/request-demo.md)

No credit card needed · Cancel anytime
