---
title: "TIL: What afinfo Reveals About Your Audio Files"
description: "afinfo prints every audio file property macOS knows about: sample rate, channels, bit depth, duration, and codec. Essential for debugging STT pipeline issues."
canonical: https://lukeocodes.dev/til-afinfo-audio-inspection
type: article
locale: en_GB
published: 2026-05-12T00:00:00.000Z
modified: 2026-05-12T00:00:00.000Z
authors:
  - Luke Oliff
section: TIL
tags:
  - TIL
  - Voice AI
  - Engineering
feed: https://lukeocodes.dev/rss.xml
search: https://lukeocodes.dev/search.json?q={query}
schema:
  - "@context": https://schema.org
    "@graph":
      - "@type": Organization
        "@id": https://ably.com/#organization
        name: Ably
        url: https://ably.com
      - "@type": WebSite
        "@id": https://lukeocodes.dev/#website
        url: https://lukeocodes.dev
        name: Luke Oliff
        alternateName: lukeocodes
        inLanguage: en
        publisher:
          "@id": https://lukeocodes.dev/authors/luke#person
        description: Personal blog and writing by Luke Oliff — developer relations, voice AI, developer experience.
        potentialAction:
          - "@type": SearchAction
            target:
              "@type": EntryPoint
              urlTemplate: https://lukeocodes.dev/blog/search?q={search_term_string}
            query-input: required name=search_term_string
      - "@type": Person
        "@id": https://lukeocodes.dev/authors/luke#person
        name: Luke Oliff
        url: https://lukeocodes.dev/authors/luke
        description: Staff engineer and Staff Tech Lead for Developer Experience at Ably. Writing about developer relations, AI, and the voice industry, from the UK.
        mainEntityOfPage: https://lukeocodes.dev/authors/luke
        givenName: Luke
        familyName: Oliff
        image: https://lukeocodes.dev/authors/luke.jpg
        jobTitle: Staff Tech Lead, Developer Experience
        worksFor:
          "@id": https://ably.com/#organization
        sameAs:
          - https://www.linkedin.com/in/lukeocodes
          - https://github.com/lukeocodes
          - https://bsky.app/profile/lukeocodes.dev
          - https://x.com/lukeocodes
          - https://hashnode.com/@lukeocodes
          - https://dev.to/lukeocodes
        knowsAbout:
          - Developer Relations
          - Developer Experience
          - Voice AI
          - Text-to-Speech
          - Answer Engine Optimisation
          - Search Engine Optimisation
          - Open Source
          - Developer Tooling
          - API Design
          - Speech-to-Text
          - Voice Agents
          - Community Building
        knowsLanguage:
          - English
        nationality: British
        alumniOf:
          - "@type": Organization
            name: The Open University
  - "@context": https://schema.org
    "@graph":
      - "@type": Organization
        "@id": https://ably.com/#organization
        name: Ably
        url: https://ably.com
      - "@type": Person
        "@id": https://lukeocodes.dev/authors/luke#person
        name: Luke Oliff
        url: https://lukeocodes.dev/authors/luke
        description: Staff engineer and Staff Tech Lead for Developer Experience at Ably. Writing about developer relations, AI, and the voice industry, from the UK.
        mainEntityOfPage: https://lukeocodes.dev/authors/luke
        givenName: Luke
        familyName: Oliff
        image: https://lukeocodes.dev/authors/luke.jpg
        jobTitle: Staff Tech Lead, Developer Experience
        worksFor:
          "@id": https://ably.com/#organization
        sameAs:
          - https://www.linkedin.com/in/lukeocodes
          - https://github.com/lukeocodes
          - https://bsky.app/profile/lukeocodes.dev
          - https://x.com/lukeocodes
          - https://hashnode.com/@lukeocodes
          - https://dev.to/lukeocodes
        knowsAbout:
          - Developer Relations
          - Developer Experience
          - Voice AI
          - Text-to-Speech
          - Answer Engine Optimisation
          - Search Engine Optimisation
          - Open Source
          - Developer Tooling
          - API Design
          - Speech-to-Text
          - Voice Agents
          - Community Building
        knowsLanguage:
          - English
        nationality: British
        alumniOf:
          - "@type": Organization
            name: The Open University
      - "@type": BlogPosting
        "@id": https://lukeocodes.dev/til-afinfo-audio-inspection#article
        headline: "TIL: What afinfo Reveals About Your Audio Files"
        alternativeHeadline: "TIL: What afinfo Reveals About Your Audio Files"
        description: "afinfo prints every audio file property macOS knows about: sample rate, channels, bit depth, duration, and codec. Essential for debugging STT pipeline issues."
        datePublished: 2026-05-12T00:00:00.000Z
        dateModified: 2026-05-12T00:00:00.000Z
        url: https://lukeocodes.dev/til-afinfo-audio-inspection
        mainEntityOfPage: https://lukeocodes.dev/til-afinfo-audio-inspection
        inLanguage: en
        author:
          - "@id": https://lukeocodes.dev/authors/luke#person
        isPartOf:
          "@id": https://lukeocodes.dev/#website
        keywords: TIL, Voice AI, Engineering
        articleSection: TIL
        about:
          - "@type": Thing
            name: Voice AI
        abstract: Every audio file carries its specs in the header. Sample rate, channels, bit depth, codec. Before you send anything to a speech-to-text API, one command tells you if the audio and the endpoint agree.
        speakable:
          "@type": SpeakableSpecification
          cssSelector:
            - .post-tldr
            - h1
        image: https://lukeocodes.dev/blog/til-afinfo-audio-inspection/hero.png
        wordCount: 528
        timeRequired: PT3M
        publisher:
          "@id": https://ably.com/#organization
      - "@type": BreadcrumbList
        itemListElement:
          - "@type": ListItem
            position: 1
            name: Home
            item: https://lukeocodes.dev
          - "@type": ListItem
            position: 2
            name: Writing
            item: https://lukeocodes.dev/blog
          - "@type": ListItem
            position: 3
            name: "TIL: What afinfo Reveals About Your Audio Files"
            item: https://lukeocodes.dev/til-afinfo-audio-inspection
