Easy FLAC to MP3 mirroring with mp3fs

Storing music in FLAC format is an excellent choice. It's higher quality than MP3 and, importantly, is 'lossless' which means you can always convert it to another format. Not all players support it though, so sometimes you need to have your same music in a different format. How do you accomplish this while not wasting time or storage space? mp3fs is a fully automatic and storage efficient way of keeping a copy of your FLAC library in MP3 format.

What are the other options for converting from FLAC to MP3? First, it can be done manually on a file by file or bulk basis. Some converters (or 'transcoders') work with a GUI while some work on the command line. Examples of both are dBpoweramp Music Converter and flac2mp3.

There are two problems with the manual approaches:
  1. They have to be run each time your music library changes, because they are manual. This can be mitigated by running the job periodically
  2. They use more storage space, because a separate copy of your FLACs in MP3 format are kept
Instead, on my Linux home server, I use mp3fs. mp3fs represents your FLAC folders as MP3 folders. You simply point mp3fs at your FLAC directory and tell it where the resulting MP3 files should end up. No MP3 files are created as such, it just looks like they are.

First decide where you want your mp3s to be stored. Let's say you want them stored in /mnt/music/mp3. This should be an empty directory. Now, choose your FLAC directory. Let's say this is /mnt/music/flac:

gravelld@gravelld-laptop:~$ ls /mnt/music/flac
Alison_Balsom Mint Royale Oasis Suede Various
Louis_Armstrong Nelly_Furtado Pendulum The_Chemical_Brothers

Meanwhile:

gravelld@gravelld-laptop:~$ ls /mnt/music/mp3
gravelld@gravelld-laptop:~$

Nothing in there yet! So, let's weave some mp3fs magic:

sudo mp3fs -b 192 /mnt/music/flac /mnt/music/mp3 -o allow_other,ro

Now:

gravelld@gravelld-laptop:~$ ls /mnt/music/mp3
Alison_Balsom Mint Royale Oasis Suede Various
Louis_Armstrong Nelly_Furtado Pendulum The_Chemical_Brothers

And interestingly:

gravelld@gravelld-laptop:~$ sudo ls /mnt/music/mp3/Oasis/Definitely\ Maybe
01-Rock 'N' Roll Star.mp3 07-Bring It On Down.mp3
02-Shakermaker.mp3 08-Cigarettes & Alcohol.mp3
03-Live Forever.mp3 09-Digsy's Dinner.mp3
04-Up In The Sky.mp3 10-Slide Away.mp3
05-Columbia.mp3 11-Married With Children.mp3
06-Supersonic.mp3 cover.jpg

These are FLAC files stored in the FLAC directory, but now they appear to be MP3 files too. The important bit here is that these MP3 files are not actually stored on the hard disk. Rather, each time you access the MP3 directory or files therein, mp3fs mimics the directory structure or creates the MP3s on-the-fly. This means:
  1. You don't need to tell mp3fs when the music library has changed
  2. There's no extra storage space required to store your MP3 mirror of your FLAC files
Some people say "storage is cheap". I agree, but your time isn't. Storing two separate trees of music is duplication and therefore imposes a management cost. It's not just adding music either, it's deleting it and modifying it too that would, with a manual solution, require a rebuild of your MP3s.

That is how I mirror my FLACs to MP3s on my Linux home server, and I haven't had to think about it again since.
tags: server linux formats mp3fs bulk automatic

The Music Library Management blog

Dan Gravell

I'm Dan, the founder and programmer of bliss. I write bliss to solve my own problems with my digital music collection.