mirror of
https://github.com/rosenbjerg/FFMpegCore.git
synced 2024-11-10 08:34:12 +01:00
Fix NullReferenceException if no duration exists
This commit is contained in:
parent
0b35935b5d
commit
5daef17b44
1 changed files with 3 additions and 2 deletions
|
@ -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;
|
||||
|
||||
|
|
Loading…
Reference in a new issue