diff --git a/FFMpegCore/FFProbe/MediaAnalysis.cs b/FFMpegCore/FFProbe/MediaAnalysis.cs index 887baeb..af37cf2 100644 --- a/FFMpegCore/FFProbe/MediaAnalysis.cs +++ b/FFMpegCore/FFProbe/MediaAnalysis.cs @@ -30,9 +30,12 @@ private MediaFormat ParseFormat(Format analysisFormat) }; } + private string GetValue(string tagName, Dictionary? tags, string defaultValue) => + tags == null ? defaultValue : tags.TryGetValue(tagName, out var value) ? value : defaultValue; + private ChapterData ParseChapter(Chapter analysisChapter) { - var title = analysisChapter.Tags.FirstOrDefault(t => t.Key == "title").Value; + var title = GetValue("title", analysisChapter.Tags, "TitleValueNotSet"); var start = MediaAnalysisUtils.ParseDuration(analysisChapter.StartTime); var end = MediaAnalysisUtils.ParseDuration(analysisChapter.EndTime);