Too Cool for Internet Explorer

What the FLAC? A journey from MP3 to FLAC

what-the-flac-a-journey-from-mp3-to-flac

One of my current idle tasks is to nurse and improve my music collection. A result of that work is a pretty mature specification of how my digital music collection should look like - properly tagged and a consistent file and directory structure of course.

The most recent spleen is the migration from MP3 to FLAC. That spleen actually emerged during a nasty file system corruption which was caused by the experimental ext4 driver.  As a consequence,  a considerable amount of recently created MP3 files had audible glitches.

While I tried to find all broken music files, I realized that MP3 wasn’t exactly designed to check them for integrity - it’s lossy in every meaning :?

FLAC is different - it’s lossless in every meaning :) At least one is able to indicate a broken file as such: FLAC integrates a 16-bit CRC for each frame and a MD5 signature of the unencoded audio data. It’s also open, fast and well supported by almost every player software out there. As disk space is becoming cheaper and cheaper and the transcoding speed (eg. FLAC → OGG) is even faster as the transfer speed of USB 2.0, there are few counter arguments remaining.

How to keep Amarok statistics?

My favorite audio player is Amarok. Besides many other features it tracks which songs you like, when and how often you played them.

During the migration I wouldn’t want to lose those stats. This is where a nice feature comes into play: Amarok File Tracking (AFT). It enables Amarok to identify an audio track, even if it is moved or renamed. Moving/Renaming, isn’t that exactly what we’re doing? Right!

I asked an Amarok developer (Jeff Mitchell) how AFT could be abused leveraged for my needs. He immediately fixed AFT to work with FLAC and gave me migration instructions:

  1. Use amarok_afttagger to embed identifiers into your MP3s.
  2. Make sure that those files are scanned into Amarok (full rescan), so
    the UIDs in the tags overwrite the ones that were auto-generated before.
  3. Use a script to transfer the identifiers into the FLACs.
  4. Remove the MP3s from Amarok’s collection, add the FLACs, and do a
    full rescan.

Step 3. might be most difficult.
AFT uses the UFID header in case of a MP3 (ID3) and a Vorbis comment in case of a FLAC.
To transfer the unique identifier from MP3 to FLAC all you need to do is to “copy/paste” that tag.

After you successfully ran step 2. you can dump the UFID of a MP3 file using some ID3 tool like eyeD3:
12 Clarity.mp3 [ 7.96 MB ]
——————————————————————————–
Time: 4:03 MPEG1, Layer III [ ~274 kb/s @ 44100 Hz - Joint stereo ]
——————————————————————————–
ID3 v2.4:
title: Clarity artist: Jimmy Eat World
album: Clarity year: 1999
track: 12/13 genre: Rock (id 17)
Publisher/label: Capitol Records
Unique File ID: [Amarok 2 AFTv1 - amarok.kde.org] 62e164257a0c5c01761ac7740269d31c
Unique File ID: [http://musicbrainz.org] fec93932-51af-4f05-8aa1-3457bbc1e3b4

The identifier (62e164257a0c5c01761ac7740269d31c) can then be inserted into the corresponding FLAC file.

Automation

To automate the transfer of the identifier, I wrote a small python script (using Mutagen).
Given the case, that all files are properly assigned a MusicBrainz trackid (eg. using Picard), it can be used like that:

# cd /music/interpret/mp3-album
# amarok-ufid.py dump
# cp ufid.dump /music/interpret/flac-album
# cd /music/interpret/flac-album
# amarok-ufid.py apply

done!

No Comments yet »

RSS feed for comments on this post. TrackBack URI

Leave a comment

XHTML: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Powered by WordPress with GimpStyle Theme design by Horacio Bella. Get Entries and comments.