From 5daef17b4443b93c1759fb39256cf2befdbeb873 Mon Sep 17 00:00:00 2001 From: Crydsch Date: Thu, 13 Feb 2020 20:58:14 +0100 Subject: [PATCH] Fix NullReferenceException if no duration exists --- FFMpegCore/FFMPEG/FFProbe.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/FFMpegCore/FFMPEG/FFProbe.cs b/FFMpegCore/FFMPEG/FFProbe.cs index 2c69aff..b4e0012 100644 --- a/FFMpegCore/FFMPEG/FFProbe.cs +++ b/FFMpegCore/FFMPEG/FFProbe.cs @@ -77,7 +77,7 @@ private VideoInfo ParseVideoInfoInternal(VideoInfo info, string probeOutput) double audioSize = 0d; string sDuration = (video ?? audio).Duration; - TimeSpan duration; + TimeSpan duration = TimeSpan.Zero; if (sDuration != null) { duration = TimeSpan.FromSeconds(double.TryParse(sDuration, NumberStyles.Any, CultureInfo.InvariantCulture, out var output) ? output : 0); @@ -85,7 +85,8 @@ private VideoInfo ParseVideoInfoInternal(VideoInfo info, string probeOutput) else { sDuration = (video ?? audio).Tags.Duration; - TimeSpan.TryParse(sDuration.Remove(sDuration.LastIndexOf('.') + 8), CultureInfo.InvariantCulture, out duration); // TimeSpan fractions only allow up to 7 digits + if (sDuration != null) + TimeSpan.TryParse(sDuration.Remove(sDuration.LastIndexOf('.') + 8), CultureInfo.InvariantCulture, out duration); // TimeSpan fractions only allow up to 7 digits } info.Duration = duration;