Fix NullReferenceException if no duration exists

Former-commit-id: 5daef17b44
This commit is contained in:
Crydsch 2020-02-13 20:58:14 +01:00
parent 073cfee5ea
commit 703da64f44

View file

@ -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,6 +85,7 @@ private VideoInfo ParseVideoInfoInternal(VideoInfo info, string probeOutput)
else
{
sDuration = (video ?? audio).Tags.Duration;
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;