I host a podcast called Breaking Change. Like many podcasts, speech is recorded in mono audio with segments divided by stereo jingles (audio "stingers"). I always wanted to add support for chapters, but for the fact I am very lazy.
Enter autochapter
. It analyzes your podcast M4A/MP3 file, identifying each time the audio switches from mono to stereo. It then remuxes your audio file to rewrite the chapter table with whatever names you give each segment.
brew install searlsco/tap/autochapter
How you invoke autochapter
depends on how you decide to name the chapters for each of your podcast's segments.
You can set each chapter name by repeating the --segment
or -s
flag like this:
autochapter \
-s Intro \
-s Follow-up \
-s "Aaron's Pun" \
-s News \
-s Recommendations \
-s Mailbag \
-s Outro \
v44.mp3
Which will save v44-chapters.mp3
If, like me, your podcast always features the same segments, you can point autochapter
to a text file with the --segment-file
option:
Intro
Follow-up
Aaron's Pun
News
Recommendations
Mailbag
Outro
You can then run:
autochapter --segment-file breaking-change.txt v44.mp3
If you don't provide segments, they'll be named Chapter 01
, Chapter 02
, and so on.
After each run, autochapter
will output the chapters in the format YouTube expects. If you paste them into your video's description, the chapters will appear in the YouTube player.
Chapters:
0:00 Intro
24:11 Follow-up
53:45 Aaron's Pun
56:14 News
1:49:03 Recommendations
2:03:52 Mailbag
2:33:11 Outro
Usage: autochapter [-s SEGMENT]... [--segment-file PATH] [-o OUTPUT] INPUT
Create podcast chapters from stereo stingers.
Options:
-s, --segment NAME Segment title (repeat per segment, e.g. `-s Intro`)
--segment-file PATH File with one segment name per line
-o, --output PATH Output file (default: input basename with -chapters.ext)
-h, --help Show this help
Be sure that you're not exporting variable bitrate (VBR) MP3s. Apple's AVFoundation stack doesn't play them right, causing timestamp drift. Export in constant bitrate (CBR) or as AAC (M4A) instead.
Under the hood, autochapter
does this:
- Encodes the file as PCM to facilitate analysis with ffmpeg, downsampling the audio to 12 kHz to speed things up
- Analyzes the left/right energy difference with an inline Python script to detect stereo audio (the heuristic we use to identify the stingers)
- Builds an intermediate FFmetadata file with the timestamps of the start of each detected stinger
- Remuxes the original audio so only the chapter table changes
A full two-hour show usually finishes in a couple of minutes on modern hardware.