---
title: "What Is an Audio Codec? Lossy, Lossless and Codec vs File - CE.SDK Glossary"
description: "An audio codec shrinks sound and restores it for playback. Hear how lossy codecs hide what they drop, tell a codec from a file, and see what CE.SDK opens."
url: "https://img.ly/glossary/audio-codec/"
type: "page"
---

> This is the markdown version of [What Is an Audio Codec? Lossy, Lossless and Codec vs File - CE.SDK Glossary](https://img.ly/glossary/audio-codec/). For all pages in one file, see [llms-full.txt](https://img.ly/llms-full.txt). For an index of all available pages, see [llms.txt](https://img.ly/llms.txt).

---

# Audio Codec

## What Is an Audio Codec?

An audio codec is the pair of programs that compresses sound for storage or sending and turns it back into samples a speaker can play: the encoder packs the audio, the decoder unpacks it. The Opus and FLAC specs define the decoder exactly and leave the encoder's choices open, so two encoders can turn one recording into different files that both play.

A codec is not a file type. The file around the audio holds the encoded stream along with timing and tags, and one kind of file can carry several codecs. Some names cover both, MP3 among them.

### Lossy codecs drop the least audible detail

They decode to an approximation of the recording, leaving out or coarsening the parts a listener is least likely to notice.

MP3, AAC, Vorbis, Opus

### Lossless codecs decode to the exact original

They make the file smaller, and decoding gives back audio bit for bit identical to what went in.

FLAC, ALAC

### Uncompressed PCM stores the raw signal

Linear PCM measures the sound at regular intervals and stores each measurement as a number. Audio CDs use it at 16 bits, and it is what nearly every WAV file holds.

8-bit PCM, 16-bit PCM, 24-bit PCM

## How Does a Lossy Codec Decide What to Drop?

Lossy encoders lean on psychoacoustics, the study of what people hear. A loud sound can hide a quieter one close to it in pitch, an effect called masking, which weakens as the two sounds move apart. The encoder estimates that masking threshold as it goes and keeps the noise its compression adds below it, where it can't be heard.

### Hide a quiet tone under noise

The noise plays around 1 kHz with a quiet tone inside it. Switch the tone off and on, then move it two octaves up and try again.

The demo plays a band of noise centered on 1 kHz with a sine tone 18 dB quieter than the noise, which you switch on and off. The tone sits either at 1 kHz, in the middle of the noise, or at 4 kHz, two octaves above it. The sound is generated in the browser; no codec runs.

## Audio Codec vs File Format: What's the Difference?

The codec decides how the sound is compressed, and the file format decides how it is packed, with timing, tags and sometimes a video track alongside. An extension names the file, not the codec, so the same AAC audio can arrive as an .m4a, an .mp4 or an .aac file. Video files follow the same split, as the [WebM vs MP4](https://img.ly/glossary/webm-vs-mp4.md) and [MKV vs MP4](https://img.ly/glossary/mkv-vs-mp4.md) pages show.

### MP3 is the name of a codec and of a file

MP3 audio usually travels as an .mp3 file, which wraps the stream and often adds ID3 tags for its metadata. The same audio can also sit inside an MP4, Matroska or 3GP file, and then the extension no longer says MP3.

### An .m4a file is an MP4 holding AAC or ALAC

The audio in an .m4a can be [lossy](https://img.ly/glossary/lossy-vs-lossless.md) AAC or lossless ALAC, and the extension doesn't say which. A .aac file is something else again: a nearly bare AAC stream in a thin wrapper called ADTS.

### A WAV file wraps sound that is almost always uncompressed PCM

WAV is a RIFF container, and RIFF lets it carry several codecs. In practice nearly every WAV file holds linear PCM, which is why WAV and uncompressed audio tend to mean the same thing.

## Which Audio Codec Should You Use?

The job decides, and one product may need several. A podcast app might keep each host's raw recording as a FLAC master, publish the episode as AAC in an .m4a file and run live call-ins over [Opus](https://img.ly/glossary/opus-codec.md).

- **Video for the web and social apps**: Use: AAC, Why: The usual pairing for video, and Apple's HLS spec requires a stereo AAC track

- **Calls and live voice**: Use: Opus, Why: A low-delay codec, built for live audio

- **Music downloads and podcasts**: Use: AAC or MP3, Why: Both play in every major browser, though Firefox plays AAC only in an MP4 file

- **Editing masters and archives**: Use: FLAC, or WAV with PCM, Why: Lossless, so every later export starts from the full recording

- **Lossless audio for Apple devices**: Use: ALAC in .m4a, Why: Apple's own lossless codec

- **Surround sound for TVs**: Use: E-AC-3 or AC-3, Why: The Dolby codecs HLS lists for multichannel audio; AC-3 is also widespread on DVDs and digital TV

- **Speech on phone networks**: Use: AMR in .3gp, Why: Made for speech sampled at 8 kHz, at 12.2 kbps or less

## Can a Device Play a Codec It Can't Encode?

Yes. Decoding and encoding are separate pieces of software, and a platform can ship one without the other. Android's own media support table lists MP3 and Vorbis as formats it decodes with no encoder for either, so an Android app can play both but can't write them with the built-in encoders.

For an app, that makes the question two questions: can this device play the format, and can it create one. In a browser, the media element's `canPlayType()` answers the first, and [WebCodecs](https://img.ly/glossary/webcodecs.md) answers the second.

## Does Bluetooth Use the File's Audio Codec?

No. Wireless headphones receive sound through a link codec of their own, which the phone and headphones agree on when they connect: SBC, plus AAC, aptX, aptX HD or LDAC on Android. The phone decodes the file and passes the audio through that encoder, so the two codecs are separate stages.

That is why a FLAC or ALAC file usually reaches wireless headphones in lossy form. Apple's lossless audio page, for one, says many AirPods and Beats models use its AAC Bluetooth codec, and that Bluetooth connections aren't lossless.

## How Audio Codecs Work in CE.SDK

Music tracks, voice recordings and the sound of your users' video clips all pass through [CE.SDK's video editing](https://img.ly/products/video-sdk.md), which decodes each one as it loads and encodes the finished mix on export. Your app picks the audio codec of that export or leaves it on Auto.

### Opening audio files and video soundtracks

WAV, MP3 and M4A files open as audio, and video files bring their sound along: [AAC or MP3](https://img.ly/glossary/aac-vs-mp3.md) in [MP4 and MOV](https://img.ly/glossary/mp4-vs-mov.md), Opus or Vorbis in WebM, and Opus in MP4. A WAV file needs PCM or floating-point samples inside, at 8, 16, 24 or 32 bits.

### AC-3 sound stopped an MP4 from opening in our web test

In our test of the web editor, an MP4 whose audio was AC-3 failed to load as a whole. The message in the browser console listed the audio codecs the editor accepts in an MP4 and suggested re-encoding the audio to AAC, which is the fix to give your users.

### Exporting with AAC or Opus

On Auto, MP4 exports carry AAC and WebM exports carry Opus. In the browser the encoders are the browser's own, and since Firefox, like Chrome on Linux, can't encode AAC, MP4 exports made in those browsers carry [Opus](https://img.ly/glossary/opus-codec.md) audio. The iOS and Android SDKs and `@cesdk/node-native` carry their own Opus and Vorbis encoders. The [audio bitrate](https://img.ly/glossary/bitrate.md) has its own setting.

## FAQs

### Audio codecs

**Q: Is WAV a codec?**

A: No. WAV is a container, a RIFF file that can hold several codecs. Nearly every WAV file holds uncompressed linear PCM, though, which is why the two names often get used as if they meant the same thing.

**Q: Is FLAC better than WAV?**

A: For storing a master, FLAC gives up nothing: it decodes to exactly the audio a PCM WAV holds, in a smaller file. Choose WAV when the app or device that receives the file reads only uncompressed audio.

**Q: Which audio codec plays on the most devices?**

A: AAC and MP3, which both play in every major browser. AAC is also the usual soundtrack for video: Apple's HLS spec requires a stereo AAC track, and MDN names AAC the likely best choice for a site that can support just one audio format. Firefox plays AAC only inside an MP4 file.

**Q: Can FLAC audio be stored in an MP4?**

A: Yes. The FLAC spec points to a separate definition for storing FLAC in MP4, next to its own mappings for Ogg and Matroska, and MDN lists FLAC among the audio codecs browsers support in MP4 files. A .flac file, by contrast, holds only FLAC audio.

**Q: What audio codec should a YouTube upload use?**

A: AAC-LC, Opus or Eclipsa Audio, according to YouTube's recommended upload settings, with stereo or stereo plus 5.1 channels at a 48 kHz sample rate.

## Links

- [Video Editor SDK](https://img.ly/products/video-sdk.md): Let your users add music, voice and video soundtracks, and export the mix with AAC or Opus audio.
- [File format support](https://img.ly/docs/cesdk/js/import-media/file-format-support-8cdc84.md): See which audio files and soundtrack codecs CE.SDK opens on each platform.
- [To MP4](https://img.ly/docs/cesdk/js/export-save-publish/export/to-mp4-c998a8.md): Export MP4 video and choose its audio codec, or leave it on Auto for AAC.

---

## More Resources

- **[IMG.LY Website](https://img.ly/index.md)** - Creative editing SDKs for photo, video, and design
- **[Documentation](https://img.ly/docs/cesdk/)** - CE.SDK developer documentation
- **[Build with a coding agent](https://img.ly/SKILL.md)** - A skill that adds a CE.SDK editor to an app: it interviews the user, picks a starter kit and builds it
- **[Contact Sales](https://img.ly/forms/contact-sales.md)** - Get a custom quote. A public JSON API accepts the request directly, no account or key needed. Ask your user for consent and their details first.
- **[Free Trial](https://img.ly/pricing.md)** - Start building with CE.SDK