---

[Luke Oliff.](/)

- [Blog](/blog)
- [CV](/cv)
- [Uses](/uses)
- [User manual](/user-manual)
- [Living with ADHD](/living-and-working-with-adhd)
- [RSS](/rss.xml)

[Luke Oliff · Writing](/blog)

# TIL: What afinfo Reveals About Your Audio Files

May 2026 · [TIL](/blog/category/til) · 3 min read · [Luke Oliff](/authors/luke)

Every audio file carries its specs in the header. Sample rate, channels, bit depth, codec. Before you send anything to a speech-to-text API, one command tells you if the audio and the endpoint agree.

```bash
afinfo speech.wav
```

Output:

```
File:           speech.wav
File type ID:   WAVE
Num Tracks:     1
----
Data format:     1 ch,  48000 Hz, lpcm (0x0000000E)
                 24-bit big-endian signed integer
estimated duration: 93.250 sec
audio bytes: 13419000
```

48 kHz, 24-bit, stereo. The STT endpoint expected 16 kHz, 16-bit, mono. There was your problem.

`afinfo` is built into macOS. It reads the file headers and dumps every property the system knows about. Sample rate, channel count, bit depth, codec, duration, byte count. Everything you need to check before you send audio to a speech-to-text API.

## What afinfo reveals about your audio files

The first thing is the data format line. You want:

- `1 ch` (mono) for most STT endpoints. Two channels means the API either mixes them down or processes one and discards the other.
- `16000 Hz` or whatever sample rate your provider expects. A mismatch here produces garbage transcripts with no error message.
- `16-bit` signed integer. The most common format for speech-to-text pipelines. 24-bit works but wastes bandwidth.

The second is the duration and byte count. If the estimated duration is way off or the byte count looks small, the file might be truncated or have trailing metadata that inflates the header size.

```bash
# Quick check: is it even the right format?
afinfo speech.wav | grep "Data format"

# Brief mode for scripting
afinfo -b speech.wav
```

The `-b` (brief) flag prints everything on one line. Good for scripts or when you want the answer in under a second.

```bash
afinfo -b speech.wav
# /path/to/speech.wav: WAVE, 1 ch, 16000 Hz, lpcm (0x0000000E) 16-bit big-endian signed integer
```

## Why afinfo matters for STT debugging

Most STT issues are not model problems. They are format mismatches that the API does not tell you about. The audio plays fine in a media player. QuickTime shows a waveform. But the sample rate is wrong, or the bit depth is unexpected, or the file is stereo when the pipeline assumes mono. The API returns a transcript that reads like a fax machine falling down stairs, with no error and no hint about why.

`afinfo` catches all of these in one command. No SDK needed. No API call wasted.

### Can I use afinfo on compressed audio like MP3 or AAC?

Yes. afinfo reads any format QuickTime handles. For MP3 files it prints the codec info and bitrate instead of raw PCM properties. The output looks different but the key fields (sample rate, channels, duration) are the same.

### Is there a way to fix audio format issues from the terminal?

Use `afconvert` for that. It converts between audio formats using macOS Core Audio. `afconvert speech.wav -o speech-16kHz.wav -f WAVE -d LEI16@16000` is the pattern for creating a 16-bit, 16 kHz mono WAV file.

### Does afinfo work on Linux?

No, it's macOS-only. On Linux use `ffprobe` (from ffmpeg) or `mediainfo` for the same functionality. The output format differs but the fields are the same.

[← Newer: Why Speaker Diarization Is the Hardest Problem in Voice AI](/why-speaker-diarization-hardest-problem-voice-ai)

[All posts](/blog) →

## Search this site

`GET https://lukeocodes.dev/search.json?q=<words>` returns matching posts as JSON, each with its page URL and its markdown URL. Add `&limit=<1-50>` for more than 10. How it works: [/blog/search](https://lukeocodes.dev/blog/search.md).

```sh
curl "https://lukeocodes.dev/search.json?q=developer+relations"
```

---

© 2026 Luke Oliff. Posts live at the root of this site.

- [GitHub](https://github.com/lukeocodes)
- [LinkedIn](https://www.linkedin.com/in/lukeocodes)
- [X](https://x.com/lukeocodes)
- [Bluesky](https://bsky.app/profile/lukeocodes.dev)
- [Email](mailto:luke@lukeoliff.com)
- [RSS](/rss.xml)

## Cookies

This site sets one analytics cookie, from Google Analytics, and only in a browser that accepts the cookie banner. A client that does not run scripts sets no cookies, so there is nothing to accept or decline here.

[Cookie policy](/cookies)
