Configuration files for converting audio files

Simple Conversion

© Lead Image © sxwx, 123RF.com

© Lead Image © sxwx, 123RF.com

Article from Issue 194/2017
Author(s):

Learn how to convert your music files to Ogg Vorbis for casual use or to Flac for more refined playback.

MP3 is the most common audio format in computing. However, free software boasts two superior audio formats: Ogg Vorbis [1], a lossy format like MP3 but with better compression and sound quality, and Flac [2], a lossless high-quality format, whose files are usually several times larger that MP3 or Ogg Vorbis. Casual listeners might want to convert music files to Ogg Vorbis, while audiophiles might prefer Flac. Neither conversion is difficult, but both require some organization.

In both cases, the first difficulty of conversion is that it requires several dependencies. The overall process is run by abcde [3], a CD reader like cdparanoia [4] for ripping CDs, the oggenc codex [5] for Ogg Vorbis conversion, and the Flac codex for Flac conversion. Depending on your distribution, some of these dependencies may be installed by default, but you should check before attempting any conversion. You may also require an Internet connection.

All conversions are made with abcde. However, the second difficulty is that you will probably require a dozen or more options to make any conversion, opening countless opportunities for mistakes. Once you've done one conversion, the Bash history can speed the progress, but an even greater help is a custom /etc/abcde.conf file that contains commonly used options, allowing you to concentrate only on unusual circumstances as you structure the command.

Abcde installs with its own /etc/abcde.conf, but you should look over all its options, not just the ones for a particular conversion, and read the comments above each option. For convenience, you might even want to write custom abcde.conf files for conversions to each format, using the -c FILE option to point to the one you want to use. However, most settings are probably the same no matter what the conversion, so you can usually manage with a single file, with separate entries – one per line – for each conversion you do regularly. Some fields in configuration files you may choose to ignore as unimportant.

To avoid confusion, remember that manually entered options override all configuration files, custom configuration files override one in your home directory, and one in your home directory overrides the default one in /etc. By editing the abcde configuration files carefully, you can greatly reduce the length of the command you need to enter, perhaps to something as basic as:

abcde -c /etc/abcde-ogg.conf DISK/FILEPATH

However, the options used in a conversion can be far more numerous. What follows are the configuration settings most likely to be useful. The purpose of the settings not mentioned here can usually be understood from the comments.

Important CDDB Options

An abcde configuration file falls into several categories (Figure 1). These are not named, but, if you choose, you might add a comment to identify them. Most of the fields in each category are commented out, so you will have to remove the hash sign at the start of a line if you want a field to activate.

Figure 1: An abcde configuration file begins with options for how the command interacts with the CDDB database of published CDs.

At the top of the file is CDDB Options. The Compact Disc Database (CDDB) [6] is a database of published musical disks. The two most commonly used copies of the CDDB are CDDB or Musicbrainz, with CDDB set as the default in the CDDBMETHOD field. Alternatively, by setting the CDDBUSELOCAL field to y, you can use the database shipped with the CD instead. A third option is to set NOCDDBQUERY to y, which will open a blank CDDB file for you to edit instead.

Should the CD's list of tracks differ from the one in CDDB, or if no entry for the CD exists, you have the option of specifying whether to send updates in CDDBSUBMIT or of refusing to send updates by setting the NOSUBMIT= field to n.

The CDDB section of the configuration file also sets the tags or metadata for each track, setting whether they include title, artist, composer, album artist, album, genre, year, and comments. These tags are used on some music players as different ways to list tracks, but if, for example, you never choose music by genre or year, you can omit these tags from the converted files by entering a comma-separated list of tags you do want in SHOWCDDBFIELDS.

Codecs and Other Resources

The next section of an abcde configuration file defines the tools used for the conversion (Figure 2). The important of the fields in this section define the encoder to user. The field for Ogg Vorbis is OGGENCODERSYNTAX=, and the one for Flac is FLACENCODERSYNTAX. In most distributions, both can be set to default, which means that oggenc and Flac are used. However, you can also enter the path to any other application that will convert the file. Other formats have similar fields, such as MP3ENCODERSYNTAX= for MP3 conversions. Give the location of the ripping program and pass any extra options.

