Replaygain

Scripts for Madsonic
c0utta
Posts: 12
Joined: 21 Aug 2013, 04:16
Has thanked: 0
Been thanked: 10 times

Replaygain

Unread post by c0utta »

I’m running Madsonic in a minimal Debian environment and have been trying for some time to get “replaygain” working. This led me to find out some other interesting things about transcoding as I fumbled my way through.
After some searching, I found that I need to read the replay gain tag (only the track gain) from my audio files. exiftool seems to be the most reliable way to do this. I created rg.sh which does my transcoding:
  1. 1: read the ReplaygainTrackGain tag into a variable
    2: use ffmpeg to filter the volume using the variable
I had to use ffmpeg, not Audioffmpeg because it didn’t have the filter options available.
I ran with this for a while on both a PC and dSub on a BlackBerry Z30 (yes, I’m running an edge case here, but it does work) but periodically some items wouldn’t transcode.
It took me a great deal of trial and error to work out what was going on – in summary, any embedded cover art is read as a video stream by ffmpeg and when the filter is applied, ffmpeg gives an error. I was checking the logs, but I had turned off the verbosity in ffmpeg as well, so nothing really appeared in the Log.

In the end I had to use the –vn option to ignore any video streams. Audioffmpeg is purely for audio files and will only process the audio stream.

I hope this helps someone if they’re trying to do something similar.

Code: Select all

#!/usr/bin/env sh

volume=`exiftool -a -All -s "$1" | awk '/ReplaygainTrackGain/ { print $3 }'`
echo "ReplayGain Track Gain = ${volume}dB" >&2
/var/madsonic/transcode/ffmpeg -i "${1}" -ab "${2}k" -v warning -vn -f mp3 -filter "volume=${volume}dB" -
These users thanked the author c0utta for the post (total 3):
MadsonicMetzlmanepsilo
Rating: 23.08%
c0utta
Posts: 12
Joined: 21 Aug 2013, 04:16
Has thanked: 0
Been thanked: 10 times

Re: Replaygain

Unread post by c0utta »

In addition, I've started using ogg on my BlackBerry Z30 to save some space and wanted to have replaygain working. I settled on -q5 for ogg, so my code looks like:

Code: Select all

#!/usr/bin/env sh

volume=`exiftool -a -All -s "$1" | awk '/ReplaygainTrackGain/ { print $3 }'`
echo "ReplayGain Track Gain = ${volume}dB" >&2
/var/madsonic/transcode/ffmpeg -i "${1}" -f ogg -acodec libvorbis -ar 44100 -aq 5 -ac 2 -map 0:0 -filter "volume=${volume}dB" -
addseo1115
Has thanked: 0
Been thanked: 0

Re: Replaygain

Unread post by addseo1115 »

It's very very important content.
Post Reply