aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTechywarrior <techywarrior@gmail.com>2013-04-15 16:44:27 -0700
committerTechywarrior <techywarrior@gmail.com>2013-04-15 16:44:27 -0700
commit2009856e41015eab34a78f9f8f94976a5272aaa6 (patch)
tree12a48e1c11109c3e1e243cf997baedde3cae5750
parent27d2d2b89a4bc1ca21b0acc3c6df35360e58667e (diff)
parent06a7d64525c12c02c0151354d484d8a8649d2c45 (diff)
Merge branch 'master' of https://github.com/MediaBrowser/MediaBrowser
-rw-r--r--MediaBrowser.Server.Implementations/HttpServer/HttpServer.cs5
-rw-r--r--MediaBrowser.Server.Implementations/MediaEncoder/MediaEncoder.cs24
2 files changed, 21 insertions, 8 deletions
diff --git a/MediaBrowser.Server.Implementations/HttpServer/HttpServer.cs b/MediaBrowser.Server.Implementations/HttpServer/HttpServer.cs
index 990dc7671..9637817ce 100644
--- a/MediaBrowser.Server.Implementations/HttpServer/HttpServer.cs
+++ b/MediaBrowser.Server.Implementations/HttpServer/HttpServer.cs
@@ -357,10 +357,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer
_logger.ErrorException("AcceptWebSocketAsync error", ex);
ctx.Response.StatusCode = 500;
- }
- finally
- {
- ctx.Response.Close();
+ ctx.Response.Close();
}
}
diff --git a/MediaBrowser.Server.Implementations/MediaEncoder/MediaEncoder.cs b/MediaBrowser.Server.Implementations/MediaEncoder/MediaEncoder.cs
index 709c21f50..9b1a73349 100644
--- a/MediaBrowser.Server.Implementations/MediaEncoder/MediaEncoder.cs
+++ b/MediaBrowser.Server.Implementations/MediaEncoder/MediaEncoder.cs
@@ -708,11 +708,26 @@ namespace MediaBrowser.Server.Implementations.MediaEncoder
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Task.</returns>
/// <exception cref="System.ArgumentException">Must use inputPath list overload</exception>
- public Task ExtractImage(string[] inputFiles, InputType type, TimeSpan? offset, string outputPath, CancellationToken cancellationToken)
+ public async Task ExtractImage(string[] inputFiles, InputType type, TimeSpan? offset, string outputPath, CancellationToken cancellationToken)
{
var resourcePool = type == InputType.AudioFile ? _audioImageResourcePool : _videoImageResourcePool;
- return ExtractImageInternal(GetInputArgument(inputFiles, type), type, offset, outputPath, resourcePool, cancellationToken);
+ var inputArgument = GetInputArgument(inputFiles, type);
+
+ if (type != InputType.AudioFile)
+ {
+ try
+ {
+ await ExtractImageInternal(inputArgument, type, offset, outputPath, true, resourcePool, cancellationToken).ConfigureAwait(false);
+ return;
+ }
+ catch
+ {
+ _logger.Error("I-frame image extraction failed, will attempt standard way. Input: {0}", inputArgument);
+ }
+ }
+
+ await ExtractImageInternal(inputArgument, type, offset, outputPath, false, resourcePool, cancellationToken).ConfigureAwait(false);
}
/// <summary>
@@ -722,6 +737,7 @@ namespace MediaBrowser.Server.Implementations.MediaEncoder
/// <param name="type">The type.</param>
/// <param name="offset">The offset.</param>
/// <param name="outputPath">The output path.</param>
+ /// <param name="useIFrame">if set to <c>true</c> [use I frame].</param>
/// <param name="resourcePool">The resource pool.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Task.</returns>
@@ -729,7 +745,7 @@ namespace MediaBrowser.Server.Implementations.MediaEncoder
/// or
/// outputPath</exception>
/// <exception cref="System.ApplicationException"></exception>
- private async Task ExtractImageInternal(string inputPath, InputType type, TimeSpan? offset, string outputPath, SemaphoreSlim resourcePool, CancellationToken cancellationToken)
+ private async Task ExtractImageInternal(string inputPath, InputType type, TimeSpan? offset, string outputPath, bool useIFrame, SemaphoreSlim resourcePool, CancellationToken cancellationToken)
{
if (string.IsNullOrEmpty(inputPath))
{
@@ -741,7 +757,7 @@ namespace MediaBrowser.Server.Implementations.MediaEncoder
throw new ArgumentNullException("outputPath");
}
- var args = type != InputType.Dvd ? string.Format("-i {0} -threads 0 -v quiet -vframes 1 -filter:v select=\\'eq(pict_type\\,I)\\' -f image2 \"{1}\"", inputPath, outputPath) :
+ var args = useIFrame ? string.Format("-i {0} -threads 0 -v quiet -vframes 1 -filter:v select=\\'eq(pict_type\\,I)\\' -f image2 \"{1}\"", inputPath, outputPath) :
string.Format("-i {0} -threads 0 -v quiet -vframes 1 -f image2 \"{1}\"", inputPath, outputPath);
var probeSize = GetProbeSizeArgument(type);