paint-brush
How I Compressed Each Podcast Episode to Less Than a Floppy Disk's 1.44 MB Limitby@Haas
323 reads
323 reads

How I Compressed Each Podcast Episode to Less Than a Floppy Disk's 1.44 MB Limit

by SeanAugust 7th, 2020
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

Advent of Computing: extreme lo-fi edition. How I Compressed Each Podcast Episode to Less Than a Floppy Disk's 1.44 MB Limit. The trick to all of this is encoding. MP3 is the most familiar, but you also have formats with better compression like AAC, or lossless formats like FLAC and WAV. AMR is an audio coded that's widely used for transmitting telephone calls over GSM networks, but it can just as easily be used to encode full audio files.

Companies Mentioned

Mention Thumbnail
Mention Thumbnail
featured image - How I Compressed Each Podcast Episode to Less Than a Floppy Disk's 1.44 MB Limit
Sean HackerNoon profile picture

Do you want to learn about the history of computers? Are MP3 files just to darn big? Can you only listen to audio streamed off a floppy disk? Well, then I have just the podcast for you. Allow me to introduce Advent of Computing: extreme lo-fi edition. Each episode is guaranteed to be under 1.44 megabytes.

If you were being generous you could say I work in the broadcasting industry, I'm a software developer for an audio-focused CDN. I also host a computer history podcast on the side. In my day-to-day life I tend to do a lot more encoding and transcoding that most people. Usually the goal with transcoding is to turn some format audio file into another format while maintaining its quality. But there's no reason to you can't go the other way. One great example is STRUDELSOFT, a vaporwave label that only publishes music on floppy disks. They can fit an album, albeit a short one, on a single 1.44 megabyte disk. That got me to thinking, just how far does that rabbit hole go? As it turns out, pretty far. And with a little doing it's possible to actually fit close to an hour long podcast episode on a single disk.

The trick to all of this is encoding. Now, there are probably well over a hundred different ways to encode and package up audio. MP3 is the most familiar, but you also have formats with better compression like AAC, or lossless formats like FLAC and WAV. Those all have their place, but they produce pretty big files. Lucky for us, there are other options. The one I went with, and I think the only one that can actually work for these purposes, is the Adaptive Multi-Rate codec. AMR is an audio coded that's widely used for transmitting telephone calls over GSM networks, but it can just as easily be used to encode full audio files. One of its major benefits is that it's tiny. Like, really tiny. If you've ever made a call on a cellphone you've experienced the glory of AMR. Boasting a fixed 8kHz sampling rate, and able to go as low as 1.8 kbit/s, it doesn't sound all that good. But hey, it's not like we are going to get silky smooth audio off a floppy disk anyway.

For encoding my go-to is always FFmpeg. However, the stock install I have handy right now wasn't built with AMR encoding support. But never fear, SoX(The SOund eXchange) comes out of the box with full AMR support(at least out of apt). The final setup I came up with is actually a combination of the two programs. Even with aggressively low bitrates my files were still a little too big. So I do a first pass through FFmpeg to speed up the audio slightly(I'm using 1.2 times right now). Then I encode it down as AMR with a bitrate around 5 kbit/s. The scripting looks something like this:

ffmpeg -i big_input.mp3 -filter:a "atempo=1.2" tmp.mp3
sox tmp.mp3 -C 0 tiny_output.amr

The gains, or rather the losses, from this procedure are impressive. Starting with a 72 MB MP3 file, just over 45 minutes of audio, I can shave that down to 1.2 MB. That's small enough to fit an whole episode onto a floppy disk. So, how far can I take this? Can I create a full podcast feed with nothing but floppy-sized episodes?

Going Further!

There is one big issue with this approach. No matter what fancy codecs or compression algorithms you use there is always an upper limit to how much data you can squeeze onto a floppy disk. For AMR and our given encoding settings we can calculate this limit pretty easily. Encoding at 5.15 kbit/s we can get just over 38 minutes of audio down to 1.44 MB. By speeding up the audio 1.3 times we can up that to about 45 minutes. This approach gives us what I'd calla mediocre audio quality, it's a little fast and it's extra crunchy. Just imagine listening to a JPEG. For most of my back catalog of episodes this is fine, but a handful of my episodes are actually over 45 minutes long. And being a bit of a completionist I can't leave those out of my lo-fi feed. To get those to fit I need to get a little more aggressive, so a few episodes had to be sped up 1.35 times just to get them down to size. With everything converted building up an RSS feed is a since, just replace the normal MP3 files paths with links to my crispy tunes.

This is where we run into a big roadblock. Podcasts are distributed via RSS feeds, basically a big XML file that lists each episode, all the details about that episode, and where links to where the audio files live. Those RSS files are then passed off to a directory like Apple Podcasts, Spotify, or Google Podcasts. You can theoretically put anything you want in an RSS feed, but the final arbiters of what is allowable for a podcast are those directories. Apple Podcasts, as well as most large directories, only support M4A, MP3, MOV, MP4, M4V, and PDF(why?) files as valid content. Note the lack of our exotic low-bitrate format of choice. So if we craft a beautiful RSS feed full of AMR encoded episodes we can't get it out to the world via normal channels.

Some experimentation shows that I can get really close to the 1.44 MB cut off by transcoding my AMR files back to MP3. This works because the process of generating my super small audio files strips out a lot of data, it's not reversible. But even with that I end up getting around a 2 MB MP3 file, and that's just too darn big. The problem I run into is that none of the permitted audio formats support low enough bitrates or sample rates to squeeze everything down. The best I can get is 16 kbit/s at 11 kHz. The beautifully lo-fi feed won't be showing up on any major directories, at least that's what I thought.

There is a weird coda to this project. Once I had everything converted to my liking and built up a valid RSS feed I got a little curious. If I listen to what most podcast directories say about their requirements then I shouldn't be able to submit this feed to any major platform. But hey, docs can be wrong. So I decided to try submitting this lo-fi feed around a few places. As expected Apple Podcasts just gave a validation error, but Spotify actually accepted the feed and published it. Stranger still, it can play back in browser. This shocked me because AMR isn't supported in any major web browser, there are some JS players that almost work but are pretty flaky. I'm at a bit of a loss as to how they support this, unless they are transcoding every incoming podcast episode to an MP3 somewhere along the line. But hey, it works. You can see for yourself here: https://open.spotify.com/show/4NmReVKmbeD8Apvj0HgYkU

If you'd like a more direct method, then the raw RSS feed is available here: https://adventofcomputing.com/flop-cast/flop-cast.rss

Should anyone actually listen to this podcast feed? Probably not, but this is a fun proof of concept. If you want to listen to my podcast proper I do have a normal feed, one with properly encoded MP3 files and much better audio quality. You can find everything about Advent of Computing at my website (http://adventofcomputing.com/).