Closed Yamakaky closed 5 years ago
Hi,
The leading space should not matter:
# Scanf.sscanf "0.23 dB" " %f dB" (fun x -> Printf.printf "%f\n%!" x);;
0.230000
Are you aware of the extract-replaygain
script that is distributed with liquidsoap
: https://github.com/savonet/liquidsoap/blob/3350999c9efe447d8a226d59ffc061ce55004580/scripts/extract-replaygain ? It does exactly what you are describing, I believe.
Hi Romain,
Apologies for crashing this thread. I have been trying to get replay gain to work on my Debian setup without any luck. The last post to my ongoing thread (https://sourceforge.net/p/savonet/mailman/message/36622880/) went unanswered. I ran the test as suggested by Romain without luck but then again, I’m still learning about LS. I hope that someone can get me on the right track to get replaygain to work on my system.
Damian
On 8 Apr 2019, at 09:22, Romain Beauxis notifications@github.com wrote:
Hi,
The leading space should not matter:
Scanf.sscanf "0.23 dB" " %f dB" (fun x -> Printf.printf "%f\n%!" x);;
0.230000 Are you aware of the extract-replaygain script that is distributed with liquidsoap: https://github.com/savonet/liquidsoap/blob/3350999c9efe447d8a226d59ffc061ce55004580/scripts/extract-replaygain ? It does exactly what you are describing, I believe.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.
Savonet-users mailing list Savonet-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/savonet-users
This script only works if the corresponding binaries are installed. If instead the mp3 files use ID3v2, the values are present in the Metadata, which are easier to manipulate in liquidsoap and doesn't require any extra binary. It does however require the preprocessing to be done ahead of time. I will write a script for that.
Additional argument for adding native replay gain support is the handling of pregain, per track VS per album gain and clipping prevention according to the spec.
Is there any documentation that clearly outlines which binaries to install and from where? Obviously, the reason why it’s not working for me is because I haven’t set this up correctly.
On 8 Apr 2019, at 5:52 pm, Yamakaky notifications@github.com wrote:
This script works if the corresponding binaries are installed. If instead the mp3 files use ID3v2, the values are present in the Metadata, which are easier to manipulate in liquidsoap and doesn't require any extra binary. It does however require the preprocessing to be done ahead of time.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/savonet/liquidsoap/issues/749#issuecomment-480723866, or mute the thread https://github.com/notifications/unsubscribe-auth/Am23y-tvijiunK4KKfavlTT1MWpImc9aks5vevU7gaJpZM4cgQ_c.
Savonet-users mailing list Savonet-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/savonet-users
I'm writing a script for that, please wait a few more hours ;)
Spoiler : ffmpeg
Here it is: https://gist.github.com/Yamakaky/0f0546ea0aeb4ed220caa82d814b7d68. This will create the REPLAYGAIN_TRACK_PEAK and GAIN (-a is not implemented). It should support any codec supported by ffmpeg, no additional binary needed. It must be run one time ahead of time.
In liquidsoap, a basic support is to use amplify(1.0, override = "REPLAYGAIN_TRACK_GAIN", source)
. It however doesn't support pre-amp or clipping.
BTW, do you know why https://wiki.hydrogenaud.io/index.php?title=ReplayGain_specification#Reduced_gain uses a factor of 20? I thought 3dB = x2 amp, but with this formula it's more around 7dB.
In fact, I was thinking of the power level ration of the signal with the amplitude ratio, which is used here. https://en.wikipedia.org/wiki/Decibel
Hum, but then there is a risk of mistake when using lin_of_dB with amplify. From what I understand, the first outs a power ratio while the second wants an amplitude ratio, correct?
@toots how would you implement the amp factor calculation? I was thinking about using on_metadata + a global ref per source, but that's not very clean and we may use an incorrect amp factor for a few frames at the beginning of the file. We also have to deal with overlapping sources, which may break this setup.
I was thinking of a modified amplify operator, something like apply_replaygain(preamp: () -> float, limit_peak: bool = false, use_album_values: bool = false)
. I can do the implementation if needed. Would that play nice with sources transitions?
Hi, can i clarify, does this script provide the necessary binaries for the extract replaygain script that comes with liquidsoap? Also, will it provide me with what I need to apply gain to mp3 files?
On 9 Apr 2019, at 04:13, Yamakaky notifications@github.com wrote:
@toots how would you implement the amp factor calculation? I was thinking about using on_metadata + a global ref per source, but that's not very clean and we may use an incorrect amp factor for a few frames at the beginning of the file. We also have to deal with overlapping sources, which may break this setup.
I was thinking of a modified amplify operator, something like apply_replaygain(preamp: () -> float, limit_peak: bool = false). Would that play nice with sources transitions?
— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.
Savonet-users mailing list Savonet-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/savonet-users
It replaces mp3gain and friends with only ffmpeg which you still need to install. Running the script will check if ffmpeg is present.
It should support any codec supported by ffmpeg, using the native filter https://ffmpeg.org/ffmpeg-filters.html#replaygain
Edit: my bad, miss read your post. My script isn't a backend for the script from liquidsoap. With it, you don't need enable_replaygain_metadata. The setup is : 1) run my script on your media directory ahead of time 2) in liquidsoap, use only the amplify operator as above. Don't use enable_replaygain_metadata or the replay gain protocol.
Why would I need ffmpeg instead of mp3gain? The extract-replaygain script seems to specifically require either mp3gain or replaygain for it to work. I can’t see any reference to ffmpeg
if (($file =~ /.mp3$/i) || (test_mime() =~ /audio\/mpeg/)) {
if (which mp3gain
) {
my $out = `mp3gain -q "$file" 2> /dev/null` ;
$out =~ /Recommended "Track" dB change: (.*)$/m || die ;
print "$1 dB\n" ;
} elsif (which replaygain
) {
use_replaygain()
} else {
print STDERR "Cannot find mp3gain nor replaygain binaries!\n";
On 9 Apr 2019, at 5:35 pm, Yamakaky notifications@github.com wrote:
It replaces mp3gain and friends with only ffmpeg which you still need to install. Running the script will check if ffmpeg is present.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/savonet/liquidsoap/issues/749#issuecomment-481137775, or mute the thread https://github.com/notifications/unsubscribe-auth/Am23yz_v2-L5jvhNNgHCsQqEVGmRZaTZks5vfELPgaJpZM4cgQ_c.
Savonet-users mailing list Savonet-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/savonet-users
Please reply from github, you will see my message edited ^^
This script looks great @Yamakaky. I'm gonna reuse this work to simplify replaygain. Thanks!
Thanks!
How would you implement the RG in .liq? If we do amplify(1.0, "REPLAYGAIN_TRACK_GAIN", playlist(...))
, would each track be amplified with its own factor? What it we add transitions between the tracks?
I need to think about it. There are two possibilities:
ffmpeg
workThe second solution seems more useful as you wouldn't need to even have to think of using the amplify
operator and etc. So I'll prolly go that direction.
The only problem that may occur is that we should be able to configure if we want per album or per track (can be static), how we handle amplitude limiting (idem) and pre-amp (dynamic). Not sure if we can do the pregain with a protocol?
Considering that the underlying architecture of liquidsoap is track-based, I believe that the best solution is a standard, per-track, implementation of the replay gain specifications. It should be only optionally enabled and anything beyond that would require the user to specify what they intent to do. Of course, it can and should be made as easy as possible to go beyond the simple standard.
Some bugs I discovered with my scripts :
Seems like vorbisgain is the only one who read the doc:
Additionally,
liquidsoap
seem to require a leading space in the metadata value, in contradiction with the doc.The only way I see out of this madness, outside from fixing these tools/finding spec-compliant ones, would be to make the
dB
prefix optional and the metadata name case insensitive. Since this is specific toreplaygain
, a newreplaygain
operator could be created as aamplify
wrapper.Bonus point if this operator supports preamp and clipping prevention as required by the spec. It could also be added as a note to use
amplify
in the doc.What do you think?