| 1 |
ReplayGain Plugin |
| 2 |
================= |
| 3 |
|
| 4 |
This plugin adds support for ReplayGain_, a technique for normalizing audio |
| 5 |
playback levels. |
| 6 |
|
| 7 |
.. _replaygain: https://wiki.hydrogenaudio.org/index.php?title=ReplayGain |
| 8 |
|
| 9 |
Installation |
| 10 |
------------ |
| 11 |
|
| 12 |
This plugin can use one of many backends to compute the ReplayGain values: |
| 13 |
GStreamer, mp3gain (and its cousins, aacgain and mp3rgain), Python Audio Tools, |
| 14 |
ffmpeg or metaflac. ffmpeg and mp3gain can be easier to install. mp3gain |
| 15 |
supports fewer audio formats than the other backends, and metaflac only supports |
| 16 |
FLAC. |
| 17 |
|
| 18 |
Once installed, this plugin analyzes all files during the import process. This |
| 19 |
can be a slow process; to instead analyze after the fact, disable automatic |
| 20 |
analysis and use the ``beet replaygain`` command (see below). |
| 21 |
|
| 22 |
To speed up analysis with some of the available backends, this plugin processes |
| 23 |
tracks or albums (when using the ``-a`` option) in parallel. By default, a |
| 24 |
single thread is used per logical core of your CPU. |
| 25 |
|
| 26 |
GStreamer |
| 27 |
~~~~~~~~~ |
| 28 |
|
| 29 |
To use GStreamer_ for ReplayGain analysis, you will of course need to install |
| 30 |
GStreamer and plugins for compatibility with your audio files. You will need at |
| 31 |
least GStreamer 1.0 and `PyGObject 3.x`_ (a.k.a. ``python-gi``). |
| 32 |
|
| 33 |
.. _gstreamer: https://gstreamer.freedesktop.org/ |
| 34 |
|
| 35 |
.. _pygobject 3.x: https://pygobject.gnome.org/ |
| 36 |
|
| 37 |
Then, install ``beets`` with ``replaygain`` extra which installs ``GStreamer`` |
| 38 |
bindings for Python |
| 39 |
|
| 40 |
.. code-block:: bash |
| 41 |
|
| 42 |
pip install "beets[replaygain]" |
| 43 |
|
| 44 |
Lastly, enable the ``replaygain`` plugin in your configuration (see |
| 45 |
:ref:`using-plugins`) and specify the GStreamer backend by adding this to your |
| 46 |
configuration file: |
| 47 |
|
| 48 |
:: |
| 49 |
|
| 50 |
replaygain: |
| 51 |
backend: gstreamer |
| 52 |
|
| 53 |
The GStreamer backend does not support parallel analysis. |
| 54 |
|
| 55 |
Supported ``command`` backends |
| 56 |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 57 |
|
| 58 |
In order to use this backend, you will need to install a supported command-line |
| 59 |
tool: |
| 60 |
|
| 61 |
- mp3gain_ (MP3 only) |
| 62 |
- aacgain_ (MP3, AAC/M4A) |
| 63 |
- mp3rgain_ (MP3, AAC/M4A) |
| 64 |
|
| 65 |
mp3gain |
| 66 |
+++++++ |
| 67 |
|
| 68 |
- On Linux, mp3gain_ is probably in your repositories. On Debian or Ubuntu, for |
| 69 |
example, you can run ``apt-get install mp3gain``. |
| 70 |
- On Windows, download and install mp3gain_. |
| 71 |
|
| 72 |
aacgain |
| 73 |
+++++++ |
| 74 |
|
| 75 |
- On macOS, install via Homebrew_: ``brew install aacgain``. |
| 76 |
- For other platforms, download from aacgain_ or use a compatible fork if |
| 77 |
available for your system. |
| 78 |
|
| 79 |
mp3rgain |
| 80 |
++++++++ |
| 81 |
|
| 82 |
mp3rgain_ is a modern Rust rewrite of ``mp3gain`` that also supports AAC/M4A |
| 83 |
files. It addresses security vulnerability CVE-2019-18359 present in the |
| 84 |
original mp3gain and works on modern systems including Windows 11 and macOS with |
| 85 |
Apple Silicon. |
| 86 |
|
| 87 |
- On macOS, install via Homebrew_: ``brew install mp3rgain``. |
| 88 |
- On Linux, install via Nix: ``nix-env -iA nixpkgs.mp3rgain`` or from your |
| 89 |
distribution packaging (for example, AUR on Arch Linux). |
| 90 |
- On Windows, download and install mp3rgain_. |
| 91 |
|
| 92 |
Configuration |
| 93 |
+++++++++++++ |
| 94 |
|
| 95 |
.. code-block:: yaml |
| 96 |
|
| 97 |
replaygain: |
| 98 |
backend: command |
| 99 |
command: # mp3rgain, mp3gain, or aacgain |
| 100 |
|
| 101 |
If beets doesn't automatically find the command executable, you can configure |
| 102 |
the path explicitly like so: |
| 103 |
|
| 104 |
.. code-block:: yaml |
| 105 |
|
| 106 |
replaygain: |
| 107 |
command: /Applications/MacMP3Gain.app/Contents/Resources/aacgain |
| 108 |
|
| 109 |
.. _aacgain: https://github.com/dgilman/aacgain |
| 110 |
|
| 111 |
.. _homebrew: https://brew.sh |
| 112 |
|
| 113 |
.. _mp3gain: https://sourceforge.net/projects/mp3gain/download.php |
| 114 |
|
| 115 |
.. _mp3rgain: https://github.com/M-Igashi/mp3rgain |
| 116 |
|
| 117 |
Python Audio Tools |
| 118 |
~~~~~~~~~~~~~~~~~~ |
| 119 |
|
| 120 |
This backend uses the `Python Audio Tools`_ package to compute ReplayGain for a |
| 121 |
range of different file formats. The package is not available via PyPI; it must |
| 122 |
be installed manually (only versions preceding 3.x are compatible). |
| 123 |
|
| 124 |
On OS X, most of the dependencies can be installed with Homebrew_: |
| 125 |
|
| 126 |
:: |
| 127 |
|
| 128 |
brew install mpg123 mp3gain vorbisgain faad2 libvorbis |
| 129 |
|
| 130 |
The Python Audio Tools backend does not support parallel analysis. |
| 131 |
|
| 132 |
.. _python audio tools: https://sourceforge.net/projects/audiotools/ |
| 133 |
|
| 134 |
ffmpeg |
| 135 |
~~~~~~ |
| 136 |
|
| 137 |
This backend uses ffmpeg to calculate EBU R128 gain values. To use it, install |
| 138 |
the ffmpeg_ command-line tool and select the ``ffmpeg`` backend in your config |
| 139 |
file. |
| 140 |
|
| 141 |
.. _ffmpeg: https://ffmpeg.org |
| 142 |
|
| 143 |
metaflac |
| 144 |
~~~~~~~~ |
| 145 |
|
| 146 |
This backend uses the metaflac_ command-line tool (part of the FLAC tools) to |
| 147 |
compute ReplayGain values for FLAC files. It only supports FLAC; files in other |
| 148 |
formats are skipped. To use it, install the ``flac`` package, which provides |
| 149 |
``metaflac``, and select the ``metaflac`` backend in your configuration file: |
| 150 |
|
| 151 |
.. code-block:: yaml |
| 152 |
|
| 153 |
replaygain: |
| 154 |
backend: metaflac |
| 155 |
|
| 156 |
metaflac scans every file of an album in a single pass, so the files of an album |
| 157 |
need to share the same sample rate and channel layout. |
| 158 |
|
| 159 |
.. _metaflac: https://xiph.org/flac/documentation_tools_metaflac.html |
| 160 |
|
| 161 |
Configuration |
| 162 |
------------- |
| 163 |
|
| 164 |
To configure the plugin, make a ``replaygain:`` section in your configuration |
| 165 |
file. The available options are: |
| 166 |
|
| 167 |
- **auto**: Enable ReplayGain analysis during import. Default: ``yes``. |
| 168 |
- **threads**: The number of parallel threads to run the analysis in. Overridden |
| 169 |
by ``--threads`` at the command line. Default: # of logical CPU cores |
| 170 |
- **parallel_on_import**: Whether to enable parallel analysis during import. As |
| 171 |
of now this ReplayGain data is not written to files properly, so this option |
| 172 |
is disabled by default. If you wish to enable it, remember to run ``beet |
| 173 |
write`` after importing to actually write to the imported files. Default: |
| 174 |
``no`` |
| 175 |
- **backend**: The analysis backend; either ``gstreamer``, ``command``, |
| 176 |
``audiotools``, ``ffmpeg`` or ``metaflac``. Default: ``command``. |
| 177 |
- **overwrite**: On import, re-analyze files that already have ReplayGain tags. |
| 178 |
Note that, for historical reasons, the name of this option is somewhat |
| 179 |
unfortunate: It does not decide whether tags are written to the files (which |
| 180 |
is controlled by the :ref:`import.write <config-import-write>` option). |
| 181 |
Default: ``no``. |
| 182 |
- **targetlevel**: A number of decibels for the target loudness level for files |
| 183 |
using ``REPLAYGAIN_`` tags. Default: ``89``. |
| 184 |
- **r128_targetlevel**: The target loudness level in decibels (i.e. ``<loudness |
| 185 |
in LUFS> + 107``) for files using ``R128_`` tags. Default: 84 (Use ``83`` for |
| 186 |
ATSC A/85, ``84`` for EBU R128 or ``89`` for ReplayGain 2.0.) |
| 187 |
- **r128**: A space separated list of formats that will use ``R128_`` tags with |
| 188 |
integer values instead of the common ``REPLAYGAIN_`` tags with floating point |
| 189 |
values. Requires the "ffmpeg" backend. Default: ``Opus``. |
| 190 |
- **per_disc**: Calculate album ReplayGain on disc level instead of album level. |
| 191 |
Default: ``no`` |
| 192 |
|
| 193 |
These options only work with the "command" backend: |
| 194 |
|
| 195 |
- **command**: Name or path to your command backend of choice: either of |
| 196 |
``mp3gain``, ``aacgain`` or ``mp3rgain``. |
| 197 |
- **noclip**: Reduce the amount of ReplayGain adjustment to whatever amount |
| 198 |
would keep clipping from occurring. Default: ``yes``. |
| 199 |
|
| 200 |
This option only works with the "ffmpeg" backend: |
| 201 |
|
| 202 |
- **peak**: Either ``true`` (the default) or ``sample``. ``true`` is more |
| 203 |
accurate but slower. |
| 204 |
|
| 205 |
This option only works with the "metaflac" backend: |
| 206 |
|
| 207 |
- **metaflac**: Name or path to the ``metaflac`` executable. Default: |
| 208 |
``metaflac``. |
| 209 |
|
| 210 |
Manual Analysis |
| 211 |
--------------- |
| 212 |
|
| 213 |
By default, the plugin will analyze all items an albums as they are implemented. |
| 214 |
However, you can also manually analyze files that are already in your library. |
| 215 |
Use the ``beet replaygain`` command: |
| 216 |
|
| 217 |
:: |
| 218 |
|
| 219 |
$ beet replaygain [-Waf] [QUERY] |
| 220 |
|
| 221 |
The ``-a`` flag analyzes whole albums instead of individual tracks. Provide a |
| 222 |
query (see :doc:`/reference/query`) to indicate which items or albums to |
| 223 |
analyze. Files that already have ReplayGain values are skipped unless ``-f`` is |
| 224 |
supplied. Use ``-w`` (write tags) or ``-W`` (don't write tags) to control |
| 225 |
whether ReplayGain tags are written into the music files, or stored in the beets |
| 226 |
database only (the default is to use :ref:`the importer's configuration |
| 227 |
<config-import-write>`). |
| 228 |
|
| 229 |
To execute with a different number of threads, call ``beet replaygain --threads |
| 230 |
N``: |
| 231 |
|
| 232 |
:: |
| 233 |
|
| 234 |
$ beet replaygain --threads N [-Waf] [QUERY] |
| 235 |
|
| 236 |
with N any integer. To disable parallelism, use ``--threads 0``. |
| 237 |
|
| 238 |
ReplayGain analysis is not fast, so you may want to disable it during import. |
| 239 |
Use the ``auto`` config option to control this: |
| 240 |
|
| 241 |
:: |
| 242 |
|
| 243 |
replaygain: |
| 244 |
auto: no |