mirror of
https://github.com/rosenbjerg/FFMpegCore.git
synced 2024-11-10 08:34:12 +01:00
Make Tags and Disposition dictionaries case-insensivite #295
This commit is contained in:
parent
fc86a64b9e
commit
90155efe75
1 changed files with 10 additions and 5 deletions
|
@ -25,7 +25,7 @@ private MediaFormat ParseFormat(Format analysisFormat)
|
||||||
StreamCount = analysisFormat.NbStreams,
|
StreamCount = analysisFormat.NbStreams,
|
||||||
ProbeScore = analysisFormat.ProbeScore,
|
ProbeScore = analysisFormat.ProbeScore,
|
||||||
BitRate = long.Parse(analysisFormat.BitRate ?? "0"),
|
BitRate = long.Parse(analysisFormat.BitRate ?? "0"),
|
||||||
Tags = analysisFormat.Tags,
|
Tags = analysisFormat.Tags.ToCaseInsensitive(),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ private VideoStream ParseVideoStream(FFProbeStream stream)
|
||||||
Rotation = (int)float.Parse(stream.GetRotate() ?? "0"),
|
Rotation = (int)float.Parse(stream.GetRotate() ?? "0"),
|
||||||
Language = stream.GetLanguage(),
|
Language = stream.GetLanguage(),
|
||||||
Disposition = MediaAnalysisUtils.FormatDisposition(stream.Disposition),
|
Disposition = MediaAnalysisUtils.FormatDisposition(stream.Disposition),
|
||||||
Tags = stream.Tags,
|
Tags = stream.Tags.ToCaseInsensitive(),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,7 +90,7 @@ private AudioStream ParseAudioStream(FFProbeStream stream)
|
||||||
Profile = stream.Profile,
|
Profile = stream.Profile,
|
||||||
Language = stream.GetLanguage(),
|
Language = stream.GetLanguage(),
|
||||||
Disposition = MediaAnalysisUtils.FormatDisposition(stream.Disposition),
|
Disposition = MediaAnalysisUtils.FormatDisposition(stream.Disposition),
|
||||||
Tags = stream.Tags,
|
Tags = stream.Tags.ToCaseInsensitive(),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,15 +105,20 @@ private SubtitleStream ParseSubtitleStream(FFProbeStream stream)
|
||||||
Duration = MediaAnalysisUtils.ParseDuration(stream),
|
Duration = MediaAnalysisUtils.ParseDuration(stream),
|
||||||
Language = stream.GetLanguage(),
|
Language = stream.GetLanguage(),
|
||||||
Disposition = MediaAnalysisUtils.FormatDisposition(stream.Disposition),
|
Disposition = MediaAnalysisUtils.FormatDisposition(stream.Disposition),
|
||||||
Tags = stream.Tags,
|
Tags = stream.Tags.ToCaseInsensitive(),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class MediaAnalysisUtils
|
public static class MediaAnalysisUtils
|
||||||
{
|
{
|
||||||
private static readonly Regex DurationRegex = new Regex(@"^(\d+):(\d{1,2}):(\d{1,2})\.(\d{1,3})", RegexOptions.Compiled);
|
private static readonly Regex DurationRegex = new Regex(@"^(\d+):(\d{1,2}):(\d{1,2})\.(\d{1,3})", RegexOptions.Compiled);
|
||||||
|
|
||||||
|
internal static Dictionary<string, string> ToCaseInsensitive(this Dictionary<string, string> dictionary)
|
||||||
|
{
|
||||||
|
return dictionary.ToDictionary(tag => tag.Key, tag => tag.Value, StringComparer.OrdinalIgnoreCase);
|
||||||
|
}
|
||||||
public static double DivideRatio((double, double) ratio) => ratio.Item1 / ratio.Item2;
|
public static double DivideRatio((double, double) ratio) => ratio.Item1 / ratio.Item2;
|
||||||
|
|
||||||
public static (int, int) ParseRatioInt(string input, char separator)
|
public static (int, int) ParseRatioInt(string input, char separator)
|
||||||
|
@ -184,7 +189,7 @@ public static TimeSpan ParseDuration(FFProbeStream ffProbeStream)
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
var result = new Dictionary<string, bool>(disposition.Count);
|
var result = new Dictionary<string, bool>(disposition.Count, StringComparer.Ordinal);
|
||||||
|
|
||||||
foreach (var pair in disposition)
|
foreach (var pair in disposition)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue