flac2all is a simple utility that allows you to convert high-quality FLAC files to almost any modern audio format. Unlike ffmpeg, this utility automates the process of sorting, tagging and encoding your FLAC audio. flac2all is easy to install and use. Learn how to use this highly versatile program that can act as a front end for all your audio transcoding needs.
Also read: 4 Ways to Increase the Battery Life of Your Linux Laptop
Why Use flac2all
At its core, flac2all is both a wrapper and a scheduling program. It takes a list of FLAC files and uses various codecs to queue and manage the transcoding process.
One advantage of this approach is that flac2all does not depend on a single encoder, which means that you can easily adapt the program to any new format you might want to use. For example, you can install the custom Fraunhofer FDK AAC encoder alongside regular AAC.
Lastly, flac2all also preserves the folder structure of your FLAC collection, so you do not need to redo the directory of your archive while using this program. These features make flac2all a handy utility if you are looking for a quick and easy way to recreate your FLAC collection in a different format.
Also read: The Differences between Su, Sudo Su, Sudo -s and Sudo -i
Installing flac2all
Before you install flac2all, it’s important to obtain all of its dependencies to ensure that there will be no conflicts after installation:
sudo apt install python3 flac python3-pip python3-zmq python3-notcurses lame opus-tools
The next thing to do is to download flac2all through pip, a Python-specific package manager that you can use to install additional software. Run the following command to use pip:
pip3 install --user flac2all
This will install flac2all to the current user’s “.local” directory. So if you are on a multi-user system, other users will not be able to run the program.
In order to run flac2all, include your “.local” directory to your machine’s PATH variable by adding the following line of code to your “.bash_profile” file:
PATH=$PATH:/home/$USER/.local/bin/ export PATH
Lastly, either restart or log out of your current session to apply the new settings, after which you can run flac2all -h
to confirm that you have properly installed the program.
Using flac2all to Transcode Audio
The developer of flac2all designed the program to be as simple as possible. For example, the syntax for transcoding a FLAC directory to a single format looks like this:
flac2all mp3 -o ./output ./royalty-free
- The first element after “flac2all” highlights the format that you want to transcode to. I am converting my FLAC folder to MP3 in this example.
- The second element contains options for the current transcode job. Here, the
-o
option tells flac2all to send any MP3 files to the “output” folder. - Lastly, the third element indicates the source folder for your FLAC files. In my case, it is my “royalty-free” folder.
Also read: How to Resize and Optimize Images From the Linux Terminal
Transcoding to Multiple Formats
You can also use flac2all to transcode files to multiple formats in parallel, which can be useful if you want to transfer your archive to players with different format requirements.
For example, I can run the following command to transcode my “royalty-free” folder to both MP3 and Opus:
flac2all mp3,opus -o ./output ./royalty-free
Note that a multiple-format transcode will take longer than a single-format transcode because flac2all will encode each file in your directory for every format that you specify. In my case, transcoding MP3 and AAC will take twice as long as only transcoding MP3.
Creating Custom Transcode Jobs
Aside from creating simple transcodes, it is possible to tweak how the encoders behave with flac2all, which is especially helpful if you want the copy of your archive to be of a certain audio quality. Look at the following command, for example.
flac2all mp3 --lame-options='b 320' -o ./output ./royalty-free
This command tells the program to use the LAME MP3 encoder to transcode my “royalty-free” folder at a constant bitrate of 320k.
You can also create custom jobs for multi-format transcodes. For example, the following command tells flac2all to create a custom transcode with MP3 and Opus:
flac2all mp3,opus --opus-options='downmix-mono' --lame-options='b 320' -o ./output ./royalty-free
Creating a flac2all Transcode Cluster
While you can use flac2all on a single computer, it is also possible to spread the program across multiple systems – a practical solution to speed up the transcoding process. Ensure that you have the following resources ready:
- Two or more machines that can directly connect to each other
- A NAS that you can access across all machines because the master flac2all process only instructs its worker clients to process existing data
- A reliable network connection between the master process and its worker clients
Knowing these factors, this tutorial will focus on creating a small flac2all cluster between two Ubuntu 22.04 machines.
Also read: How to Set Up and Use SSH in Linux
Setting Up a Network Mount
Create a network storage mount to begin. For this, I am going to use SSHFS since it is easy to use and available to almost all Linux distributions.
To start, install SSHFS on all of the machines that you want to use:
sudo apt install ssh sshfs
Next, create the folder to which SSHFS will mount. I will create a “royalty-free” folder in the home directory of my worker machine:
mkdir /home/$USER/royalty-free
Now mount the “royalty-free” directory to each of your worker machines with the following command:
sshfs -o allow_other,default_permissions $USER@192.168.68.10:/home/$USER/royalty-free /home/$USER/royalty-free
Starting the flac2all Cluster
You can now start the transcoding cluster by running the master process and adding both -m
and -C
flags to flac2all.
For example, run this command on your main machine to create a master process:
flac2all lame,aac -m -C --lame-options='b 320' -o /home/$USER/output /home/$USER/royalty-free
Unlike regular flac2all, creating a master process will not start the transcoding session. In order to transcode files, you also need to connect the workers to the master process by running the following command on your worker machines:
flac2all_worker 192.168.68.10
Once done, the worker client will create a headless process that connects to the master program. After that, flac2all will start immediately once it finds a handful of workers on standby.
Also read: How to Download and Configure DaVinci Resolve in Linux
Frequently Asked Questions
flac2all does not terminate after processing my audio files. How do I fix this issue?
This happens whenever there is a conflict with flac2all and its Python dependencies. Fix it by updating your installation to reflect any changes between flac2all and its dependencies. Run pip install --user --upgrade flac2all
to upgrade flac2all.
flac2all is throwing a "FileNotFound" error. Is my installation broken?
No! This problem occurs when the program fails to detect the encoder for the format to which you want to transcode.
For example, running flac2all opus […]
without the Opus encoder will result in a “FileNotFound” error. You can fix the issue by installing ffmpeg. This is a catch-all program that will also install most of the common audio encoders. Run sudo apt install ffmpeg
to add ffmpeg to your system.
The worker process failed to find any media in my SSHFS mount. Is flac2all broken?
No. This usually happens due to a directory mismatch between the master process and its workers. To ensure that the transcode cluster works, check that the file paths between each machine are the same by running pwd
on both your media folder and the root of your SSHFS mount.
Image credit: Unsplash and Wikimedia Commons All alterations and screenshots by Ramces Red
Our latest tutorials delivered straight to your inbox