Encode your FLAC collection to OGG Vorbis
December 1st 2020 | ~ 2 minute read
I have a lot of music, collected over the years, ripped from audio CDs, digitally downloaded, you name it. Most of my music is encoded in a lossless audio codec, FLAC. Now while FLAC is good for archiving, the size of the audio files can be quite large (300MB+ for a single album as an example). This is far from ideal on a portable device like a smartphone. On those devises audio quality is of less concern than file size, so what I do is strike the balance between quality and file size by using a lossy audio codec called OGG Vorbis.
Why Vorbis as opposed to MP3 for example? Well it comes down to two reasons, one practical and one ideological. Reason number one is simple, Vorbis is superior to MP3 in every aspect that matters, better compression (file sizes are smaller on the same bitrate) and less perceived quality loss just to name a few. The other reason is that while MP3 has been patented in the past, Vorbis is patent free and fully free software developed and supported by the Xiph.org Foundation.
Now for the fun part. There are a number of ways in which you could encode FLAC files to Vorbis, but what I use is the Xiph.org encoder, available in many GNU/Linux distributions under different package names. I'm using Arch Linux so the instructions will be valid for Arch and its derivatives like Manjaro.
To begin install a package named vorbis-tools.
sudo pacman -S vorbis-tools
This will install a binary named oggenc. This binary has many optional switches which you can list by either reading the manual page, or the help page, but what we're most interested in is the quality setting. This ranges from 1 (very low) to 10 (very high). The default setting is 3, but in my experience I find that going with 4 produces noticeably higher quality sound with minimal increase in file size. This setting is equivalent to a bitrate of roughly 120-160 kbit/s.
To encode a single file to OGG Vorbis you should run the program like this:
oggenc -q 4 file_name.flac
This will output a file named file_name.ogg in the source directory.
Now, encoding files one by one is certainly possible, but it's tedious. Fortunately oggenc takes an argument list of all the files you want to encode, so if you wish to encode all of the files in the directory you can just supply a wildcard like this:
oggenc -q 4 *.flac
Congratulations, you've just encoded some files to OGG Vorbis for listening on the go.