Audio codecs are one of those topics where everyone has an opinion, and most of those opinions come from one listen through cheap earbuds on a noisy train. We are not going to pretend we have golden ears either. What we can do is explain how the codecs work, read the numbers, and show what Spotube actually asks for when you press play. Where we could not verify something, we say so.
Lossless and lossy are different bets
A digital recording (PCM) is just a list of numbers. CD audio stores 44,100 samples per second for each channel, and each sample is 16 bits. For stereo that is 44,100 x 16 x 2 = 1,411,200 bits per second, or about 1411 kbps. The 44.1 kHz sample rate can represent frequencies up to 22.05 kHz, which is above what most people can hear, and the hearing of most adults tops out well below that.
A lossless codec like FLAC looks for redundancy in those numbers, much like a zip file does, and rebuilds the exact same samples when it decodes. The file is smaller, often around 50 to 60 percent of the raw size depending on the music, and not a single sample changes.
A lossy codec makes a different bet. It does not try to rebuild the samples. It tries to rebuild something that sounds the same to a listener. That one sentence is the whole trick, and it is also where the arguments start.
Your ears have blind spots, and codecs use them
The main trick is psychoacoustic masking. A loud sound makes quieter sounds that are close to it in frequency (and, to a lesser extent, in time) hard to hear. An encoder builds a rough model of this, works out a masking threshold, and spends no bits on anything that falls below it.
The same quiet tone is masked next to a loud one and audible far from it
The model is an approximation, and it behaves differently for different music. Dense rock mixes hide a lot of sins. A solo piano, a triangle or a single voice in a quiet room leaves very little cover, so artifacts such as pre-echo on sharp attacks are easier to notice. That is why the "can you hear it" answer depends on the track as much as on the codec.
Bitrate is a budget, not a grade
Bitrate is how many bits per second the encoder is allowed to spend. It is a useful number, but it is only comparable between codecs and encoders that are doing similar work. A modern encoder spending 128 kbps on a perceptual model can sound better than an older design at a higher bitrate, so a bitrate number on its own tells you about the size of the file more than the quality of the sound.
One second of audio, five budgets
The diagram above is the budget view. Raw CD audio spends more than five times the bits of Spotube's default 256 kbps. Everything that follows is about how much of that gap you can actually hear.
The codecs, one paragraph each
MP3 and AAC
MP3 (MPEG-1 Layer III) dates back to the early 1990s and is still everywhere. AAC is its successor. At the same bitrate it is generally more efficient, and it is the usual codec inside .m4a and MP4 files. In published listening tests, AAC at around 256 kbps is very hard for most listeners to tell apart from the original, and MP3 generally needs a higher bitrate to reach the same point. Treat "very hard to tell apart" as a statement about averages, not about your particular speakers.
Opus
Opus is the codec we care about most in Spotube. It is standardized in RFC 6716 and is built to handle both speech and music. It supports frame sizes from 2.5 ms up to 60 ms, which is why it is used for low-latency voice and video calls. Internally it combines a speech-oriented layer (SILK) with a music-oriented one (CELT). For stereo music, Opus at around 96 to 128 kbps is widely regarded as a very efficient choice, and in most published comparisons it beats MP3 and AAC at the same bitrate. Opus is usually carried in an Ogg or WebM container.
FLAC
FLAC is lossless, open, and decodes bit for bit back to the original. It has no fixed bitrate, because the size depends on how compressible the music is. It is the right choice when the file is the thing you want to keep, and a poor choice when you need small files on a slow connection.
What Spotube actually asks for
The defaults live in UserSettings in spotube/composeApp/src/commonMain/kotlin/org/spotube/spotube/modules/settings/SettingsModels.kt. Here is what they say:
-
streamingMusicFormatdefaults toopusin awebmcontainer, andstreamingMusicQualitydefaults toAudioQuality.Lossy(bitrate = 256_000). The comment ondefaultStreamingMusicFormat()gives the reason for the container: opus/webm works on every platform because the players in use, ExoPlayer and VLC, can both decode it.
The built-in audio plugin is always selected, and it offers the presets 44, 96, 128 and 256 kbps for both Opus/WebM and AAC/MP4 (RealNewPipeAudioAPI, under spotube/composeApp/src/commonMain/kotlin/org/spotube/spotube/core/zipline/plugin_apis/newpipe_yt/). Every quality it lists is lossy. The bitrate is written in bits per second in code, so 256_000 means 256 kbps.
The plugin API describes those qualities as a sealed interface. A plugin can offer either a lossy bitrate or a lossless sample rate and channel count. This is the model, from spotube/plugin_interfaces/src/commonMain/kotlin/org/spotube/plugin_interfaces/plugin_apis/audio/AudioModels.kt:
@Serializable sealed interface AudioQuality { @Serializable @SerialName("lossy") data class Lossy(val bitrate: Int) : AudioQuality @Serializable @SerialName("lossless") data class Lossless( val sampleRate: Int, val channels: Int ) : AudioQuality } The built-in provider only lists lossy qualities today. A plugin that wants to offer FLAC can, because the lossless variants are already part of the contract.
Preferences are rankings, not filters
A setting like "256 kbps Opus" is a wish, not a demand. The plugin might not offer that exact stream, and the app has to pick the best one it has. The selection lives in spotube/composeApp/src/commonMain/kotlin/org/spotube/spotube/core/server/StreamingUrlRepository.kt:
internal fun selectPreferredAudioStream( streams: List<AudioStream>, preferredFormat: AudioFormat, preferredQuality: AudioQuality): AudioStream? = streams.minWithOrNull( compareBy<AudioStream> { stream -> formatMismatchCount(stream, preferredFormat) }.thenBy { stream -> if (stream.matchesQualityType(preferredQuality)) 0 else 1 }.thenBy { stream -> stream.qualityDistance(preferredQuality) }.thenBy { stream -> stream.channelDistance(preferredQuality) } ) Nothing gets thrown out up front. Every candidate gets a sort key, and the lowest key wins. The keys are compared in order. First come codec and container mismatches, each counted separately. Next is whether the stream is lossy or lossless compared to what you asked for. Then comes the distance from the requested bitrate (or sample rate), and finally the channel count for lossless streams.
If the only stream on offer is 128 kbps Opus and you asked for 256 kbps Opus, you get the 128 kbps stream. The log records a QUALITY FALLBACK warning, and a FORMAT FALLBACK warning appears when the codec or container differs too.
An exact bitrate in the wrong format loses to the right format at a lower bitrate
With the default format, the built-in provider offers an exact opus/webm match, so the fallback path only runs when a plugin does not offer one.
Lossless is for keeping, not for hearing
Here is our honest take. On a phone, through typical earbuds, in a normal room, a good lossy codec at a decent bitrate is very hard to tell apart from lossless. If you are streaming on the train, the codec is rarely the weakest link in the chain.
Lossless matters for three other reasons.
- Re-encoding. Every lossy generation (generation loss) adds its own losses. Converting a lossy file into another lossy format stacks artifacts, so keep the master in a lossless format and encode from there.
- Archiving. A library you plan to keep for twenty years should be stored in a format that will not quietly degrade, and FLAC is open and well supported.
- Processing. Mixing, sample analysis and tagging tools are happier with the exact samples.
So our advice is simple. Listen with the lossy default. Keep the masters in FLAC if you have them.
Test it yourself with ABX
Do not trust us, or anyone else's forum post. Run an ABX test. You hear sample A (the original), then sample B (the encoded version), then X, which is randomly either A or B. You decide whether X is A or B. Repeat it at least 16 times. Random guessing gets about half right, and 12 correct out of 16 happens by luck only about 3.8 percent of the time, so that is a reasonable bar for "I can actually tell."
Make the test files from the same source with ffmpeg:
ffmpeg -i track.flac -c:a libopus -b:a 128k track-opus-128.opus ffmpeg -i track.flac -c:a libopus -b:a 96k track-opus-96.opus ffmpeg -i track.flac -c:a aac -b:a 256k track-aac-256.m4a Use music you know well, on the gear you actually listen with. Turn off any "enhancement" settings in the player, because they change the sound more than the codec does. If you cannot pass the test, that is useful information: the codec is good enough for you, and you can stop worrying about it.
Where that leaves you
Lossy codecs throw away what your ears are unlikely to miss, and modern ones are very good at it. Opus is the efficient choice for streaming, and FLAC is the one to keep when the master is the thing you care about. Spotube's defaults reflect that split: Opus at 256 kbps for streaming, and a ranking that falls back gracefully when a plugin does not offer what you asked for.
If you find a case where the defaults sound wrong on your setup, tell us which track and which codec, and we will look at it. The settings are there to change, and the ranking is short enough to read in one sitting.
References
- RFC 6716: Definition of the Opus Audio Codec is the Opus standard, including frame sizes and the SILK and CELT layers.
- Opus codec site covers Opus features and software, and its comparison page shows listening-test results against other codecs.
- FLAC is the project site for the open lossless codec.
- MP3 and AAC give the history and design of both lossy codecs.
- Auditory masking explains the psychoacoustic effect lossy encoders exploit.
- ABX test describes the blind comparison method and its statistics.
- Red Book (audio CD standard) lists the 44.1 kHz, 16-bit stereo format behind the 1411 kbps figure.
- Media3 ExoPlayer and VLC are the two players Spotube uses.
Originally published on spotube.org.





