diff options
| author | LukePulverenti Luke Pulverenti luke pulverenti <LukePulverenti Luke Pulverenti luke.pulverenti@gmail.com> | 2012-08-25 11:30:37 -0400 |
|---|---|---|
| committer | LukePulverenti Luke Pulverenti luke pulverenti <LukePulverenti Luke Pulverenti luke.pulverenti@gmail.com> | 2012-08-25 11:30:37 -0400 |
| commit | 37dd0c8bdde20ce83e95a638f913dbfd7ae41f85 (patch) | |
| tree | fc92bdacdc46f9dd384ef1865c2e5b1e95c47537 | |
| parent | bbbe6164dc592cbeb934cf398dca0044e7b2f77e (diff) | |
Added some ffprobe error handling
| -rw-r--r-- | MediaBrowser.Controller/FFMpeg/FFProbe.cs | 7 | ||||
| -rw-r--r-- | MediaBrowser.Controller/Providers/AudioInfoProvider.cs | 23 | ||||
| -rw-r--r-- | MediaBrowser.Controller/Providers/VideoInfoProvider.cs | 61 |
3 files changed, 54 insertions, 37 deletions
diff --git a/MediaBrowser.Controller/FFMpeg/FFProbe.cs b/MediaBrowser.Controller/FFMpeg/FFProbe.cs index 791f47b29..da5e11c5b 100644 --- a/MediaBrowser.Controller/FFMpeg/FFProbe.cs +++ b/MediaBrowser.Controller/FFMpeg/FFProbe.cs @@ -35,8 +35,11 @@ namespace MediaBrowser.Controller.FFMpeg FFProbeResult result = Run(item.Path);
- // Fire and forget
- CacheResult(result, cachePath);
+ if (result != null)
+ {
+ // Fire and forget
+ CacheResult(result, cachePath);
+ }
return result;
}
diff --git a/MediaBrowser.Controller/Providers/AudioInfoProvider.cs b/MediaBrowser.Controller/Providers/AudioInfoProvider.cs index ce0759715..709589cdb 100644 --- a/MediaBrowser.Controller/Providers/AudioInfoProvider.cs +++ b/MediaBrowser.Controller/Providers/AudioInfoProvider.cs @@ -26,12 +26,6 @@ namespace MediaBrowser.Controller.Providers protected override 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;
@@ -176,16 +170,25 @@ namespace MediaBrowser.Controller.Providers FFProbeResult result = FFProbe.Run(myItem, CacheDirectory);
- if (result.format.tags != null)
+ if (result == null)
+ {
+ Logger.LogInfo("Null FFProbeResult for {0} {1}", item.Id, item.Name);
+ return;
+ }
+
+ if (result.format != null && result.format.tags != null)
{
result.format.tags = ConvertDictionaryToCaseInSensitive(result.format.tags);
}
- foreach (MediaStream stream in result.streams)
+ if (result.streams != null)
{
- if (stream.tags != null)
+ foreach (MediaStream stream in result.streams)
{
- stream.tags = ConvertDictionaryToCaseInSensitive(stream.tags);
+ if (stream.tags != null)
+ {
+ stream.tags = ConvertDictionaryToCaseInSensitive(stream.tags);
+ }
}
}
diff --git a/MediaBrowser.Controller/Providers/VideoInfoProvider.cs b/MediaBrowser.Controller/Providers/VideoInfoProvider.cs index fdc4a1147..4da83a8cc 100644 --- a/MediaBrowser.Controller/Providers/VideoInfoProvider.cs +++ b/MediaBrowser.Controller/Providers/VideoInfoProvider.cs @@ -27,40 +27,40 @@ namespace MediaBrowser.Controller.Providers protected override void Fetch(Video video, FFProbeResult data)
{
- if (data == null)
+ if (data.format != 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;
+ }
- if (!string.IsNullOrEmpty(data.format.duration))
- {
- video.RunTimeTicks = TimeSpan.FromSeconds(double.Parse(data.format.duration)).Ticks;
+ if (!string.IsNullOrEmpty(data.format.bit_rate))
+ {
+ video.BitRate = int.Parse(data.format.bit_rate);
+ }
}
- if (!string.IsNullOrEmpty(data.format.bit_rate))
+ if (data.streams != null)
{
- video.BitRate = int.Parse(data.format.bit_rate);
- }
-
- // For now, only read info about first video stream
- // Files with multiple video streams are possible, but extremely rare
- bool foundVideo = false;
+ // For now, only read info about first video stream
+ // Files with multiple video streams are possible, but extremely rare
+ bool foundVideo = false;
- foreach (MediaStream stream in data.streams)
- {
- if (stream.codec_type.Equals("video", StringComparison.OrdinalIgnoreCase))
+ foreach (MediaStream stream in data.streams)
{
- if (!foundVideo)
+ if (stream.codec_type.Equals("video", StringComparison.OrdinalIgnoreCase))
{
- FetchFromVideoStream(video, stream);
- }
+ if (!foundVideo)
+ {
+ FetchFromVideoStream(video, stream);
+ }
- foundVideo = true;
- }
- else if (stream.codec_type.Equals("audio", StringComparison.OrdinalIgnoreCase))
- {
- FetchFromAudioStream(video, stream);
+ foundVideo = true;
+ }
+ else if (stream.codec_type.Equals("audio", StringComparison.OrdinalIgnoreCase))
+ {
+ FetchFromAudioStream(video, stream);
+ }
}
}
}
@@ -111,6 +111,17 @@ namespace MediaBrowser.Controller.Providers streams.Add(audio);
video.AudioStreams = streams;
}
+
+ private void FetchFromSubtitleStream(Video video, MediaStream stream)
+ {
+ SubtitleStream subtitle = new SubtitleStream();
+
+ subtitle.Language = GetDictionaryValue(stream.tags, "language");
+
+ List<SubtitleStream> streams = video.Subtitles ?? new List<SubtitleStream>();
+ streams.Add(subtitle);
+ video.Subtitles = streams;
+ }
/// <summary>
/// Determines if there's already enough info in the Video object to allow us to skip running ffprobe
|
