Emil Miler

Transcoding your music library with acxi

Managing a music library is easy with tools such as Picard from MusicBrainz, but here is how I transcode and sync my FLAC library by using acxi, a powerful audio processing tool.

It works similarly to Rsync by cloning data from one place to another, but acxi can also transcode files to other formats in the process. This is great for, say, converting a FLAC library to Opus, because storing FLAC files in a phone is just insane. Having most of my music in FLAC is perfect because of no loss in quality from transcoding to lossy formats. Audiophiles begone!

Installation

Acxi is written in Perl, so a working Perl runtime is needed. Installation can be done either from a repository, if your distribution provides a package, or downloading the script from GitHub directly.

wget -O /usr/local/bin/acxi https://github.com/smxi/acxi/raw/stable/acxi
wget -O /usr/local/share/man/man1/acxi.1 https://github.com/smxi/acxi/raw/stable/acxi.1
chmod +x /usr/local/bin/acxi

The output paths are important, if you later want to use the -U option for self-update, for which you also need curl.

Acxi can also do transcoding in parallel based on the number of threads you have. This functionality needs perl-parallel-forkmanager. If we want to do transcoding from FLAC to Opus, we need opus-tools as well.

Pacman PKGBUILD

I have written a simple PKGBUILD for Pacman. There are some problems with publishing it on AUR. Also bear in mind, the following was written at the time of publishing this article and is now out-of-date.

pkgname=acxi
pkgver=3.5.05
pkgrel=1
pkgdesc='Audio conversion tool that helps sync lossless to lossy formats'
arch=('any')
url='https://github.com/smxi/acxi'
license=('GPL3')
depends=('perl')
optdepends=('perl-parallel-forkmanager: Parallel processing (FORK)'
            'ffmpeg: FLAC resampling'
            'lame: MP3 encoding'
            'flac: MP3 encoding'
            'vorbis-tools: Ogg encoding'
            'opus-tools: Opus encoding'
            'shorten: SHN to FLAC conversion'
            'ffmpeg: SHN to FLAC conversion')
options=('zipman')
source=("https://github.com/smxi/acxi/archive/refs/tags/${pkgver}.tar.gz")
sha256sums=('146ff26e2f7fc4671d83acb0d68f3066777ec65cbd7b8bf812960fe5cba7ec37')

package() {
	cd "$srcdir/acxi-$pkgver"
	install -D -m755 "acxi" "${pkgdir}/usr/bin/acxi"
	install -D -m644 "acxi.1" "${pkgdir}/usr/share/man/man1/acxi.1"
}

Configuration

Acxi reads a config file during every execution in this order:

$XDG_CONFIG_HOME/acxi.conf > $HOME/.conf/acxi.conf > $HOME/.acxi.conf

We can create a file ~/.config/acxi.conf and set some basic configuration options.

SOURCE_DIRECTORY=/home/em/nfs/share/music
DESTINATION_DIRECTORY=/home/em/music
INPUT_TYPE=flac
OUTPUT_TYPE=opus
COPY_TYPES=mp3
FORK=12

This tells acxi to convert FLAC to Opus and directly copy all MP3 files. Some obscure albums were never released in FLAC. In my case, the source directory is a NFS mount point from my file-server and transcoded files are stored locally on my laptop. The FORK=12 option creates 12 parallel processes for transcoding, which should ideally match your thread count.

Executing acxi would then transcode and copy all files not present in the destination directory.

Issues with opus-tools

There are some FLAC files which cause problems during transcoding. If that happens to you, try building opus-tools from source. See more at https://github.com/xiph/opus-tools/issues/66

References

2022-09-27, Emil Miler
Page updates:
  • 2022-12-03 — Updated Pacman PKGBUILD to version 3.5.05