|
|
|
@ -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();
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Probes the specified item for metadata.
|
|
|
|
|
/// </summary>
|
|
|
|
@ -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);
|
|
|
|
|