mirror of
https://github.com/rosenbjerg/FFMpegCore.git
synced 2024-11-10 08:34:12 +01:00
Fix NullReferenceException if no duration exists
Former-commit-id: 5daef17b44
This commit is contained in:
parent
073cfee5ea
commit
703da64f44
1 changed files with 3 additions and 2 deletions
|
@ -77,7 +77,7 @@ private VideoInfo ParseVideoInfoInternal(VideoInfo info, string probeOutput)
|
||||||
double audioSize = 0d;
|
double audioSize = 0d;
|
||||||
|
|
||||||
string sDuration = (video ?? audio).Duration;
|
string sDuration = (video ?? audio).Duration;
|
||||||
TimeSpan duration;
|
TimeSpan duration = TimeSpan.Zero;
|
||||||
if (sDuration != null)
|
if (sDuration != null)
|
||||||
{
|
{
|
||||||
duration = TimeSpan.FromSeconds(double.TryParse(sDuration, NumberStyles.Any, CultureInfo.InvariantCulture, out var output) ? output : 0);
|
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
|
else
|
||||||
{
|
{
|
||||||
sDuration = (video ?? audio).Tags.Duration;
|
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
|
TimeSpan.TryParse(sDuration.Remove(sDuration.LastIndexOf('.') + 8), CultureInfo.InvariantCulture, out duration); // TimeSpan fractions only allow up to 7 digits
|
||||||
}
|
}
|
||||||
info.Duration = duration;
|
info.Duration = duration;
|
||||||
|
|
Loading…
Reference in a new issue