I am looking for a solution that will add ReplayGain to all my FLAC music files.
I uses Samba (Samba Server - 96):
\\192.168.xxx.yy\dietpi\Music
Thanks for any help
Torben
I am looking for a solution that will add ReplayGain to all my FLAC music files.
I uses Samba (Samba Server - 96):
\\192.168.xxx.yy\dietpi\Music
Thanks for any help
Torben
On windows I use foobar2000. It has a built-in ReplayGain scanner, which can handle FLAC files.
For CLI on your SBC you could use metaflac, it comes with the flac package.
apt install flac
Or if you want more control:
https://github.com/Moonbase59/loudgain
Thanks @Jappe
If I want to add ReplayGain to the “Music” dir what would be the right command. This:
#!/bin/bash
MUSIC=/dietpi/Music
mnt/dietpi_userdata/Music
find $MUSIC -type f -name "*.flac" -exec metaflac --add-replay-gain {} \;
or
#!/bin/bash
MUSIC=/mnt/dietpi_userdata/Music
find $MUSIC -type f -name "*.flac" -exec metaflac --add-replay-gain {} \;
And if I want to remove ReplayGain again what would be the right command?
Thanks - Have a great WE
Torben
For removal of the ReplayGain tags you can use --remove-replay-gain
The second one, because in the first you have a newline in your file path and also the path differs.
Also /dietpi/Music is not a default path.
We can optimize this further, to get also filenames with special characters and whitespaces in their name, to skip files which already have a ReplayGain-tag and also run it in parallel, to utilize more then one core:
#!/bin/bash
MUSIC="/mnt/dietpi_userdata/Music"
find "$MUSIC" -type f -iname "*.flac" -print0 | \
xargs -0 -n1 -P$(nproc) bash -c '
for file; do
if ! metaflac --list "$file" | grep -q "REPLAYGAIN_TRACK_GAIN"; then
echo "Adding ReplayGain: $file"
metaflac --add-replay-gain "$file"
else
echo "Skipping: $file"
fi
done
' _
-P$(nproc) will utilize every core. If you do not want this, you can reduce it like -P$(( $(nproc) - 1 )) to “spare” one core. ($(nproc) returns the number of your cores)
Or if you want to say “just use 2” you could also specify -P2
@Jappe - Thanks
Another suggestion:
#!/bin/bash
MUSIC=/path/to/media/files
shopt -s globstar
for filepath in $MUSIC/**/*.flac; do metaflac --add-replay-gain "$filepath"; done
Information as it loops through files and folders:
folder="${filepath%/*.flac}"
# and so on
There seems to be different ways to do this.
Torben
Yes, there are different ways. But with your last suggestion it can run into problems for filenames which include special characters or whitespaces. You also get no feedback about progression and possible occuring errors.
My suggestion take of that and also skip files which already have the RepalyGain tag.
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.