Easy FLAC to MP3 mirroring with mp3fs
May 17, 2010 in digital music by Dan Gravell
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:
- They have to be run each time your music library changes, because they are manual. This can be mitigated by running the job periodically
- They use more storage space, because a separate copy of your FLACs in MP3 format are kept
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:
- You don't need to tell mp3fs when the music library has changed
- There's no extra storage space required to store your MP3 mirror of your FLAC files
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.