Page 1 of 1
Script to bulk-lower volume of flac files using ffmpeg doesn't work (Solved)
Posted: Fri May 21, 2021 2:23 am
by gychang
Several of my flac album folders are too loud. I like to lower the volume but maintain the same file name and extension. FFmeg command that lowers the volume is "ffmpeg -i input.flac -filter:a "volume=0.5" output.flac". I am thinking the find command may work with -exec option. Within a folder following gives an error.
find . -type f -iname "*.flac" -exec ffmpeg -i -filter:a "volume=0.5" {} \;
gives an error " -filter-a: protocol not found..."
can someone suggest a solution?, the above ffmpeg command works fine in a single .flac file.
Re: bulk flac files to lower volume using ffmpeg
Posted: Fri May 21, 2021 6:13 am
by fredx181
Hi gychang, this should do it:
Code: Select all
find . -type f -iname "*.flac" -exec ffmpeg -i "{}" -filter:a "volume=0.5" -sample_fmt s16 -f flac "{}".tmp \; -exec mv -f "{}".tmp "{}" \;
(ffmpeg cannot edit files in place, so convert first to .tmp, then use mv -f to rename to original name)
I added "-sample_fmt s16" to make it bit depth 16, without it, it will become 24 bits (so leave it out if you prefer that).
Fred
Re: bulk flac files to lower volume using ffmpeg
Posted: Fri May 21, 2021 1:03 pm
by gychang
fredx181 wrote: Fri May 21, 2021 6:13 am
Hi gychang, this should do it:
Code: Select all
find . -type f -iname "*.flac" -exec ffmpeg -i "{}" -filter:a "volume=0.5" -sample_fmt s16 -f flac "{}".tmp \; -exec mv -f "{}".tmp "{}" \;
(ffmpeg cannot edit files in place, so convert first to .tmp, then use mv -f to rename to original name)
I added "-sample_fmt s16" to make it bit depth 16, without it, it will become 24 bits (so leave it out if you prefer that).
Fred
works perfect!, thanks.
Re: Script to bulk lower flac files volume using ffmpeg doesn't work (Solved)
Posted: Fri May 21, 2021 6:43 pm
by williams2
You can use replaygain to normalize audio files, so that when played back on a replaygain capable player, the volume of each audio file is adjusted individually as they are played. The volume level for each file is stored in the meta data of each file. The audio files are not re-encoded.
For example: https://xiph.org/flac/documentation_tools_metaflac.html
--add-replay-gain Calculates the title and album gains/peaks of the given FLAC files as if all the files were part of one album, then stores them as FLAC tags. The tags are the same as those used by vorbisgain
https://xiph.org/flac/documentation_tools_metaflac.html
https://www.bobulous.org.uk/misc/Replay ... Linux.html
https://en.wikipedia.org/wiki/Replay_Gain
Another alternative to re-encoding is to use audio compression. For example, in Audacious, Effects, Dynamic Range Compressor. Audio compression could be useful in certain situations.
Re: Script to bulk lower flac files volume using ffmpeg doesn't work (Solved)
Posted: Fri May 21, 2021 7:14 pm
by gychang
williams2 wrote: Fri May 21, 2021 6:43 pm
For example: https://xiph.org/flac/documentation_tools_metaflac.html
--add-replay-gain Calculates the title and album gains/peaks of the given FLAC files as if all the files were part of one album, then stores them as FLAC tags. The tags are the same as those used by vorbisgain
I use mpv to listen to my flac files in puppy. Automatic on-the-fly normalization would be ideal for each flac file. Using the command find . -type f -iname "*.flac" -exec metaflac --add-replay-gain {} \; from the flac folder terminal seems to be the answer!