diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs
index c1d9ecbdfc..474b093d51 100644
--- a/MediaBrowser.Controller/Entities/BaseItem.cs
+++ b/MediaBrowser.Controller/Entities/BaseItem.cs
@@ -135,7 +135,7 @@ namespace MediaBrowser.Controller.Entities
///
/// The LUFS Value.
[JsonIgnore]
- public float LUFS { get; set; }
+ public float? LUFS { get; set; }
///
/// Gets or sets the channel identifier.
diff --git a/MediaBrowser.Model/Configuration/LibraryOptions.cs b/MediaBrowser.Model/Configuration/LibraryOptions.cs
index e777d5fd88..7ce75b2bce 100644
--- a/MediaBrowser.Model/Configuration/LibraryOptions.cs
+++ b/MediaBrowser.Model/Configuration/LibraryOptions.cs
@@ -35,8 +35,6 @@ namespace MediaBrowser.Model.Configuration
public bool EnableLUFSScan { get; set; }
- public bool UseReplayGainTags { get; set; }
-
public bool EnableChapterImageExtraction { get; set; }
public bool ExtractChapterImagesDuringLibraryScan { get; set; }
diff --git a/MediaBrowser.Providers/MediaInfo/AudioFileProber.cs b/MediaBrowser.Providers/MediaInfo/AudioFileProber.cs
index 1ca57c36e7..17d2ab71d6 100644
--- a/MediaBrowser.Providers/MediaInfo/AudioFileProber.cs
+++ b/MediaBrowser.Providers/MediaInfo/AudioFileProber.cs
@@ -70,9 +70,6 @@ namespace MediaBrowser.Providers.MediaInfo
[GeneratedRegex(@"I:\s+(.*?)\s+LUFS")]
private static partial Regex LUFSRegex();
- [GeneratedRegex(@"REPLAYGAIN_TRACK_GAIN:\s+-?([0-9.]+)\s+dB")]
- private static partial Regex ReplayGainTagRegex();
-
///
/// Probes the specified item for metadata.
///
@@ -116,50 +113,7 @@ namespace MediaBrowser.Providers.MediaInfo
}
var libraryOptions = _libraryManager.GetLibraryOptions(item);
- bool foundLUFSValue = false;
-
- if (libraryOptions.UseReplayGainTags)
- {
- using (var process = new Process()
- {
- StartInfo = new ProcessStartInfo
- {
- FileName = _mediaEncoder.ProbePath,
- Arguments = $"-hide_banner -i \"{path}\"",
- RedirectStandardOutput = false,
- RedirectStandardError = true
- },
- })
- {
- try
- {
- process.Start();
- }
- catch (Exception ex)
- {
- _logger.LogError(ex, "Error starting ffmpeg");
-
- throw;
- }
-
- using var reader = process.StandardError;
- var output = await reader.ReadToEndAsync(cancellationToken).ConfigureAwait(false);
- cancellationToken.ThrowIfCancellationRequested();
- Match split = ReplayGainTagRegex().Match(output);
-
- if (split.Success)
- {
- item.LUFS = DefaultLUFSValue - float.Parse(split.Groups[1].ValueSpan, CultureInfo.InvariantCulture.NumberFormat);
- foundLUFSValue = true;
- }
- else
- {
- item.LUFS = DefaultLUFSValue;
- }
- }
- }
-
- if (libraryOptions.EnableLUFSScan && !foundLUFSValue)
+ if (libraryOptions.EnableLUFSScan && item.LUFS is null)
{
using (var process = new Process()
{
@@ -192,18 +146,9 @@ namespace MediaBrowser.Providers.MediaInfo
{
item.LUFS = float.Parse(split[0].Groups[1].ValueSpan, CultureInfo.InvariantCulture.NumberFormat);
}
- else
- {
- item.LUFS = DefaultLUFSValue;
- }
}
}
- if (!libraryOptions.EnableLUFSScan && !libraryOptions.UseReplayGainTags)
- {
- item.LUFS = DefaultLUFSValue;
- }
-
_logger.LogDebug("LUFS for {ItemName} is {LUFS}.", item.Name, item.LUFS);
return ItemUpdateType.MetadataImport;
@@ -392,6 +337,11 @@ namespace MediaBrowser.Providers.MediaInfo
: audio.Genres;
}
+ if (!double.IsNaN(tags.ReplayGainTrackGain))
+ {
+ audio.LUFS = DefaultLUFSValue - (float)tags.ReplayGainTrackGain;
+ }
+
if (options.ReplaceAllMetadata || !audio.TryGetProviderId(MetadataProvider.MusicBrainzArtist, out _))
{
audio.SetProviderId(MetadataProvider.MusicBrainzArtist, tags.MusicBrainzArtistId);