correct dlna param positions
This commit is contained in:
parent
1664de62c0
commit
ec49a65752
|
@ -967,8 +967,6 @@ namespace MediaBrowser.Api.Playback
|
|||
|
||||
private async void StreamToStandardInput(Process process, StreamState state)
|
||||
{
|
||||
state.StandardInputCancellationTokenSource = new CancellationTokenSource();
|
||||
|
||||
try
|
||||
{
|
||||
await StreamToStandardInputInternal(process, state).ConfigureAwait(false);
|
||||
|
@ -1263,31 +1261,38 @@ namespace MediaBrowser.Api.Playback
|
|||
{
|
||||
if (videoRequest != null)
|
||||
{
|
||||
videoRequest.MaxWidth = int.Parse(val, UsCulture);
|
||||
videoRequest.MaxFramerate = double.Parse(val, UsCulture);
|
||||
}
|
||||
}
|
||||
else if (i == 12)
|
||||
{
|
||||
if (videoRequest != null)
|
||||
{
|
||||
videoRequest.MaxHeight = int.Parse(val, UsCulture);
|
||||
videoRequest.MaxWidth = int.Parse(val, UsCulture);
|
||||
}
|
||||
}
|
||||
else if (i == 13)
|
||||
{
|
||||
if (videoRequest != null)
|
||||
{
|
||||
videoRequest.Framerate = int.Parse(val, UsCulture);
|
||||
videoRequest.MaxHeight = int.Parse(val, UsCulture);
|
||||
}
|
||||
}
|
||||
else if (i == 14)
|
||||
{
|
||||
if (videoRequest != null)
|
||||
{
|
||||
request.StartTimeTicks = long.Parse(val, UsCulture);
|
||||
videoRequest.Framerate = int.Parse(val, UsCulture);
|
||||
}
|
||||
}
|
||||
else if (i == 15)
|
||||
{
|
||||
if (videoRequest != null)
|
||||
{
|
||||
request.StartTimeTicks = long.Parse(val, UsCulture);
|
||||
}
|
||||
}
|
||||
else if (i == 16)
|
||||
{
|
||||
if (videoRequest != null)
|
||||
{
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
using MediaBrowser.Common.IO;
|
||||
using MediaBrowser.Common.Configuration;
|
||||
using MediaBrowser.Common.IO;
|
||||
using MediaBrowser.Controller.MediaEncoding;
|
||||
using MediaBrowser.Model.Logging;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
@ -15,16 +18,18 @@ namespace MediaBrowser.MediaEncoding.Encoder
|
|||
private readonly string _ffmpegPath;
|
||||
private readonly ILogger _logger;
|
||||
private readonly IFileSystem _fileSystem;
|
||||
private readonly IApplicationPaths _appPaths;
|
||||
|
||||
private readonly CultureInfo _usCulture = new CultureInfo("en-US");
|
||||
|
||||
private static readonly SemaphoreSlim ResourcePool = new SemaphoreSlim(10, 10);
|
||||
|
||||
public ImageEncoder(string ffmpegPath, ILogger logger, IFileSystem fileSystem)
|
||||
public ImageEncoder(string ffmpegPath, ILogger logger, IFileSystem fileSystem, IApplicationPaths appPaths)
|
||||
{
|
||||
_ffmpegPath = ffmpegPath;
|
||||
_logger = logger;
|
||||
_fileSystem = fileSystem;
|
||||
_appPaths = appPaths;
|
||||
}
|
||||
|
||||
public async Task<Stream> EncodeImage(ImageEncodingOptions options, CancellationToken cancellationToken)
|
||||
|
@ -47,6 +52,15 @@ namespace MediaBrowser.MediaEncoding.Encoder
|
|||
{
|
||||
ValidateInput(options);
|
||||
|
||||
var inputPath = options.InputPath;
|
||||
var filename = Path.GetFileName(inputPath);
|
||||
|
||||
if (HasDiacritics(filename))
|
||||
{
|
||||
inputPath = GetTempFile(inputPath);
|
||||
filename = Path.GetFileName(inputPath);
|
||||
}
|
||||
|
||||
var process = new Process
|
||||
{
|
||||
StartInfo = new ProcessStartInfo
|
||||
|
@ -54,12 +68,12 @@ namespace MediaBrowser.MediaEncoding.Encoder
|
|||
CreateNoWindow = true,
|
||||
UseShellExecute = false,
|
||||
FileName = _ffmpegPath,
|
||||
Arguments = GetArguments(options),
|
||||
Arguments = GetArguments(options, filename),
|
||||
WindowStyle = ProcessWindowStyle.Hidden,
|
||||
ErrorDialog = false,
|
||||
RedirectStandardOutput = true,
|
||||
RedirectStandardError = true,
|
||||
WorkingDirectory = Path.GetDirectoryName(options.InputPath)
|
||||
WorkingDirectory = Path.GetDirectoryName(inputPath)
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -113,8 +127,19 @@ namespace MediaBrowser.MediaEncoding.Encoder
|
|||
memoryStream.Position = 0;
|
||||
return memoryStream;
|
||||
}
|
||||
|
||||
private string GetTempFile(string path)
|
||||
{
|
||||
var extension = Path.GetExtension(path) ?? string.Empty;
|
||||
|
||||
var tempPath = Path.Combine(_appPaths.TempDirectory, Guid.NewGuid().ToString("N") + extension);
|
||||
|
||||
File.Copy(path, tempPath);
|
||||
|
||||
return tempPath;
|
||||
}
|
||||
|
||||
private string GetArguments(ImageEncodingOptions options)
|
||||
private string GetArguments(ImageEncodingOptions options, string inputFilename)
|
||||
{
|
||||
var vfScale = GetFilterGraph(options);
|
||||
var outputFormat = GetOutputFormat(options.Format);
|
||||
|
@ -127,7 +152,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
|
|||
qualityValue.ToString(_usCulture),
|
||||
vfScale,
|
||||
outputFormat,
|
||||
Path.GetFileName(options.InputPath));
|
||||
inputFilename);
|
||||
}
|
||||
|
||||
private string GetFilterGraph(ImageEncodingOptions options)
|
||||
|
@ -163,10 +188,9 @@ namespace MediaBrowser.MediaEncoding.Encoder
|
|||
|
||||
var scaleMethod = "lanczos";
|
||||
|
||||
return string.Format("-vf scale=\"{0}:{1}\" -sws_flags {2}",
|
||||
return string.Format("-vf scale=\"{0}:{1}\"",
|
||||
widthScale,
|
||||
heightScale,
|
||||
scaleMethod);
|
||||
heightScale);
|
||||
}
|
||||
|
||||
private string GetOutputFormat(string format)
|
||||
|
@ -183,5 +207,29 @@ namespace MediaBrowser.MediaEncoding.Encoder
|
|||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether the specified text has diacritics.
|
||||
/// </summary>
|
||||
/// <param name="text">The text.</param>
|
||||
/// <returns><c>true</c> if the specified text has diacritics; otherwise, <c>false</c>.</returns>
|
||||
private bool HasDiacritics(string text)
|
||||
{
|
||||
return !String.Equals(text, RemoveDiacritics(text), StringComparison.Ordinal);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes the diacritics.
|
||||
/// </summary>
|
||||
/// <param name="text">The text.</param>
|
||||
/// <returns>System.String.</returns>
|
||||
private string RemoveDiacritics(string text)
|
||||
{
|
||||
return String.Concat(
|
||||
text.Normalize(NormalizationForm.FormD)
|
||||
.Where(ch => CharUnicodeInfo.GetUnicodeCategory(ch) !=
|
||||
UnicodeCategory.NonSpacingMark)
|
||||
).Normalize(NormalizationForm.FormC);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -911,7 +911,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
|
|||
|
||||
public Task<Stream> EncodeImage(ImageEncodingOptions options, CancellationToken cancellationToken)
|
||||
{
|
||||
return new ImageEncoder(FFMpegPath, _logger, _fileSystem).EncodeImage(options, cancellationToken);
|
||||
return new ImageEncoder(FFMpegPath, _logger, _fileSystem, _appPaths).EncodeImage(options, cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -25,6 +25,7 @@ namespace MediaBrowser.Model.Drawing
|
|||
/// <summary>
|
||||
/// The PNG
|
||||
/// </summary>
|
||||
Png
|
||||
Png,
|
||||
Webp
|
||||
}
|
||||
}
|
||||
|
|
|
@ -130,30 +130,6 @@ namespace MediaBrowser.Providers.Music
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether the specified text has diacritics.
|
||||
/// </summary>
|
||||
/// <param name="text">The text.</param>
|
||||
/// <returns><c>true</c> if the specified text has diacritics; otherwise, <c>false</c>.</returns>
|
||||
private bool HasDiacritics(string text)
|
||||
{
|
||||
return !String.Equals(text, RemoveDiacritics(text), StringComparison.Ordinal);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes the diacritics.
|
||||
/// </summary>
|
||||
/// <param name="text">The text.</param>
|
||||
/// <returns>System.String.</returns>
|
||||
private string RemoveDiacritics(string text)
|
||||
{
|
||||
return String.Concat(
|
||||
text.Normalize(NormalizationForm.FormD)
|
||||
.Where(ch => CharUnicodeInfo.GetUnicodeCategory(ch) !=
|
||||
UnicodeCategory.NonSpacingMark)
|
||||
).Normalize(NormalizationForm.FormC);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Encodes an URL.
|
||||
/// </summary>
|
||||
|
|
|
@ -218,36 +218,36 @@ namespace MediaBrowser.Server.Implementations.Drawing
|
|||
{
|
||||
var hasPostProcessing = !string.IsNullOrEmpty(options.BackgroundColor) || options.UnplayedCount.HasValue || options.AddPlayedIndicator || options.PercentPlayed.HasValue;
|
||||
|
||||
if (!hasPostProcessing)
|
||||
{
|
||||
using (var outputStream = await _mediaEncoder.EncodeImage(new ImageEncodingOptions
|
||||
{
|
||||
InputPath = originalImagePath,
|
||||
MaxHeight = options.MaxHeight,
|
||||
MaxWidth = options.MaxWidth,
|
||||
Height = options.Height,
|
||||
Width = options.Width,
|
||||
Quality = options.Quality,
|
||||
Format = options.OutputFormat == ImageOutputFormat.Original ? Path.GetExtension(originalImagePath).TrimStart('.') : options.OutputFormat.ToString().ToLower()
|
||||
//if (!hasPostProcessing)
|
||||
//{
|
||||
// using (var outputStream = await _mediaEncoder.EncodeImage(new ImageEncodingOptions
|
||||
// {
|
||||
// InputPath = originalImagePath,
|
||||
// MaxHeight = options.MaxHeight,
|
||||
// MaxWidth = options.MaxWidth,
|
||||
// Height = options.Height,
|
||||
// Width = options.Width,
|
||||
// Quality = options.Quality,
|
||||
// Format = options.OutputFormat == ImageOutputFormat.Original ? Path.GetExtension(originalImagePath).TrimStart('.') : options.OutputFormat.ToString().ToLower()
|
||||
|
||||
}, CancellationToken.None).ConfigureAwait(false))
|
||||
{
|
||||
using (var outputMemoryStream = new MemoryStream())
|
||||
{
|
||||
// Save to the memory stream
|
||||
await outputStream.CopyToAsync(outputMemoryStream).ConfigureAwait(false);
|
||||
// }, CancellationToken.None).ConfigureAwait(false))
|
||||
// {
|
||||
// using (var outputMemoryStream = new MemoryStream())
|
||||
// {
|
||||
// // Save to the memory stream
|
||||
// await outputStream.CopyToAsync(outputMemoryStream).ConfigureAwait(false);
|
||||
|
||||
var bytes = outputMemoryStream.ToArray();
|
||||
// var bytes = outputMemoryStream.ToArray();
|
||||
|
||||
await toStream.WriteAsync(bytes, 0, bytes.Length).ConfigureAwait(false);
|
||||
// await toStream.WriteAsync(bytes, 0, bytes.Length).ConfigureAwait(false);
|
||||
|
||||
// kick off a task to cache the result
|
||||
await CacheResizedImage(cacheFilePath, bytes).ConfigureAwait(false);
|
||||
}
|
||||
// // kick off a task to cache the result
|
||||
// await CacheResizedImage(cacheFilePath, bytes).ConfigureAwait(false);
|
||||
// }
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
// return;
|
||||
// }
|
||||
//}
|
||||
|
||||
using (var fileStream = _fileSystem.GetFileStream(originalImagePath, FileMode.Open, FileAccess.Read, FileShare.Read, true))
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue
Block a user