1
0
em.0x45.cz/content/posts/transcoding-your-music-library-with-acxi/index.md.bak

95 lines
3.8 KiB
Markdown
Raw Normal View History

2024-05-06 12:30:55 +02:00
+++
title = "Transcoding your music library with acxi"
date = 2022-09-27
[taxonomies]
categories = ["Linux"]
[extra]
author = "Emil Miler"
+++
Managing a music library is easy with tools such as [Picard](https://picard.musicbrainz.org/) from MusicBrainz, but here is how I transcode and sync my FLAC library by using [acxi](https://github.com/smxi/acxi), a powerful audio processing tool.
<!-- more -->
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 for now. You might be able to find my package there in the future, in which case this post will be updated.
```
pkgname=acxi
pkgver=3.5.02
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=('19553ee95420b54ec0fc455daab59fe1b342b7b048877044f777dcfeb96ff4ea')
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](https://morcatanauteku.cz/) 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 stranscoding, which should ideally match your thread count.
Executing `acxi` would then transcode 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
- [smxi.org](https://smxi.org/)
- [github.com/smxi/acxi](https://github.com/smxi/acxi)