aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Controller/MediaEncoding
diff options
context:
space:
mode:
Diffstat (limited to 'MediaBrowser.Controller/MediaEncoding')
-rw-r--r--MediaBrowser.Controller/MediaEncoding/ChapterImageRefreshOptions.cs17
-rw-r--r--MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs169
-rw-r--r--MediaBrowser.Controller/MediaEncoding/EncodingJobInfo.cs15
-rw-r--r--MediaBrowser.Controller/MediaEncoding/IEncodingManager.cs10
-rw-r--r--MediaBrowser.Controller/MediaEncoding/IMediaEncoder.cs28
-rw-r--r--MediaBrowser.Controller/MediaEncoding/JobLogger.cs149
-rw-r--r--MediaBrowser.Controller/MediaEncoding/MediaEncoderHelpers.cs21
-rw-r--r--MediaBrowser.Controller/MediaEncoding/MediaInfoRequest.cs4
8 files changed, 141 insertions, 272 deletions
diff --git a/MediaBrowser.Controller/MediaEncoding/ChapterImageRefreshOptions.cs b/MediaBrowser.Controller/MediaEncoding/ChapterImageRefreshOptions.cs
deleted file mode 100644
index e11bd6cdf..000000000
--- a/MediaBrowser.Controller/MediaEncoding/ChapterImageRefreshOptions.cs
+++ /dev/null
@@ -1,17 +0,0 @@
-using MediaBrowser.Controller.Entities;
-using MediaBrowser.Model.Entities;
-using System.Collections.Generic;
-
-namespace MediaBrowser.Controller.MediaEncoding
-{
- public class ChapterImageRefreshOptions
- {
- public Video Video { get; set; }
-
- public List<ChapterInfo> Chapters { get; set; }
-
- public bool SaveChapters { get; set; }
-
- public bool ExtractImages { get; set; }
- }
-}
diff --git a/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs b/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs
index bd7bbb6fe..531711b55 100644
--- a/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs
+++ b/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs
@@ -4,13 +4,14 @@ using System.Globalization;
using System.IO;
using System.Linq;
using System.Threading;
-using MediaBrowser.Controller.Configuration;
+using MediaBrowser.Controller.Entities;
using MediaBrowser.Model.Configuration;
using MediaBrowser.Model.Dlna;
using MediaBrowser.Model.Dto;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.IO;
using MediaBrowser.Model.MediaInfo;
+using MediaBrowser.Model.Extensions;
namespace MediaBrowser.Controller.MediaEncoding
{
@@ -19,14 +20,12 @@ namespace MediaBrowser.Controller.MediaEncoding
private readonly CultureInfo _usCulture = new CultureInfo("en-US");
private readonly IMediaEncoder _mediaEncoder;
- private readonly IServerConfigurationManager _config;
private readonly IFileSystem _fileSystem;
private readonly ISubtitleEncoder _subtitleEncoder;
- public EncodingHelper(IMediaEncoder mediaEncoder, IServerConfigurationManager config, IFileSystem fileSystem, ISubtitleEncoder subtitleEncoder)
+ public EncodingHelper(IMediaEncoder mediaEncoder, IFileSystem fileSystem, ISubtitleEncoder subtitleEncoder)
{
_mediaEncoder = mediaEncoder;
- _config = config;
_fileSystem = fileSystem;
_subtitleEncoder = subtitleEncoder;
}
@@ -151,10 +150,13 @@ namespace MediaBrowser.Controller.MediaEncoding
public string GetInputFormat(string container)
{
- if (string.Equals(container, "mkv", StringComparison.OrdinalIgnoreCase))
+ if (string.IsNullOrWhiteSpace(container))
{
- return "matroska";
+ return null;
}
+
+ container = container.Replace("mkv", "matroska", StringComparison.OrdinalIgnoreCase);
+
if (string.Equals(container, "ts", StringComparison.OrdinalIgnoreCase))
{
return "mpegts";
@@ -209,6 +211,10 @@ namespace MediaBrowser.Controller.MediaEncoding
{
return null;
}
+ if (string.Equals(container, "rtp", StringComparison.OrdinalIgnoreCase))
+ {
+ return null;
+ }
// Seeing reported failures here, not sure yet if this is related to specfying input format
if (string.Equals(container, "m4v", StringComparison.OrdinalIgnoreCase))
@@ -772,6 +778,11 @@ namespace MediaBrowser.Controller.MediaEncoding
return false;
}
+ if (state.EnableMpDecimate)
+ {
+ return false;
+ }
+
if (videoStream.IsInterlaced)
{
if (request.DeInterlace)
@@ -923,19 +934,6 @@ namespace MediaBrowser.Controller.MediaEncoding
return false;
}
- // Video bitrate must fall within requested value
- if (request.AudioBitRate.HasValue)
- {
- if (!audioStream.BitRate.HasValue || audioStream.BitRate.Value <= 0)
- {
- return false;
- }
- if (audioStream.BitRate.Value > request.AudioBitRate.Value)
- {
- return false;
- }
- }
-
// Channels must fall within requested value
var channels = request.AudioChannels ?? request.MaxAudioChannels;
if (channels.HasValue)
@@ -963,6 +961,19 @@ namespace MediaBrowser.Controller.MediaEncoding
}
}
+ // Video bitrate must fall within requested value
+ if (request.AudioBitRate.HasValue)
+ {
+ if (!audioStream.BitRate.HasValue || audioStream.BitRate.Value <= 0)
+ {
+ return false;
+ }
+ if (audioStream.BitRate.Value > request.AudioBitRate.Value)
+ {
+ return false;
+ }
+ }
+
return request.EnableAutoStreamCopy;
}
@@ -1443,6 +1454,11 @@ namespace MediaBrowser.Controller.MediaEncoding
}
}
+ if (state.EnableMpDecimate)
+ {
+ filters.Add("mpdecimate,setpts=N/FRAME_RATE/TB");
+ }
+
if (filters.Count > 0)
{
output += string.Format(" -vf \"{0}\"", string.Join(",", filters.ToArray()));
@@ -1515,7 +1531,7 @@ namespace MediaBrowser.Controller.MediaEncoding
{
var inputModifier = string.Empty;
- var numInputFiles = state.PlayableStreamFileNames.Count > 0 ? state.PlayableStreamFileNames.Count : 1;
+ var numInputFiles = state.PlayableStreamFileNames.Length > 0 ? state.PlayableStreamFileNames.Length : 1;
var probeSizeArgument = GetProbeSizeArgument(numInputFiles);
string analyzeDurationArgument;
@@ -1625,26 +1641,6 @@ namespace MediaBrowser.Controller.MediaEncoding
inputModifier += " -f " + inputFormat;
}
}
-
- // Only do this for video files due to sometimes unpredictable codec names coming from BDInfo
- if (state.VideoType == VideoType.VideoFile && state.RunTimeTicks.HasValue && string.IsNullOrWhiteSpace(encodingOptions.HardwareAccelerationType))
- {
- foreach (var stream in state.MediaSource.MediaStreams)
- {
- if (!stream.IsExternal && stream.Type != MediaStreamType.Subtitle)
- {
- if (!string.IsNullOrWhiteSpace(stream.Codec) && stream.Index != -1)
- {
- var decoder = GetDecoderFromCodec(stream.Codec);
-
- if (!string.IsNullOrWhiteSpace(decoder))
- {
- inputModifier += " -codec:" + stream.Index.ToString(_usCulture) + " " + decoder;
- }
- }
- }
- }
- }
}
if (state.MediaSource.RequiresLooping)
@@ -1675,14 +1671,33 @@ namespace MediaBrowser.Controller.MediaEncoding
state.RunTimeTicks = mediaSource.RunTimeTicks;
state.RemoteHttpHeaders = mediaSource.RequiredHttpHeaders;
+ state.IsoType = mediaSource.IsoType;
+
if (mediaSource.VideoType.HasValue)
{
state.VideoType = mediaSource.VideoType.Value;
- }
-
- state.IsoType = mediaSource.IsoType;
- state.PlayableStreamFileNames = mediaSource.PlayableStreamFileNames.ToList();
+ if (mediaSource.VideoType.Value == VideoType.BluRay || mediaSource.VideoType.Value == VideoType.Dvd)
+ {
+ state.PlayableStreamFileNames = Video.QueryPlayableStreamFiles(state.MediaPath, mediaSource.VideoType.Value).Select(Path.GetFileName).ToArray();
+ }
+ else if (mediaSource.VideoType.Value == VideoType.Iso && state.IsoType == IsoType.BluRay)
+ {
+ state.PlayableStreamFileNames = Video.QueryPlayableStreamFiles(state.MediaPath, VideoType.BluRay).Select(Path.GetFileName).ToArray();
+ }
+ else if (mediaSource.VideoType.Value == VideoType.Iso && state.IsoType == IsoType.Dvd)
+ {
+ state.PlayableStreamFileNames = Video.QueryPlayableStreamFiles(state.MediaPath, VideoType.Dvd).Select(Path.GetFileName).ToArray();
+ }
+ else
+ {
+ state.PlayableStreamFileNames = new string[]{};
+ }
+ }
+ else
+ {
+ state.PlayableStreamFileNames = new string[] { };
+ }
if (mediaSource.Timestamp.HasValue)
{
@@ -1702,7 +1717,8 @@ namespace MediaBrowser.Controller.MediaEncoding
state.InputAudioSync = "1";
}
- if (string.Equals(mediaSource.Container, "wma", StringComparison.OrdinalIgnoreCase))
+ if (string.Equals(mediaSource.Container, "wma", StringComparison.OrdinalIgnoreCase) ||
+ string.Equals(mediaSource.Container, "asf", StringComparison.OrdinalIgnoreCase))
{
// Seeing some stuttering when transcoding wma to audio-only HLS
state.InputAudioSync = "1";
@@ -1776,50 +1792,54 @@ namespace MediaBrowser.Controller.MediaEncoding
return null;
}
+ return GetVideoDecoder(state.MediaSource.VideoType ?? VideoType.VideoFile, state.VideoStream, encodingOptions);
+ }
+
+ public string GetVideoDecoder(VideoType videoType, MediaStream videoStream, EncodingOptions encodingOptions)
+ {
// Only use alternative encoders for video files.
// When using concat with folder rips, if the mfx session fails to initialize, ffmpeg will be stuck retrying and will not exit gracefully
// Since transcoding of folder rips is expiremental anyway, it's not worth adding additional variables such as this.
- if (state.VideoType != VideoType.VideoFile)
+ if (videoType != VideoType.VideoFile)
{
return null;
}
- if (state.VideoStream != null &&
- !string.IsNullOrWhiteSpace(state.VideoStream.Codec) &&
- !string.IsNullOrWhiteSpace(encodingOptions.HardwareAccelerationType) &&
- encodingOptions.EnableHardwareDecoding)
+ if (videoStream != null &&
+ !string.IsNullOrWhiteSpace(videoStream.Codec) &&
+ !string.IsNullOrWhiteSpace(encodingOptions.HardwareAccelerationType))
{
if (string.Equals(encodingOptions.HardwareAccelerationType, "qsv", StringComparison.OrdinalIgnoreCase))
{
- switch (state.MediaSource.VideoStream.Codec.ToLower())
+ switch (videoStream.Codec.ToLower())
{
case "avc":
case "h264":
- if (_mediaEncoder.SupportsDecoder("h264_qsv"))
+ if (_mediaEncoder.SupportsDecoder("h264_qsv") && encodingOptions.HardwareDecodingCodecs.Contains("h264", StringComparer.OrdinalIgnoreCase))
{
// qsv decoder does not support 10-bit input
- if ((state.VideoStream.BitDepth ?? 8) > 8)
+ if ((videoStream.BitDepth ?? 8) > 8)
{
return null;
}
return "-c:v h264_qsv ";
}
break;
- //case "hevc":
- //case "h265":
- // if (_mediaEncoder.SupportsDecoder("hevc_qsv"))
- // {
- // return "-c:v hevc_qsv ";
- // }
- // break;
+ case "hevc":
+ case "h265":
+ if (_mediaEncoder.SupportsDecoder("hevc_qsv") && encodingOptions.HardwareDecodingCodecs.Contains("hevc", StringComparer.OrdinalIgnoreCase))
+ {
+ return "-c:v hevc_qsv ";
+ }
+ break;
case "mpeg2video":
- if (_mediaEncoder.SupportsDecoder("mpeg2_qsv"))
+ if (_mediaEncoder.SupportsDecoder("mpeg2_qsv") && encodingOptions.HardwareDecodingCodecs.Contains("mpeg2video", StringComparer.OrdinalIgnoreCase))
{
return "-c:v mpeg2_qsv ";
}
break;
case "vc1":
- if (_mediaEncoder.SupportsDecoder("vc1_qsv"))
+ if (_mediaEncoder.SupportsDecoder("vc1_qsv") && encodingOptions.HardwareDecodingCodecs.Contains("vc1", StringComparer.OrdinalIgnoreCase))
{
return "-c:v vc1_qsv ";
}
@@ -1829,22 +1849,40 @@ namespace MediaBrowser.Controller.MediaEncoding
else if (string.Equals(encodingOptions.HardwareAccelerationType, "nvenc", StringComparison.OrdinalIgnoreCase))
{
- switch (state.MediaSource.VideoStream.Codec.ToLower())
+ switch (videoStream.Codec.ToLower())
{
case "avc":
case "h264":
- if (_mediaEncoder.SupportsDecoder("h264_cuvid"))
+ if (_mediaEncoder.SupportsDecoder("h264_cuvid") && encodingOptions.HardwareDecodingCodecs.Contains("h264", StringComparer.OrdinalIgnoreCase))
{
return "-c:v h264_cuvid ";
}
break;
case "hevc":
case "h265":
- if (_mediaEncoder.SupportsDecoder("hevc_cuvid"))
+ if (_mediaEncoder.SupportsDecoder("hevc_cuvid") && encodingOptions.HardwareDecodingCodecs.Contains("hevc", StringComparer.OrdinalIgnoreCase))
{
return "-c:v hevc_cuvid ";
}
break;
+ case "mpeg2video":
+ if (_mediaEncoder.SupportsDecoder("mpeg2_cuvid") && encodingOptions.HardwareDecodingCodecs.Contains("mpeg2video", StringComparer.OrdinalIgnoreCase))
+ {
+ return "-c:v mpeg2_cuvid ";
+ }
+ break;
+ case "vc1":
+ if (_mediaEncoder.SupportsDecoder("vc1_cuvid") && encodingOptions.HardwareDecodingCodecs.Contains("vc1", StringComparer.OrdinalIgnoreCase))
+ {
+ return "-c:v vc1_cuvid ";
+ }
+ break;
+ case "mpeg4":
+ if (_mediaEncoder.SupportsDecoder("mpeg4_cuvid") && encodingOptions.HardwareDecodingCodecs.Contains("mpeg4", StringComparer.OrdinalIgnoreCase))
+ {
+ return "-c:v mpeg4_cuvid ";
+ }
+ break;
}
}
}
@@ -2109,6 +2147,7 @@ namespace MediaBrowser.Controller.MediaEncoding
var vn = string.Empty;
var hasArt = !string.IsNullOrWhiteSpace(state.AlbumCoverPath);
+ hasArt = false;
if (hasArt)
{
diff --git a/MediaBrowser.Controller/MediaEncoding/EncodingJobInfo.cs b/MediaBrowser.Controller/MediaEncoding/EncodingJobInfo.cs
index b552579a8..e76217fda 100644
--- a/MediaBrowser.Controller/MediaEncoding/EncodingJobInfo.cs
+++ b/MediaBrowser.Controller/MediaEncoding/EncodingJobInfo.cs
@@ -27,7 +27,7 @@ namespace MediaBrowser.Controller.MediaEncoding
public string MediaPath { get; set; }
public bool IsInputVideo { get; set; }
public IIsoMount IsoMount { get; set; }
- public List<string> PlayableStreamFileNames { get; set; }
+ public string[] PlayableStreamFileNames { get; set; }
public string OutputAudioCodec { get; set; }
public int? OutputVideoBitrate { get; set; }
public MediaStream SubtitleStream { get; set; }
@@ -42,8 +42,8 @@ namespace MediaBrowser.Controller.MediaEncoding
public bool ReadInputAtNativeFramerate { get; set; }
- private List<TranscodeReason> _transcodeReasons = null;
- public List<TranscodeReason> TranscodeReasons
+ private TranscodeReason[] _transcodeReasons = null;
+ public TranscodeReason[] TranscodeReasons
{
get
{
@@ -53,7 +53,7 @@ namespace MediaBrowser.Controller.MediaEncoding
.Split(',')
.Where(i => !string.IsNullOrWhiteSpace(i))
.Select(v => (TranscodeReason)Enum.Parse(typeof(TranscodeReason), v, true))
- .ToList();
+ .ToArray();
}
return _transcodeReasons;
@@ -127,6 +127,11 @@ namespace MediaBrowser.Controller.MediaEncoding
}
}
+ public bool EnableMpDecimate
+ {
+ get { return MediaSource.EnableMpDecimate; }
+ }
+
public string AlbumCoverPath { get; set; }
public string InputAudioSync { get; set; }
@@ -164,7 +169,7 @@ namespace MediaBrowser.Controller.MediaEncoding
_logger = logger;
TranscodingType = jobType;
RemoteHttpHeaders = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
- PlayableStreamFileNames = new List<string>();
+ PlayableStreamFileNames = new string[]{};
SupportedAudioCodecs = new List<string>();
SupportedVideoCodecs = new List<string>();
SupportedSubtitleCodecs = new List<string>();
diff --git a/MediaBrowser.Controller/MediaEncoding/IEncodingManager.cs b/MediaBrowser.Controller/MediaEncoding/IEncodingManager.cs
index 8683a6af4..81269fe3f 100644
--- a/MediaBrowser.Controller/MediaEncoding/IEncodingManager.cs
+++ b/MediaBrowser.Controller/MediaEncoding/IEncodingManager.cs
@@ -1,5 +1,8 @@
-using System.Threading;
+using System.Collections.Generic;
+using System.Threading;
using System.Threading.Tasks;
+using MediaBrowser.Controller.Entities;
+using MediaBrowser.Model.Entities;
namespace MediaBrowser.Controller.MediaEncoding
{
@@ -8,9 +11,6 @@ namespace MediaBrowser.Controller.MediaEncoding
/// <summary>
/// Refreshes the chapter images.
/// </summary>
- /// <param name="options">The options.</param>
- /// <param name="cancellationToken">The cancellation token.</param>
- /// <returns>Task{System.Boolean}.</returns>
- Task<bool> RefreshChapterImages(ChapterImageRefreshOptions options, CancellationToken cancellationToken);
+ Task<bool> RefreshChapterImages(Video video, List<ChapterInfo> chapters, bool extractImages, bool saveChapters, CancellationToken cancellationToken);
}
}
diff --git a/MediaBrowser.Controller/MediaEncoding/IMediaEncoder.cs b/MediaBrowser.Controller/MediaEncoding/IMediaEncoder.cs
index 10d7b9a7e..31cd96c9a 100644
--- a/MediaBrowser.Controller/MediaEncoding/IMediaEncoder.cs
+++ b/MediaBrowser.Controller/MediaEncoding/IMediaEncoder.cs
@@ -1,9 +1,11 @@
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.MediaInfo;
using System;
+using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using MediaBrowser.Model.Dlna;
+using MediaBrowser.Model.IO;
namespace MediaBrowser.Controller.MediaEncoding
{
@@ -39,29 +41,16 @@ namespace MediaBrowser.Controller.MediaEncoding
/// <summary>
/// Extracts the video image.
/// </summary>
- /// <param name="inputFiles">The input files.</param>
- /// <param name="protocol">The protocol.</param>
- /// <param name="threedFormat">The threed format.</param>
- /// <param name="offset">The offset.</param>
- /// <param name="cancellationToken">The cancellation token.</param>
- /// <returns>Task{Stream}.</returns>
- Task<string> ExtractVideoImage(string[] inputFiles, string container, MediaProtocol protocol, Video3DFormat? threedFormat, TimeSpan? offset, CancellationToken cancellationToken);
+ Task<string> ExtractVideoImage(string[] inputFiles, string container, MediaProtocol protocol, MediaStream videoStream, Video3DFormat? threedFormat, TimeSpan? offset, CancellationToken cancellationToken);
- Task<string> ExtractVideoImage(string[] inputFiles, string container, MediaProtocol protocol, int? imageStreamIndex, CancellationToken cancellationToken);
+ Task<string> ExtractVideoImage(string[] inputFiles, string container, MediaProtocol protocol, MediaStream imageStream, int? imageStreamIndex, CancellationToken cancellationToken);
/// <summary>
/// Extracts the video images on interval.
/// </summary>
- /// <param name="inputFiles">The input files.</param>
- /// <param name="protocol">The protocol.</param>
- /// <param name="threedFormat">The threed format.</param>
- /// <param name="interval">The interval.</param>
- /// <param name="targetDirectory">The target directory.</param>
- /// <param name="filenamePrefix">The filename prefix.</param>
- /// <param name="maxWidth">The maximum width.</param>
- /// <param name="cancellationToken">The cancellation token.</param>
- /// <returns>Task.</returns>
Task ExtractVideoImagesOnInterval(string[] inputFiles,
+ string container,
+ MediaStream videoStream,
MediaProtocol protocol,
Video3DFormat? threedFormat,
TimeSpan interval,
@@ -115,6 +104,8 @@ namespace MediaBrowser.Controller.MediaEncoding
IProgress<double> progress,
CancellationToken cancellationToken);
+ Task ConvertImage(string inputPath, string outputPath);
+
/// <summary>
/// Escapes the subtitle filter path.
/// </summary>
@@ -129,5 +120,8 @@ namespace MediaBrowser.Controller.MediaEncoding
void SetLogFilename(string name);
void ClearLogFilename();
+
+ string[] GetPlayableStreamFileNames(string path, VideoType videoType);
+ IEnumerable<string> GetPrimaryPlaylistVobFiles(string path, IIsoMount isoMount, uint? titleNumber);
}
}
diff --git a/MediaBrowser.Controller/MediaEncoding/JobLogger.cs b/MediaBrowser.Controller/MediaEncoding/JobLogger.cs
deleted file mode 100644
index 03e4f7771..000000000
--- a/MediaBrowser.Controller/MediaEncoding/JobLogger.cs
+++ /dev/null
@@ -1,149 +0,0 @@
-using MediaBrowser.Model.Extensions;
-using MediaBrowser.Model.Logging;
-using System;
-using System.Globalization;
-using System.IO;
-using System.Linq;
-using System.Text;
-
-namespace MediaBrowser.Controller.MediaEncoding
-{
- public class JobLogger
- {
- private readonly CultureInfo _usCulture = new CultureInfo("en-US");
- private readonly ILogger _logger;
-
- public JobLogger(ILogger logger)
- {
- _logger = logger;
- }
-
- public async void StartStreamingLog(EncodingJobInfo state, Stream source, Stream target)
- {
- try
- {
- using (var reader = new StreamReader(source))
- {
- while (!reader.EndOfStream)
- {
- var line = await reader.ReadLineAsync().ConfigureAwait(false);
-
- ParseLogLine(line, state);
-
- var bytes = Encoding.UTF8.GetBytes(Environment.NewLine + line);
-
- await target.WriteAsync(bytes, 0, bytes.Length).ConfigureAwait(false);
- await target.FlushAsync().ConfigureAwait(false);
- }
- }
- }
- catch (ObjectDisposedException)
- {
- // Don't spam the log. This doesn't seem to throw in windows, but sometimes under linux
- }
- catch (Exception ex)
- {
- _logger.ErrorException("Error reading ffmpeg log", ex);
- }
- }
-
- private void ParseLogLine(string line, EncodingJobInfo state)
- {
- float? framerate = null;
- double? percent = null;
- TimeSpan? transcodingPosition = null;
- long? bytesTranscoded = null;
- int? bitRate = null;
-
- var parts = line.Split(' ');
-
- var totalMs = state.RunTimeTicks.HasValue
- ? TimeSpan.FromTicks(state.RunTimeTicks.Value).TotalMilliseconds
- : 0;
-
- var startMs = state.BaseRequest.StartTimeTicks.HasValue
- ? TimeSpan.FromTicks(state.BaseRequest.StartTimeTicks.Value).TotalMilliseconds
- : 0;
-
- for (var i = 0; i < parts.Length; i++)
- {
- var part = parts[i];
-
- if (string.Equals(part, "fps=", StringComparison.OrdinalIgnoreCase) &&
- (i + 1 < parts.Length))
- {
- var rate = parts[i + 1];
- float val;
-
- if (float.TryParse(rate, NumberStyles.Any, _usCulture, out val))
- {
- framerate = val;
- }
- }
- else if (state.RunTimeTicks.HasValue &&
- part.StartsWith("time=", StringComparison.OrdinalIgnoreCase))
- {
- var time = part.Split(new[] { '=' }, 2).Last();
- TimeSpan val;
-
- if (TimeSpan.TryParse(time, _usCulture, out val))
- {
- var currentMs = startMs + val.TotalMilliseconds;
-
- var percentVal = currentMs / totalMs;
- percent = 100 * percentVal;
-
- transcodingPosition = val;
- }
- }
- else if (part.StartsWith("size=", StringComparison.OrdinalIgnoreCase))
- {
- var size = part.Split(new[] { '=' }, 2).Last();
-
- int? scale = null;
- if (size.IndexOf("kb", StringComparison.OrdinalIgnoreCase) != -1)
- {
- scale = 1024;
- size = size.Replace("kb", string.Empty, StringComparison.OrdinalIgnoreCase);
- }
-
- if (scale.HasValue)
- {
- long val;
-
- if (long.TryParse(size, NumberStyles.Any, _usCulture, out val))
- {
- bytesTranscoded = val * scale.Value;
- }
- }
- }
- else if (part.StartsWith("bitrate=", StringComparison.OrdinalIgnoreCase))
- {
- var rate = part.Split(new[] { '=' }, 2).Last();
-
- int? scale = null;
- if (rate.IndexOf("kbits/s", StringComparison.OrdinalIgnoreCase) != -1)
- {
- scale = 1024;
- rate = rate.Replace("kbits/s", string.Empty, StringComparison.OrdinalIgnoreCase);
- }
-
- if (scale.HasValue)
- {
- float val;
-
- if (float.TryParse(rate, NumberStyles.Any, _usCulture, out val))
- {
- bitRate = (int)Math.Ceiling(val * scale.Value);
- }
- }
- }
- }
-
- if (framerate.HasValue || percent.HasValue)
- {
- state.ReportTranscodingProgress(transcodingPosition, framerate, percent, bytesTranscoded, bitRate);
- }
- }
- }
-}
diff --git a/MediaBrowser.Controller/MediaEncoding/MediaEncoderHelpers.cs b/MediaBrowser.Controller/MediaEncoding/MediaEncoderHelpers.cs
index d5c85197f..70e4db84f 100644
--- a/MediaBrowser.Controller/MediaEncoding/MediaEncoderHelpers.cs
+++ b/MediaBrowser.Controller/MediaEncoding/MediaEncoderHelpers.cs
@@ -1,12 +1,9 @@
using MediaBrowser.Model.IO;
using MediaBrowser.Model.MediaInfo;
using System;
-using System.Collections.Generic;
using System.IO;
using System.Linq;
-using MediaBrowser.Controller.IO;
-
namespace MediaBrowser.Controller.MediaEncoding
{
/// <summary>
@@ -23,34 +20,34 @@ namespace MediaBrowser.Controller.MediaEncoding
/// <param name="isoMount">The iso mount.</param>
/// <param name="playableStreamFileNames">The playable stream file names.</param>
/// <returns>System.String[][].</returns>
- public static string[] GetInputArgument(IFileSystem fileSystem, string videoPath, MediaProtocol protocol, IIsoMount isoMount, List<string> playableStreamFileNames)
+ public static string[] GetInputArgument(IFileSystem fileSystem, string videoPath, MediaProtocol protocol, IIsoMount isoMount, string[] playableStreamFileNames)
{
- if (playableStreamFileNames.Count > 0)
+ if (playableStreamFileNames.Length > 0)
{
if (isoMount == null)
{
- return GetPlayableStreamFiles(fileSystem, videoPath, playableStreamFileNames).ToArray();
+ return GetPlayableStreamFiles(fileSystem, videoPath, playableStreamFileNames);
}
- return GetPlayableStreamFiles(fileSystem, isoMount.MountedPath, playableStreamFileNames).ToArray();
+ return GetPlayableStreamFiles(fileSystem, isoMount.MountedPath, playableStreamFileNames);
}
return new[] {videoPath};
}
- private static List<string> GetPlayableStreamFiles(IFileSystem fileSystem, string rootPath, List<string> filenames)
+ private static string[] GetPlayableStreamFiles(IFileSystem fileSystem, string rootPath, string[] filenames)
{
- if (filenames.Count == 0)
+ if (filenames.Length == 0)
{
- return new List<string>();
+ return new string[]{};
}
var allFiles = fileSystem
.GetFilePaths(rootPath, true)
- .ToList();
+ .ToArray();
return filenames.Select(name => allFiles.FirstOrDefault(f => string.Equals(Path.GetFileName(f), name, StringComparison.OrdinalIgnoreCase)))
.Where(f => !string.IsNullOrEmpty(f))
- .ToList();
+ .ToArray();
}
}
}
diff --git a/MediaBrowser.Controller/MediaEncoding/MediaInfoRequest.cs b/MediaBrowser.Controller/MediaEncoding/MediaInfoRequest.cs
index 0785ee29f..929f4e649 100644
--- a/MediaBrowser.Controller/MediaEncoding/MediaInfoRequest.cs
+++ b/MediaBrowser.Controller/MediaEncoding/MediaInfoRequest.cs
@@ -14,12 +14,12 @@ namespace MediaBrowser.Controller.MediaEncoding
public DlnaProfileType MediaType { get; set; }
public IIsoMount MountedIso { get; set; }
public VideoType VideoType { get; set; }
- public List<string> PlayableStreamFileNames { get; set; }
+ public string[] PlayableStreamFileNames { get; set; }
public int AnalyzeDurationMs { get; set; }
public MediaInfoRequest()
{
- PlayableStreamFileNames = new List<string>();
+ PlayableStreamFileNames = new string[] { };
}
}
}