Also collect duration in ffmpeg media info

This commit is contained in:
Nikolaj Olsson 2024-08-26 12:43:55 +02:00
parent 3a425c05d9
commit 9c2ba25011

View File

@ -13,8 +13,10 @@ namespace Nikse.SubtitleEdit.Core.Common
public List<FfmpegTrackInfo> Tracks { get; set; }
public Dimension Dimension { get; set; }
public TimeCode Duration { get; set; }
private static readonly Regex ResolutionRegex = new Regex(@"\d\d+x\d\d+", RegexOptions.Compiled);
private static readonly Regex DurationRegex = new Regex(@"Duration: \d+[:\.,]\d+[:\.,]\d+[:\.,]\d+", RegexOptions.Compiled);
private FfmpegMediaInfo()
{
@ -97,6 +99,13 @@ namespace Nikse.SubtitleEdit.Core.Common
}
}
}
var match = DurationRegex.Match(line);
if (match.Success)
{
var timeCodeString = match.Value.Split(' ')[1];
info.Duration = new TimeCode(TimeCode.ParseToMilliseconds(timeCodeString));
}
}
return info;