mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-07-09 03:04:24 -04:00
correct dlna param positions
This commit is contained in:
parent
87c8c429e7
commit
b95f8f5f5c
@ -967,8 +967,6 @@ namespace MediaBrowser.Api.Playback
|
|||||||
|
|
||||||
private async void StreamToStandardInput(Process process, StreamState state)
|
private async void StreamToStandardInput(Process process, StreamState state)
|
||||||
{
|
{
|
||||||
state.StandardInputCancellationTokenSource = new CancellationTokenSource();
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await StreamToStandardInputInternal(process, state).ConfigureAwait(false);
|
await StreamToStandardInputInternal(process, state).ConfigureAwait(false);
|
||||||
@ -1263,31 +1261,38 @@ namespace MediaBrowser.Api.Playback
|
|||||||
{
|
{
|
||||||
if (videoRequest != null)
|
if (videoRequest != null)
|
||||||
{
|
{
|
||||||
videoRequest.MaxWidth = int.Parse(val, UsCulture);
|
videoRequest.MaxFramerate = double.Parse(val, UsCulture);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (i == 12)
|
else if (i == 12)
|
||||||
{
|
{
|
||||||
if (videoRequest != null)
|
if (videoRequest != null)
|
||||||
{
|
{
|
||||||
videoRequest.MaxHeight = int.Parse(val, UsCulture);
|
videoRequest.MaxWidth = int.Parse(val, UsCulture);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (i == 13)
|
else if (i == 13)
|
||||||
{
|
{
|
||||||
if (videoRequest != null)
|
if (videoRequest != null)
|
||||||
{
|
{
|
||||||
videoRequest.Framerate = int.Parse(val, UsCulture);
|
videoRequest.MaxHeight = int.Parse(val, UsCulture);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (i == 14)
|
else if (i == 14)
|
||||||
{
|
{
|
||||||
if (videoRequest != null)
|
if (videoRequest != null)
|
||||||
{
|
{
|
||||||
request.StartTimeTicks = long.Parse(val, UsCulture);
|
videoRequest.Framerate = int.Parse(val, UsCulture);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (i == 15)
|
else if (i == 15)
|
||||||
|
{
|
||||||
|
if (videoRequest != null)
|
||||||
|
{
|
||||||
|
request.StartTimeTicks = long.Parse(val, UsCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (i == 16)
|
||||||
{
|
{
|
||||||
if (videoRequest != null)
|
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.Controller.MediaEncoding;
|
||||||
using MediaBrowser.Model.Logging;
|
using MediaBrowser.Model.Logging;
|
||||||
using System;
|
using System;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
@ -15,16 +18,18 @@ namespace MediaBrowser.MediaEncoding.Encoder
|
|||||||
private readonly string _ffmpegPath;
|
private readonly string _ffmpegPath;
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
private readonly IFileSystem _fileSystem;
|
private readonly IFileSystem _fileSystem;
|
||||||
|
private readonly IApplicationPaths _appPaths;
|
||||||
|
|
||||||
private readonly CultureInfo _usCulture = new CultureInfo("en-US");
|
private readonly CultureInfo _usCulture = new CultureInfo("en-US");
|
||||||
|
|
||||||
private static readonly SemaphoreSlim ResourcePool = new SemaphoreSlim(10, 10);
|
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;
|
_ffmpegPath = ffmpegPath;
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_fileSystem = fileSystem;
|
_fileSystem = fileSystem;
|
||||||
|
_appPaths = appPaths;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<Stream> EncodeImage(ImageEncodingOptions options, CancellationToken cancellationToken)
|
public async Task<Stream> EncodeImage(ImageEncodingOptions options, CancellationToken cancellationToken)
|
||||||
@ -47,6 +52,15 @@ namespace MediaBrowser.MediaEncoding.Encoder
|
|||||||
{
|
{
|
||||||
ValidateInput(options);
|
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
|
var process = new Process
|
||||||
{
|
{
|
||||||
StartInfo = new ProcessStartInfo
|
StartInfo = new ProcessStartInfo
|
||||||
@ -54,12 +68,12 @@ namespace MediaBrowser.MediaEncoding.Encoder
|
|||||||
CreateNoWindow = true,
|
CreateNoWindow = true,
|
||||||
UseShellExecute = false,
|
UseShellExecute = false,
|
||||||
FileName = _ffmpegPath,
|
FileName = _ffmpegPath,
|
||||||
Arguments = GetArguments(options),
|
Arguments = GetArguments(options, filename),
|
||||||
WindowStyle = ProcessWindowStyle.Hidden,
|
WindowStyle = ProcessWindowStyle.Hidden,
|
||||||
ErrorDialog = false,
|
ErrorDialog = false,
|
||||||
RedirectStandardOutput = true,
|
RedirectStandardOutput = true,
|
||||||
RedirectStandardError = true,
|
RedirectStandardError = true,
|
||||||
WorkingDirectory = Path.GetDirectoryName(options.InputPath)
|
WorkingDirectory = Path.GetDirectoryName(inputPath)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -114,7 +128,18 @@ namespace MediaBrowser.MediaEncoding.Encoder
|
|||||||
return memoryStream;
|
return memoryStream;
|
||||||
}
|
}
|
||||||
|
|
||||||
private string GetArguments(ImageEncodingOptions options)
|
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, string inputFilename)
|
||||||
{
|
{
|
||||||
var vfScale = GetFilterGraph(options);
|
var vfScale = GetFilterGraph(options);
|
||||||
var outputFormat = GetOutputFormat(options.Format);
|
var outputFormat = GetOutputFormat(options.Format);
|
||||||
@ -127,7 +152,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
|
|||||||
qualityValue.ToString(_usCulture),
|
qualityValue.ToString(_usCulture),
|
||||||
vfScale,
|
vfScale,
|
||||||
outputFormat,
|
outputFormat,
|
||||||
Path.GetFileName(options.InputPath));
|
inputFilename);
|
||||||
}
|
}
|
||||||
|
|
||||||
private string GetFilterGraph(ImageEncodingOptions options)
|
private string GetFilterGraph(ImageEncodingOptions options)
|
||||||
@ -163,10 +188,9 @@ namespace MediaBrowser.MediaEncoding.Encoder
|
|||||||
|
|
||||||
var scaleMethod = "lanczos";
|
var scaleMethod = "lanczos";
|
||||||
|
|
||||||
return string.Format("-vf scale=\"{0}:{1}\" -sws_flags {2}",
|
return string.Format("-vf scale=\"{0}:{1}\"",
|
||||||
widthScale,
|
widthScale,
|
||||||
heightScale,
|
heightScale);
|
||||||
scaleMethod);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private string GetOutputFormat(string format)
|
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)
|
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>
|
/// <summary>
|
||||||
|
@ -25,6 +25,7 @@ namespace MediaBrowser.Model.Drawing
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// The PNG
|
/// The PNG
|
||||||
/// </summary>
|
/// </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>
|
/// <summary>
|
||||||
/// Encodes an URL.
|
/// Encodes an URL.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -218,36 +218,36 @@ namespace MediaBrowser.Server.Implementations.Drawing
|
|||||||
{
|
{
|
||||||
var hasPostProcessing = !string.IsNullOrEmpty(options.BackgroundColor) || options.UnplayedCount.HasValue || options.AddPlayedIndicator || options.PercentPlayed.HasValue;
|
var hasPostProcessing = !string.IsNullOrEmpty(options.BackgroundColor) || options.UnplayedCount.HasValue || options.AddPlayedIndicator || options.PercentPlayed.HasValue;
|
||||||
|
|
||||||
if (!hasPostProcessing)
|
//if (!hasPostProcessing)
|
||||||
{
|
//{
|
||||||
using (var outputStream = await _mediaEncoder.EncodeImage(new ImageEncodingOptions
|
// using (var outputStream = await _mediaEncoder.EncodeImage(new ImageEncodingOptions
|
||||||
{
|
// {
|
||||||
InputPath = originalImagePath,
|
// InputPath = originalImagePath,
|
||||||
MaxHeight = options.MaxHeight,
|
// MaxHeight = options.MaxHeight,
|
||||||
MaxWidth = options.MaxWidth,
|
// MaxWidth = options.MaxWidth,
|
||||||
Height = options.Height,
|
// Height = options.Height,
|
||||||
Width = options.Width,
|
// Width = options.Width,
|
||||||
Quality = options.Quality,
|
// Quality = options.Quality,
|
||||||
Format = options.OutputFormat == ImageOutputFormat.Original ? Path.GetExtension(originalImagePath).TrimStart('.') : options.OutputFormat.ToString().ToLower()
|
// Format = options.OutputFormat == ImageOutputFormat.Original ? Path.GetExtension(originalImagePath).TrimStart('.') : options.OutputFormat.ToString().ToLower()
|
||||||
|
|
||||||
}, CancellationToken.None).ConfigureAwait(false))
|
// }, CancellationToken.None).ConfigureAwait(false))
|
||||||
{
|
// {
|
||||||
using (var outputMemoryStream = new MemoryStream())
|
// using (var outputMemoryStream = new MemoryStream())
|
||||||
{
|
// {
|
||||||
// Save to the memory stream
|
// // Save to the memory stream
|
||||||
await outputStream.CopyToAsync(outputMemoryStream).ConfigureAwait(false);
|
// 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
|
// // kick off a task to cache the result
|
||||||
await CacheResizedImage(cacheFilePath, bytes).ConfigureAwait(false);
|
// await CacheResizedImage(cacheFilePath, bytes).ConfigureAwait(false);
|
||||||
}
|
// }
|
||||||
|
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|
||||||
using (var fileStream = _fileSystem.GetFileStream(originalImagePath, FileMode.Open, FileAccess.Read, FileShare.Read, true))
|
using (var fileStream = _fileSystem.GetFileStream(originalImagePath, FileMode.Open, FileAccess.Read, FileShare.Read, true))
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user