Added some null checks and logging when parsing ffprobe output

This commit is contained in:
LukePulverenti Luke Pulverenti luke pulverenti 2012-08-22 16:57:29 -04:00
parent b15c064bba
commit 863ca986bd
3 changed files with 14 additions and 2 deletions

View File

@ -66,8 +66,6 @@ namespace MediaBrowser.Controller.FFMpeg
private static FFProbeResult Run(string input)
{
MediaBrowser.Common.Logging.Logger.LogInfo(input);
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.CreateNoWindow = true;

View File

@ -4,6 +4,7 @@ using System.ComponentModel.Composition;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using MediaBrowser.Common.Logging;
using MediaBrowser.Controller.Events;
using MediaBrowser.Controller.FFMpeg;
using MediaBrowser.Model.Entities;
@ -35,6 +36,12 @@ namespace MediaBrowser.Controller.Providers
private void Fetch(Audio audio, FFProbeResult data)
{
if (data == null)
{
Logger.LogInfo("Null FFProbeResult for {0} {1}", audio.Id, audio.Name);
return;
}
MediaStream stream = data.streams.First(s => s.codec_type.Equals("audio", StringComparison.OrdinalIgnoreCase));
string bitrate = null;

View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Linq;
using System.Threading.Tasks;
using MediaBrowser.Common.Logging;
using MediaBrowser.Controller.Events;
using MediaBrowser.Controller.FFMpeg;
using MediaBrowser.Model.Entities;
@ -47,6 +48,12 @@ namespace MediaBrowser.Controller.Providers
private void Fetch(Video video, FFProbeResult data)
{
if (data == null)
{
Logger.LogInfo("Null FFProbeResult for {0} {1}", video.Id, video.Name);
return;
}
if (!string.IsNullOrEmpty(data.format.duration))
{
video.RunTimeTicks = TimeSpan.FromSeconds(double.Parse(data.format.duration)).Ticks;