Tutorial

An MP3 Collection Editing Guide For Linux

FYI: This is a work in progress and not well tested at this point.

I’m fussy about my MP3 collection in that i like my music files to be properly formatted and free of errors. Having used Windows for most of my computing life, i had found many good editing and error correction tools over the years which served my needs quite well. Having recently moved to Linux Mint however, and not wanting to run Windows programs under Wine, i set out to duplicate my Windows tool chain on Linux and, as it turned out, i was more successful than i had anticipated so i decided to share my configuration.

This guide is primarily intended for formatting multiple audio files that have been downloaded from the web. In such a case, the files you download are often mis-tagged, damaged and/or not properly formatted and so we will use some pretty cool software tools to fix as many problems as we can. Note that all of the editing we will do with our MP3 files is non-destructive, meaning no re-encoding of the files is necessary and therefore there is no loss of sound quality.

Ideally, the end result of our work will be smaller, error-free MP3 music files that will have roughly the same volume according to the human ear.

This guide should work for all Debian-based distributions and possibly others.

Work Flow

Following are the basic steps i take to process my audio files:

  1. You may want to backup your audio files before you start
  2. File conversion if necessary (usually FLAC to MP3 in my case)
  3. Remove and rewrite all the meta tags
  4. Repair any errors in the files
  5. Trim all silence at the beginning and end of the tracks
  6. Normalize the volume so all tracks are about the same loudness
  7. Listen to all of the processed music to be sure it sounds good
  8. Organize the MP3’s into folders and/or playlists
  9. Copy the files to my devices

Tools Required

These are the tools i use to process audio files on Linux. You should check your package manager to see if they are all available and, if not, consider downloading them from their respective websites.

  • FFmpeg – a comprehensive file conversion and editing tool (it might be over-kill for just converting between FLAC and MP3, so feel free to use something else if you don’t require its many other capabilities)
  • puddletag – an audio tagging tool that is very similar to the much loved Mp3tag
  • MP3 Diags – a powerful Swiss Army Knife for repairing and tagging, if you like, MP3 audio files
  • Mp3splt – (yes, it’s spelled ‘splt’, not ‘split’) its primary use is to split MP3 files into multiple segments, however it works well for removing silence at the beginning and end of our MP3’s.
  • MP3Gain – for normalizing the volume across an entire album or multiple tracks (look in your package manager for the Linux version, or you can find it in the Ubuntu repository). This tool can be run via MP3 Diags.

Folder Structure

To keep things organized i would suggest creating the following folder structure. This is especially useful so that you don’t lose your place should you stop processing the files and wish to resume later.

  • -Incoming (drop files to be processed here if you don’t plan on working with them immediately)
  • -Replace (during processing, you may find that some files cannot be repaired and so you can drop them here until you find replacements)
  • 01 Convert
  • 02 Tagging
  • 03 Repair
    • Mp3splt_out
  • 04 Listen Test
  • 05 Organize
  • 06 Copy to Devices

Tool Settings

Following are only the most important settings that i use and recommend for the different programs:

puddletag (writing MP3 meta-tags)

  • Edit > Preferences > ID3 Options:
    • set: Create ID3v1 tag if it’s not present. Otherwise update it.
    • set: Write ID3v2.3

MP3 Diags  (fix errors, trim silence, normalize volume – Mp3splt and MP3Gain will be configured here):

  • Configuration > External tools:
    • add mp3splt command (be sure to set the input and output paths) (note that “konsole” is for KDE, other desktops may differ): konsole --hold -e /bin/sh -c "mp3splt -r -f -p th=-48 -o @f '/[source directory path]' -d '/[output directory path]'"
    • set: Confirm launch
  • Configuration > Others > Normalizer:
    • set: mp3gain -e -r -k -T -s a (note that the -T switch is optional – using it will write directly to the source file instead of creating a temporary file first)
    • set: Keep window open after completion

Convert non-MP3 to MP3 bash script – if necessary, create a bash script to convert your audio to MP3’s using FFmpeg. The following script will convert FLAC to MP3, encoding them at 320 BPS (Bits Per Second) CBR (Constant Bit Rate) and, if FFmpeg is successful, it will delete each FLAC file after it is converted. If you don’t want to encode your MP3’s at 320 BPS CBR, see this document for alternatives to -b:a 320k.

#!/bin/bash

echo "FFmpeg convert .flac to .mp3"
echo "============================"

for a in *.flac ; do
  fmpeg -i "$a" -b:a 320k "${a[@]/%flac/mp3}"
  if [$? -eq 0]; then
    rm "${a}"
  fi
done

echo "========"
echo "Finished!"

Save the script as -flac2mp3.sh in your Convert directory and set the permissions so that it is executable. The dash in front of the file name will keep it on top of your other audio files so it’s easy to find.

Audio Processing

These steps should be followed in order as outlined above in the Work Flow section.

STEP 1: Backup your collection before processing.

STEP 2: Using your bash script, convert any FLAC audio files to MP3:

  1. Place all your FLAC files in the Convert directory
  2. Run the bash script flac2mp3.sh
  3. Delete the original FLAC files if desired and move the converted files to the Tagging directory

STEP 3: Rewrite all the MP3 meta-tags using puddletag:

Personally i prefer to remove all of the tags and rewrite them without any other data than the artist name and track name. You may want to do something different than what is outlined here, such as keep the existing tag data or download new data.

  1. Rename the files as necessary, removing any unwanted characters, etc.. It may be helpful to copy the tag names to the file names, but be careful when doing this.
  2. Select all of the tracks and delete all of the tags
  3. Select all of the tracks and copy the file names to the tag names
  4. Move the files to the Repair directory

STEP 4: Repair errors with MP3 Diags:

You should refer to the MP3 Diags manual to learn how to repair your MP3 files.

STEP 5: Trim silence from beginning and end of MP3 files using MP3 Diags:

  1. Right click any track and click the Mp3splt menu item to process all the tracks
  2. Delete the original files if desired and move the output files up one level back to the Repair directory

STEP 6: Normalize volume of MP3 files using MP3 Diags:

  1. Click the Normalize icon to process all the tracks
  2. Move the files to the Listen Test directory

STEP 7: Listen test:

  1. Listen to all of the tracks to be sure they sound good
  2. Move the files to the Organize directory

STEP 8: Organize your music:

  1. Organize the tracks into folders and/or play lists. You can use puddletag for this, your music player, etc., or you can simply use a text editor (an m3u file is nothing more than a text file with a list of file paths, though you should give it an m3u8 extension if the file is Unicode).
  2. Move the files to the Copy to Devices directory

STEP 9: Copy the files to your devices and test to make sure they play.

Leave a Reply

Your email address will not be published. Required fields are marked *