mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-01-15 23:58:57 +00:00
Merge remote-tracking branch 'origin/master' into hwa
This commit is contained in:
@@ -45,6 +45,7 @@ namespace MediaBrowser.MediaEncoding.Probing
|
||||
{
|
||||
"AC/DC",
|
||||
"Au/Ra",
|
||||
"Bremer/McCoy",
|
||||
"이달의 소녀 1/3",
|
||||
"LOONA 1/3",
|
||||
"LOONA / yyxy",
|
||||
@@ -648,11 +649,6 @@ namespace MediaBrowser.MediaEncoding.Probing
|
||||
stream.IsAVC = false;
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(streamInfo.FieldOrder) && !string.Equals(streamInfo.FieldOrder, "progressive", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
stream.IsInterlaced = true;
|
||||
}
|
||||
|
||||
// Filter out junk
|
||||
if (!string.IsNullOrWhiteSpace(streamInfo.CodecTagString) && !streamInfo.CodecTagString.Contains("[0]", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
@@ -724,6 +720,23 @@ namespace MediaBrowser.MediaEncoding.Probing
|
||||
stream.AverageFrameRate = GetFrameRate(streamInfo.AverageFrameRate);
|
||||
stream.RealFrameRate = GetFrameRate(streamInfo.RFrameRate);
|
||||
|
||||
// Some interlaced H.264 files in mp4 containers using MBAFF coding aren't flagged as being interlaced by FFprobe,
|
||||
// so for H.264 files we also calculate the frame rate from the codec time base and check if it is double the reported
|
||||
// frame rate (both rounded to the nearest integer) to determine if the file is interlaced
|
||||
int roundedTimeBaseFPS = Convert.ToInt32(1 / GetFrameRate(stream.CodecTimeBase) ?? 0);
|
||||
int roundedDoubleFrameRate = Convert.ToInt32(stream.AverageFrameRate * 2 ?? 0);
|
||||
|
||||
bool videoInterlaced = !string.IsNullOrWhiteSpace(streamInfo.FieldOrder)
|
||||
&& !string.Equals(streamInfo.FieldOrder, "progressive", StringComparison.OrdinalIgnoreCase);
|
||||
bool h264MbaffCoded = string.Equals(stream.Codec, "h264", StringComparison.OrdinalIgnoreCase)
|
||||
&& string.IsNullOrWhiteSpace(streamInfo.FieldOrder)
|
||||
&& roundedTimeBaseFPS == roundedDoubleFrameRate;
|
||||
|
||||
if (videoInterlaced || h264MbaffCoded)
|
||||
{
|
||||
stream.IsInterlaced = true;
|
||||
}
|
||||
|
||||
if (isAudio
|
||||
|| string.Equals(stream.Codec, "mjpeg", StringComparison.OrdinalIgnoreCase)
|
||||
|| string.Equals(stream.Codec, "gif", StringComparison.OrdinalIgnoreCase)
|
||||
@@ -1019,27 +1032,32 @@ namespace MediaBrowser.MediaEncoding.Probing
|
||||
/// </summary>
|
||||
/// <param name="value">The value.</param>
|
||||
/// <returns>System.Nullable{System.Single}.</returns>
|
||||
private float? GetFrameRate(string value)
|
||||
internal static float? GetFrameRate(ReadOnlySpan<char> value)
|
||||
{
|
||||
if (string.IsNullOrEmpty(value))
|
||||
if (value.IsEmpty)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var parts = value.Split('/');
|
||||
|
||||
float result;
|
||||
|
||||
if (parts.Length == 2)
|
||||
int index = value.IndexOf('/');
|
||||
if (index == -1)
|
||||
{
|
||||
result = float.Parse(parts[0], CultureInfo.InvariantCulture) / float.Parse(parts[1], CultureInfo.InvariantCulture);
|
||||
}
|
||||
else
|
||||
{
|
||||
result = float.Parse(parts[0], CultureInfo.InvariantCulture);
|
||||
// REVIEW: is this branch actually required? (i.e. does ffprobe ever output something other than a fraction?)
|
||||
if (float.TryParse(value, NumberStyles.AllowThousands | NumberStyles.Float, CultureInfo.InvariantCulture, out var result))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
return float.IsNaN(result) ? null : result;
|
||||
if (!float.TryParse(value[..index], NumberStyles.Integer, CultureInfo.InvariantCulture, out var dividend)
|
||||
|| !float.TryParse(value[(index + 1)..], NumberStyles.Integer, CultureInfo.InvariantCulture, out var divisor))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return divisor == 0f ? null : dividend / divisor;
|
||||
}
|
||||
|
||||
private void SetAudioRuntimeTicks(InternalMediaInfoResult result, MediaInfo data)
|
||||
@@ -1349,8 +1367,8 @@ namespace MediaBrowser.MediaEncoding.Probing
|
||||
}
|
||||
|
||||
// Don't add artist/album artist name to studios, even if it's listed there
|
||||
if (info.Artists.Contains(studio, StringComparer.OrdinalIgnoreCase)
|
||||
|| info.AlbumArtists.Contains(studio, StringComparer.OrdinalIgnoreCase))
|
||||
if (info.Artists.Contains(studio, StringComparison.OrdinalIgnoreCase)
|
||||
|| info.AlbumArtists.Contains(studio, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user