Use audio and general stream runtimes when video runtime is zero
Fixed: Getting runtime from files should be more reliable
This commit is contained in:
parent
0534e36151
commit
8698bc7815
|
@ -46,7 +46,9 @@ namespace NzbDrone.Core.MediaFiles.MediaInfo
|
||||||
int height;
|
int height;
|
||||||
int videoBitRate;
|
int videoBitRate;
|
||||||
int audioBitRate;
|
int audioBitRate;
|
||||||
int runTime;
|
int audioRuntime;
|
||||||
|
int videoRuntime;
|
||||||
|
int generalRuntime;
|
||||||
int streamCount;
|
int streamCount;
|
||||||
int audioChannels;
|
int audioChannels;
|
||||||
decimal videoFrameRate;
|
decimal videoFrameRate;
|
||||||
|
@ -56,9 +58,13 @@ namespace NzbDrone.Core.MediaFiles.MediaInfo
|
||||||
Int32.TryParse(mediaInfo.Get(StreamKind.Video, 0, "Width"), out width);
|
Int32.TryParse(mediaInfo.Get(StreamKind.Video, 0, "Width"), out width);
|
||||||
Int32.TryParse(mediaInfo.Get(StreamKind.Video, 0, "Height"), out height);
|
Int32.TryParse(mediaInfo.Get(StreamKind.Video, 0, "Height"), out height);
|
||||||
Int32.TryParse(mediaInfo.Get(StreamKind.Video, 0, "BitRate"), out videoBitRate);
|
Int32.TryParse(mediaInfo.Get(StreamKind.Video, 0, "BitRate"), out videoBitRate);
|
||||||
Int32.TryParse(mediaInfo.Get(StreamKind.Video, 0, "PlayTime"), out runTime);
|
|
||||||
Decimal.TryParse(mediaInfo.Get(StreamKind.Video, 0, "FrameRate"), out videoFrameRate);
|
Decimal.TryParse(mediaInfo.Get(StreamKind.Video, 0, "FrameRate"), out videoFrameRate);
|
||||||
|
|
||||||
|
//Runtime
|
||||||
|
Int32.TryParse(mediaInfo.Get(StreamKind.Video, 0, "PlayTime"), out videoRuntime);
|
||||||
|
Int32.TryParse(mediaInfo.Get(StreamKind.Audio, 0, "PlayTime"), out audioRuntime);
|
||||||
|
Int32.TryParse(mediaInfo.Get(StreamKind.General, 0, "PlayTime"), out generalRuntime);
|
||||||
|
|
||||||
string aBitRate = mediaInfo.Get(StreamKind.Audio, 0, "BitRate");
|
string aBitRate = mediaInfo.Get(StreamKind.Audio, 0, "BitRate");
|
||||||
int aBindex = aBitRate.IndexOf(" /", StringComparison.InvariantCultureIgnoreCase);
|
int aBindex = aBitRate.IndexOf(" /", StringComparison.InvariantCultureIgnoreCase);
|
||||||
if (aBindex > 0)
|
if (aBindex > 0)
|
||||||
|
@ -87,10 +93,9 @@ namespace NzbDrone.Core.MediaFiles.MediaInfo
|
||||||
VideoBitrate = videoBitRate,
|
VideoBitrate = videoBitRate,
|
||||||
Height = height,
|
Height = height,
|
||||||
Width = width,
|
Width = width,
|
||||||
|
|
||||||
AudioFormat = mediaInfo.Get(StreamKind.Audio, 0, "Format"),
|
AudioFormat = mediaInfo.Get(StreamKind.Audio, 0, "Format"),
|
||||||
AudioBitrate = audioBitRate,
|
AudioBitrate = audioBitRate,
|
||||||
RunTime = TimeSpan.FromMilliseconds(runTime),
|
RunTime = GetBestRuntime(audioRuntime, videoRuntime, generalRuntime),
|
||||||
AudioStreamCount = streamCount,
|
AudioStreamCount = streamCount,
|
||||||
AudioChannels = audioChannels,
|
AudioChannels = audioChannels,
|
||||||
AudioProfile = audioProfile.Trim(),
|
AudioProfile = audioProfile.Trim(),
|
||||||
|
@ -100,7 +105,6 @@ namespace NzbDrone.Core.MediaFiles.MediaInfo
|
||||||
ScanType = scanType
|
ScanType = scanType
|
||||||
};
|
};
|
||||||
|
|
||||||
mediaInfo.Close();
|
|
||||||
return mediaInfoModel;
|
return mediaInfoModel;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -135,5 +139,20 @@ namespace NzbDrone.Core.MediaFiles.MediaInfo
|
||||||
|
|
||||||
return info.RunTime;
|
return info.RunTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private TimeSpan GetBestRuntime(int audio, int video, int general)
|
||||||
|
{
|
||||||
|
if (video == 0)
|
||||||
|
{
|
||||||
|
if (audio == 0)
|
||||||
|
{
|
||||||
|
return TimeSpan.FromMilliseconds(general);
|
||||||
|
}
|
||||||
|
|
||||||
|
return TimeSpan.FromMilliseconds(audio);
|
||||||
|
}
|
||||||
|
|
||||||
|
return TimeSpan.FromMilliseconds(video);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue