mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-06-29 02:13:36 +02:00
Always scan ReplayGain tag (#11418)
This commit is contained in:
parent
3c159822b5
commit
428283f787
|
@ -135,7 +135,7 @@ namespace MediaBrowser.Controller.Entities
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The LUFS Value.</value>
|
/// <value>The LUFS Value.</value>
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
public float LUFS { get; set; }
|
public float? LUFS { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the channel identifier.
|
/// Gets or sets the channel identifier.
|
||||||
|
|
|
@ -35,8 +35,6 @@ namespace MediaBrowser.Model.Configuration
|
||||||
|
|
||||||
public bool EnableLUFSScan { get; set; }
|
public bool EnableLUFSScan { get; set; }
|
||||||
|
|
||||||
public bool UseReplayGainTags { get; set; }
|
|
||||||
|
|
||||||
public bool EnableChapterImageExtraction { get; set; }
|
public bool EnableChapterImageExtraction { get; set; }
|
||||||
|
|
||||||
public bool ExtractChapterImagesDuringLibraryScan { get; set; }
|
public bool ExtractChapterImagesDuringLibraryScan { get; set; }
|
||||||
|
|
|
@ -70,9 +70,6 @@ namespace MediaBrowser.Providers.MediaInfo
|
||||||
[GeneratedRegex(@"I:\s+(.*?)\s+LUFS")]
|
[GeneratedRegex(@"I:\s+(.*?)\s+LUFS")]
|
||||||
private static partial Regex LUFSRegex();
|
private static partial Regex LUFSRegex();
|
||||||
|
|
||||||
[GeneratedRegex(@"REPLAYGAIN_TRACK_GAIN:\s+-?([0-9.]+)\s+dB")]
|
|
||||||
private static partial Regex ReplayGainTagRegex();
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Probes the specified item for metadata.
|
/// Probes the specified item for metadata.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -116,50 +113,7 @@ namespace MediaBrowser.Providers.MediaInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
var libraryOptions = _libraryManager.GetLibraryOptions(item);
|
var libraryOptions = _libraryManager.GetLibraryOptions(item);
|
||||||
bool foundLUFSValue = false;
|
if (libraryOptions.EnableLUFSScan && item.LUFS is null)
|
||||||
|
|
||||||
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)
|
|
||||||
{
|
{
|
||||||
using (var process = new Process()
|
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);
|
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);
|
_logger.LogDebug("LUFS for {ItemName} is {LUFS}.", item.Name, item.LUFS);
|
||||||
|
|
||||||
return ItemUpdateType.MetadataImport;
|
return ItemUpdateType.MetadataImport;
|
||||||
|
@ -392,6 +337,11 @@ namespace MediaBrowser.Providers.MediaInfo
|
||||||
: audio.Genres;
|
: audio.Genres;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!double.IsNaN(tags.ReplayGainTrackGain))
|
||||||
|
{
|
||||||
|
audio.LUFS = DefaultLUFSValue - (float)tags.ReplayGainTrackGain;
|
||||||
|
}
|
||||||
|
|
||||||
if (options.ReplaceAllMetadata || !audio.TryGetProviderId(MetadataProvider.MusicBrainzArtist, out _))
|
if (options.ReplaceAllMetadata || !audio.TryGetProviderId(MetadataProvider.MusicBrainzArtist, out _))
|
||||||
{
|
{
|
||||||
audio.SetProviderId(MetadataProvider.MusicBrainzArtist, tags.MusicBrainzArtistId);
|
audio.SetProviderId(MetadataProvider.MusicBrainzArtist, tags.MusicBrainzArtistId);
|
||||||
|
|
Loading…
Reference in a new issue