mirror of
https://github.com/rosenbjerg/FFMpegCore.git
synced 2024-11-10 08:34:12 +01:00
Fix duration parsing of .mkv and .webm files
Former-commit-id: a4c7d87e62
This commit is contained in:
parent
3ed5c7b314
commit
37fc05b26b
2 changed files with 24 additions and 3 deletions
|
@ -31,8 +31,18 @@ internal class Stream
|
|||
|
||||
[JsonProperty("r_frame_rate")]
|
||||
internal string FrameRate { get; set; }
|
||||
|
||||
[JsonProperty("tags")]
|
||||
internal Tags Tags { get; set; }
|
||||
}
|
||||
|
||||
internal class Tags
|
||||
{
|
||||
[JsonProperty("DURATION")]
|
||||
internal string Duration { get; set; }
|
||||
}
|
||||
|
||||
|
||||
internal class FFMpegStreamMetadata
|
||||
{
|
||||
[JsonProperty("streams")]
|
||||
|
|
|
@ -79,8 +79,19 @@ private VideoInfo ParseVideoInfoInternal(VideoInfo info, string probeOutput)
|
|||
double videoSize = 0d;
|
||||
double audioSize = 0d;
|
||||
|
||||
var duration = TimeSpan.FromSeconds(double.TryParse((video ?? audio).Duration, NumberStyles.Any, CultureInfo.InvariantCulture, out var output) ? output : 0);
|
||||
info.Duration = duration.Subtract(TimeSpan.FromMilliseconds(duration.Milliseconds));
|
||||
string sDuration = (video ?? audio).Duration;
|
||||
TimeSpan duration;
|
||||
if (sDuration != null)
|
||||
{
|
||||
duration = TimeSpan.FromSeconds(double.TryParse(sDuration, NumberStyles.Any, CultureInfo.InvariantCulture, out var output) ? output : 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
sDuration = (video ?? audio).Tags.Duration;
|
||||
TimeSpan.TryParse(sDuration.Remove(sDuration.LastIndexOf('.')), CultureInfo.InvariantCulture, out duration);
|
||||
}
|
||||
// Strip milliseconds and additional ticks
|
||||
info.Duration = new TimeSpan(duration.Days, duration.Hours, duration.Minutes, duration.Seconds);
|
||||
|
||||
if (video != null)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue