diff --git a/MediaBrowser.Common/MediaInfo/IMediaEncoder.cs b/MediaBrowser.Common/MediaInfo/IMediaEncoder.cs
index 84eded043c..a409dd76cd 100644
--- a/MediaBrowser.Common/MediaInfo/IMediaEncoder.cs
+++ b/MediaBrowser.Common/MediaInfo/IMediaEncoder.cs
@@ -1,6 +1,7 @@
using System;
using System.Threading;
using System.Threading.Tasks;
+using MediaBrowser.Model.Entities;
namespace MediaBrowser.Common.MediaInfo
{
@@ -26,11 +27,12 @@ namespace MediaBrowser.Common.MediaInfo
///
/// The input files.
/// The type.
+ /// The threed format.
/// The offset.
/// The output path.
/// The cancellation token.
/// Task.
- Task ExtractImage(string[] inputFiles, InputType type, TimeSpan? offset, string outputPath, CancellationToken cancellationToken);
+ Task ExtractImage(string[] inputFiles, InputType type, Video3DFormat? threedFormat, TimeSpan? offset, string outputPath, CancellationToken cancellationToken);
///
/// Extracts the text subtitle.
diff --git a/MediaBrowser.Controller/MediaInfo/FFMpegManager.cs b/MediaBrowser.Controller/MediaInfo/FFMpegManager.cs
index 81ab155486..f402cec203 100644
--- a/MediaBrowser.Controller/MediaInfo/FFMpegManager.cs
+++ b/MediaBrowser.Controller/MediaInfo/FFMpegManager.cs
@@ -169,7 +169,7 @@ namespace MediaBrowser.Controller.MediaInfo
Directory.CreateDirectory(parentPath);
}
- await _encoder.ExtractImage(inputPath, type, time, path, cancellationToken).ConfigureAwait(false);
+ await _encoder.ExtractImage(inputPath, type, video.Video3DFormat, time, path, cancellationToken).ConfigureAwait(false);
chapter.ImagePath = path;
changesMade = true;
}
diff --git a/MediaBrowser.Providers/MediaInfo/AudioImageProvider.cs b/MediaBrowser.Providers/MediaInfo/AudioImageProvider.cs
index ab3fbff55a..2b856d1108 100644
--- a/MediaBrowser.Providers/MediaInfo/AudioImageProvider.cs
+++ b/MediaBrowser.Providers/MediaInfo/AudioImageProvider.cs
@@ -186,7 +186,7 @@ namespace MediaBrowser.Providers.MediaInfo
Directory.CreateDirectory(parentPath);
}
- await _mediaEncoder.ExtractImage(new[] { item.Path }, InputType.AudioFile, null, path, cancellationToken).ConfigureAwait(false);
+ await _mediaEncoder.ExtractImage(new[] { item.Path }, InputType.AudioFile, null, null, path, cancellationToken).ConfigureAwait(false);
}
finally
{
diff --git a/MediaBrowser.Server.Implementations/MediaEncoder/MediaEncoder.cs b/MediaBrowser.Server.Implementations/MediaEncoder/MediaEncoder.cs
index 711d5bc327..d00fbdd1dc 100644
--- a/MediaBrowser.Server.Implementations/MediaEncoder/MediaEncoder.cs
+++ b/MediaBrowser.Server.Implementations/MediaEncoder/MediaEncoder.cs
@@ -880,12 +880,13 @@ namespace MediaBrowser.Server.Implementations.MediaEncoder
///
/// The input files.
/// The type.
+ /// The threed format.
/// The offset.
/// The output path.
/// The cancellation token.
/// Task.
/// Must use inputPath list overload
- public async Task ExtractImage(string[] inputFiles, InputType type, TimeSpan? offset, string outputPath, CancellationToken cancellationToken)
+ public async Task ExtractImage(string[] inputFiles, InputType type, Video3DFormat? threedFormat, TimeSpan? offset, string outputPath, CancellationToken cancellationToken)
{
var resourcePool = type == InputType.AudioFile ? _audioImageResourcePool : _videoImageResourcePool;
@@ -895,7 +896,7 @@ namespace MediaBrowser.Server.Implementations.MediaEncoder
{
try
{
- await ExtractImageInternal(inputArgument, type, offset, outputPath, true, resourcePool, cancellationToken).ConfigureAwait(false);
+ await ExtractImageInternal(inputArgument, type, threedFormat, offset, outputPath, true, resourcePool, cancellationToken).ConfigureAwait(false);
return;
}
catch
@@ -904,7 +905,7 @@ namespace MediaBrowser.Server.Implementations.MediaEncoder
}
}
- await ExtractImageInternal(inputArgument, type, offset, outputPath, false, resourcePool, cancellationToken).ConfigureAwait(false);
+ await ExtractImageInternal(inputArgument, type, threedFormat, offset, outputPath, false, resourcePool, cancellationToken).ConfigureAwait(false);
}
///
@@ -912,6 +913,7 @@ namespace MediaBrowser.Server.Implementations.MediaEncoder
///
/// The input path.
/// The type.
+ /// The threed format.
/// The offset.
/// The output path.
/// if set to true [use I frame].
@@ -922,7 +924,7 @@ namespace MediaBrowser.Server.Implementations.MediaEncoder
/// or
/// outputPath
///
- private async Task ExtractImageInternal(string inputPath, InputType type, TimeSpan? offset, string outputPath, bool useIFrame, SemaphoreSlim resourcePool, CancellationToken cancellationToken)
+ private async Task ExtractImageInternal(string inputPath, InputType type, Video3DFormat? threedFormat, TimeSpan? offset, string outputPath, bool useIFrame, SemaphoreSlim resourcePool, CancellationToken cancellationToken)
{
if (string.IsNullOrEmpty(inputPath))
{
@@ -934,8 +936,25 @@ namespace MediaBrowser.Server.Implementations.MediaEncoder
throw new ArgumentNullException("outputPath");
}
- var args = useIFrame ? string.Format("-i {0} -threads 0 -v quiet -vframes 1 -filter:v select=\"eq(pict_type\\,I)\" -vf \"scale=iw*sar:ih, scale=600:-1\" -f image2 \"{1}\"", inputPath, outputPath) :
- string.Format("-i {0} -threads 0 -v quiet -vframes 1 -vf \"scale=iw*sar:ih, scale=600:-1\" -f image2 \"{1}\"", inputPath, outputPath);
+ var vf = "scale=iw*sar:ih, scale=600:-1";
+
+ if (threedFormat.HasValue)
+ {
+ switch (threedFormat.Value)
+ {
+ case Video3DFormat.HalfSideBySide:
+ case Video3DFormat.FullSideBySide:
+ vf = "crop=iw/2:ih:0:0,scale=(iw*2):ih,scale=600:-1";
+ break;
+ case Video3DFormat.HalfTopAndBottom:
+ case Video3DFormat.FullTopAndBottom:
+ vf = "crop=iw:ih/2:0:0,scale=iw:(ih*2),scale=600:-1";
+ break;
+ }
+ }
+
+ var args = useIFrame ? string.Format("-i {0} -threads 0 -v quiet -vframes 1 -filter:v select=\"eq(pict_type\\,I)\" -vf \"{2}\" -f image2 \"{1}\"", inputPath, outputPath, vf) :
+ string.Format("-i {0} -threads 0 -v quiet -vframes 1 -vf \"{2}\" -f image2 \"{1}\"", inputPath, outputPath, vf);
var probeSize = GetProbeSizeArgument(type);
diff --git a/MediaBrowser.Server.Implementations/ScheduledTasks/VideoImagesTask.cs b/MediaBrowser.Server.Implementations/ScheduledTasks/VideoImagesTask.cs
index b19c41ad36..03be1ba39f 100644
--- a/MediaBrowser.Server.Implementations/ScheduledTasks/VideoImagesTask.cs
+++ b/MediaBrowser.Server.Implementations/ScheduledTasks/VideoImagesTask.cs
@@ -327,7 +327,7 @@ namespace MediaBrowser.Server.Implementations.ScheduledTasks
var inputPath = MediaEncoderHelpers.GetInputArgument(video, isoMount, out type);
- await _mediaEncoder.ExtractImage(inputPath, type, imageOffset, path, cancellationToken).ConfigureAwait(false);
+ await _mediaEncoder.ExtractImage(inputPath, type, video.Video3DFormat, imageOffset, path, cancellationToken).ConfigureAwait(false);
video.PrimaryImagePath = path;
}