Figure 2: The second section of an abcde configuration file contains settings for working with different audio formats.

Directly below this section, you can set the options for each encoder. This is probably the handiest part of the configuration file, because it allows you to enter the most common options once for all conversions to the format. Should you want the occasional different option, you can enter them manually when you type the command. It can be followed by OUTPUTTYPE=, which takes any legitimate extension for an audio file, including .ogg and .flac.

For Ogg Vorbis conversions, you will need to add -q NUMBER, with 1 being the lowest quality and 10 the highest. Another useful option is --resample NUMBER, which sets the sampling rate. A sample rate of 44,100 is equivalent to a low-quality MP3, while 96,000 is equivalent to a high-quality MP3, although in both cases the Ogg Vorbis file should have high-quality sound. A sample rate of 192,000 is the highest sample rate that makes a difference in quality on most music players. You can add other options as seems appropriate.

For Flac, useful options include -0 to -8 to set the level of compression, with -8 being the highest, and -V, which verifies all conversions. You can also use --picture=FILE SPECIFICATION if you want to include album covers with a file. Flac does not have a man file – presumably because it is technically a codex, not a command – so instead refer to the help on the website.

Similarly, the CD reader to use is set in CDROMREADERSYNTAX – usually to cdparanoia. Although other entries are also acceptable, some of them, like Flac, are specific to a format. If cdparanoia is chosen – and, generally, there is no reason why not – you can enter options in CDPARANOIAOPTS=.

Output Options

The final section of a configuration file sets details about the output (Figure 3). Most likely, you will have no need to change:

ACTIONS=cddb,playlist,read,encode,tag,move,clean
Figure 3: Part of the abcde configuration file showing options for output.

However, you might want to use OUTPUTDIR to specify the destination for converted files, instead of saving them to the current directory.

Another useful set of options sets how single and various single and multiple tracks are named with fields. Track names are built of building blocks, and you can choose which ones to include:

OUTPUTFORMAT='${OUTPUT}/${ARTISTFILE}-${ALBUMFILE}/${TRACKNUM}.${TRACKFILE}'VAOUTPUTFORMAT='${OUTPUT}/Various-${ALBUMFILE}/${TRACKNUM}.${ARTISTFILE}-${TRACKFILE}'

Because these are the names that will appear on music player lists, I recommend making them as short as possible so you do not have to endure endless horizontal scrolling and truncated listings. For consistency's sake, I also suggest using the same pattern for albums by both single and various artists. You can use the same naming conventions to create external playlists with .m3u extensions.

At the very bottom of the installed configuration file is a script that removes illegal characters from names, including spaces. Other fields set niceness, or the relative share of system resources parts of the conversion process use, and the paths to scripts and applications, although neither should be necessary on modern systems.

It is followed by a collection of random options, such as PADTRACKS=y, which tags track numbers using two digits instead of 1, and EJECTCD=y, which completes conversions by ejecting CDs.

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy Linux Magazine

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

  • FLAC: The premier digital audio codec

    With a little effort, you can create digital audio files with CD quality sound.

  • Sound Conversion

    Transfer the contents of audio CDs to your PC and convert the contents of music folders with soundKonverter and fre:ac.

  • Audex CD Ripper

    With the Audex CD ripper, you can start digitizing your personal music collection immediately.

  • Supporting Role

    With the addition of its supporting utilities, Ogg Vorbis competes with other free audio formats.

  • Command Line

    The command line swings. In this

    issue of “Command Line”we investigate

    how you can grab tracks from

    audio CDs and convert sound files to

    other formats. No matter whether

    you choose wav,MP3 or Ogg Vorbis,

    you can rely on the shell to convert

    your files.

comments powered by Disqus
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters

Support Our Work

Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.

Learn More

News