Glossary
Audio codec
Software or hardware that encodes audio into a compact digital format for storage or transmission and decodes it back for playback.
An audio codec is an algorithm, implemented in software or hardware, that encodes digital audio into a compact format for storage or transmission and decodes it back into playable sound. The name joins coder and decoder. MP3, AAC, Opus, Vorbis and FLAC are all audio codecs. Some discard detail that listeners are unlikely to notice in order to save space, which makes them lossy, while others shrink the data without discarding anything, which makes them lossless. The codec decides how large a file is, how it sounds, how much delay it adds to a call and how well speech recognition works on it afterwards.
What an audio codec does
Digital audio starts as pulse-code modulation, or PCM: a stream of amplitude samples taken many thousands of times per second. CD-quality stereo PCM uses 44,100 samples per second per channel at 16 bits each, which comes to about 1,411 kilobits per second, or roughly 10 megabytes per minute. That is manageable for a single file but expensive across a library of thousands of hours, and far too much for a phone call over a mobile network.
An encoder takes PCM and produces a smaller bitstream. A decoder reverses the process, producing PCM again for the speakers or for the next stage of a pipeline. The sample rate and bit depth describe the PCM going in and coming out, and the bitrate describes how much data per second the encoded stream uses. A codec’s job is to get the lowest bitrate that still meets its quality target for the material it was designed for, whether that is music, speech or both.
Lossy and lossless codecs
Lossy codecs use a psychoacoustic model, a description of what human hearing can and cannot perceive. Quiet sounds close in frequency to loud ones are masked and can be dropped, very high frequencies can be trimmed, and stereo channels that are nearly identical can be stored together. Most modern lossy codecs transform short blocks of audio into the frequency domain, commonly with the modified discrete cosine transform, quantise the coefficients according to the model, and pack the result with entropy coding. Files shrink by a factor of five to fifteen with little audible difference at sensible bitrates.
Lossless codecs keep every sample. They predict each sample from its neighbours and store only the prediction error, which compresses well because real audio is highly correlated. FLAC and Apple Lossless typically reduce music to between half and two thirds of its PCM size, and decoding returns bit-identical audio. Archives, mastering workflows and anyone who expects to re-encode later prefer lossless sources, since every lossy encode discards a little more and repeated transcoding accumulates artefacts, a problem known as generation loss.
Common audio codecs
Codec | Type | Typical use | Notes |
|---|---|---|---|
MP3 | Lossy | Music, podcasts, legacy libraries | Universal playback support; patents expired in 2017 |
AAC | Lossy | Streaming, Apple devices, video soundtracks | Better quality than MP3 at the same bitrate |
Opus | Lossy | Calls, WebRTC, voice chat, streaming | Covers speech and music from very low to high bitrates with low delay |
Vorbis | Lossy | Games, older open-source streaming | Largely succeeded by Opus |
FLAC | Lossless | Archives, high-quality music | Open format, widely supported |
ALAC | Lossless | Apple ecosystems | Apple’s equivalent of FLAC |
G.711 | Lossy speech | Traditional telephony | Narrowband, 8,000 samples per second |
AMR and EVS | Lossy speech | Mobile networks | Designed for voice over cellular links |
Speech codecs deserve a separate mention. Telephone networks long used narrowband audio sampled at 8,000 times per second, which carries frequencies only up to about 3.4 kHz. Wideband and super-wideband codecs used in modern calling apps capture much more of the voice, which makes speech clearer for listeners and for recognition systems. Opus, standardised by the IETF in 2012, adapts between speech and music modes and is the default codec for audio in WebRTC.
Codecs and containers
A codec is often confused with the file format that holds it. The container is the wrapper: it stores one or more encoded streams along with timing information, chapter markers and metadata. M4A and MP4 files usually hold AAC, Ogg files hold Vorbis or Opus, WebM holds Opus alongside video, Matroska can hold almost anything, and WAV usually holds uncompressed PCM but can hold other codecs too. The same AAC stream can be moved from one container to another without re-encoding, which is called remuxing and keeps the audio untouched.
This matters for anyone writing ingestion code. A file extension or declared MIME type names the container, not the codec, so a .m4a file might contain AAC or ALAC, and a .wav file might contain PCM or a compressed stream. File type detection identifies the container from its bytes, and a tool such as ffprobe then lists the streams inside with their codecs, sample rates, channel counts and durations. Descriptive tags such as ID3 tags live in the container or in a metadata block, separate from the audio stream. The same codec and container split applies to video, covered in the entry on video codecs and the comparison of MP4 and MOV.
How codecs affect transcription
Speech to text models do not care about codecs directly, because audio is decoded to PCM before recognition. They care about what the codec left behind. A modern lossy codec at a moderate bitrate preserves speech well, and recognition accuracy on a 64 kbps Opus or 128 kbps MP3 recording is usually close to that of the uncompressed original. Very low bitrates, narrowband telephone audio and audio that has been transcoded several times remove the high-frequency detail that distinguishes consonants such as s, f and th, and the word error rate rises accordingly.
Most recognition systems resample incoming audio to a fixed rate, often 16,000 samples per second, and mix it to mono. Upsampling a narrowband call recording to 16 kHz does not restore the missing frequencies, so call centre audio is best handled by models trained on telephone speech. Channel layout matters too: a call recorded with each speaker on a separate stereo channel makes speaker diarization much easier than a mono mix, so splitting channels before decoding to mono preserves useful information. Silence and noise handling, including voice activity detection, also behaves differently on heavily compressed audio, where codec artefacts can resemble faint speech.
Choosing a codec for an AI pipeline
For storage of source recordings, keep the original file as delivered and avoid converting it unless there is a clear reason. If you control capture, record speech at 16 kHz or higher with a modern codec at a moderate bitrate; Opus at 24 to 48 kbps or AAC at 64 to 128 kbps gives clear speech at a fraction of the size of PCM. For music or audio that will be edited, keep a lossless master. For live voice applications, such as voice agents, low-delay codecs like Opus matter as much as quality, since every few milliseconds of buffering adds to the response time the caller notices.
When a pipeline must accept whatever users upload, the practical rule is to decode everything to a single PCM format at the recognition stage and leave the stored original alone. That keeps one code path for audio transcription, preserves the best available source for reprocessing later, and avoids generation loss from repeated encoding.
Worked example: a mixed audio library
A research team collects 1,200 hours of recordings: interviews as 128 kbps MP3, phone calls as 8 kHz WAV files holding G.711 audio, webinars as AAC inside MP4 video, and some field recordings as FLAC. The figures here are illustrative. An ingestion job inspects each file’s container and streams, records codec, sample rate, channel count and duration as structured fields, and stores the originals untouched.
At transcription time every file is decoded to 16 kHz mono PCM, except the dual-channel calls, which are split so each speaker is transcribed separately. Accuracy is high on the interviews and webinars and noticeably lower on the narrowband calls, so the team tags call transcripts with a lower confidence level and routes low-scoring passages to human review. Because the codec metadata was recorded at ingestion, that routing rule is a simple filter rather than a reprocessing job.
How Exabase handles audio codecs
Exabase decodes and processes audio so that applications do not have to manage codec handling themselves. Upload MP3, WAV or any other major audio type as Resources in a Base and the file is transcribed and indexed automatically, while the original is kept as uploaded. Extract accepts the same files through one endpoint and returns a transcript with timestamps, the duration and common metadata including the detected MIME type and file size. The submitting jobs guide covers uploads and URLs, and the audio transcription and audio to JSON tools show the output for a single file.
Once indexed, spoken content is searchable through Deep Search, which returns matching passages with start and end timestamps so a result can link to the exact moment in a recording. That is the basis of audio search across podcasts, calls and meetings, and of the meeting assistants and podcast audio search use cases. The file extraction solution describes the general pattern, and teams comparing transcription providers can start with the best speech to text APIs roundup or the Exabase vs AssemblyAI comparison.
Frequently asked questions
What is the difference between a codec and a file format?
The codec encodes and decodes the audio stream. The file format, or container, wraps that stream with timing and metadata. An M4A file is a container that usually holds AAC audio.
Is MP3 or AAC better?
AAC generally sounds better than MP3 at the same bitrate, especially below 128 kbps. MP3 still has the widest playback support on older devices.
Which codec is best for speech?
Opus is a strong default for speech, giving clear audio at 24 to 48 kbps with low delay. For archival recordings, a lossless codec such as FLAC keeps every detail.
Does audio compression reduce transcription accuracy?
Moderate lossy compression has little effect. Very low bitrates, narrowband telephone audio and repeated transcoding remove detail that recognition models rely on and increase errors.
What is a lossless audio codec?
A lossless codec such as FLAC or ALAC compresses audio without discarding information, so decoding returns the exact original samples.
How do I find out which codec a file uses?
Use a media inspection tool such as ffprobe or MediaInfo, which reads the container and lists each stream’s codec, sample rate, channels and duration.
Related pages: bitrate, sample rate, video codec, ID3 tags, MP4 vs MOV, speech to text, word error rate, audio search, file extraction, best speech to text APIs