changed ChapterImageResolution in model to enum type;

added 144p to the ImageResolution enum;
updated chapters limit comment inside FFProbeVideoInfo.cs;
pull/8137/head
Negulici-R. Barnabas 2 years ago
parent b7aa5ed862
commit 7db1813cc8

@ -609,30 +609,13 @@ namespace MediaBrowser.MediaEncoding.Encoder
return await ExtractImageInternal(inputArgument, container, videoStream, imageStreamIndex, threedFormat, offset, false, targetFormat, cancellationToken).ConfigureAwait(false); return await ExtractImageInternal(inputArgument, container, videoStream, imageStreamIndex, threedFormat, offset, false, targetFormat, cancellationToken).ConfigureAwait(false);
} }
private async Task<string> ExtractImageInternal(string inputPath, string container, MediaStream videoStream, int? imageStreamIndex, Video3DFormat? threedFormat, TimeSpan? offset, bool useIFrame, ImageFormat? targetFormat, CancellationToken cancellationToken) private string GetImageResolutionParameter()
{
if (string.IsNullOrEmpty(inputPath))
{ {
throw new ArgumentNullException(nameof(inputPath)); string imageResolutionParameter;
}
var outputExtension = targetFormat switch
{
ImageFormat.Bmp => ".bmp",
ImageFormat.Gif => ".gif",
ImageFormat.Jpg => ".jpg",
ImageFormat.Png => ".png",
ImageFormat.Webp => ".webp",
_ => ".jpg"
};
bool enumConversionStatus = Enum.TryParse(_serverConfig.Configuration.ChapterImageResolution, out ImageResolution resolution);
var outputResolution = string.Empty;
if (enumConversionStatus) imageResolutionParameter = _serverConfig.Configuration.ChapterImageResolution switch
{
outputResolution = resolution switch
{ {
ImageResolution.P144 => "256x144",
ImageResolution.P240 => "426x240", ImageResolution.P240 => "426x240",
ImageResolution.P360 => "640x360", ImageResolution.P360 => "640x360",
ImageResolution.P480 => "854x480", ImageResolution.P480 => "854x480",
@ -643,12 +626,32 @@ namespace MediaBrowser.MediaEncoding.Encoder
_ => string.Empty _ => string.Empty
}; };
if (!string.IsNullOrEmpty(outputResolution)) if (!string.IsNullOrEmpty(imageResolutionParameter))
{ {
outputResolution = " -s " + outputResolution; imageResolutionParameter = " -s " + imageResolutionParameter;
}
return imageResolutionParameter;
} }
private async Task<string> ExtractImageInternal(string inputPath, string container, MediaStream videoStream, int? imageStreamIndex, Video3DFormat? threedFormat, TimeSpan? offset, bool useIFrame, ImageFormat? targetFormat, CancellationToken cancellationToken)
{
if (string.IsNullOrEmpty(inputPath))
{
throw new ArgumentNullException(nameof(inputPath));
} }
var outputExtension = targetFormat switch
{
ImageFormat.Bmp => ".bmp",
ImageFormat.Gif => ".gif",
ImageFormat.Jpg => ".jpg",
ImageFormat.Png => ".png",
ImageFormat.Webp => ".webp",
_ => ".jpg"
};
var tempExtractPath = Path.Combine(_configurationManager.ApplicationPaths.TempDirectory, Guid.NewGuid() + outputExtension); var tempExtractPath = Path.Combine(_configurationManager.ApplicationPaths.TempDirectory, Guid.NewGuid() + outputExtension);
Directory.CreateDirectory(Path.GetDirectoryName(tempExtractPath)); Directory.CreateDirectory(Path.GetDirectoryName(tempExtractPath));
@ -702,7 +705,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
var vf = string.Join(',', filters); var vf = string.Join(',', filters);
var mapArg = imageStreamIndex.HasValue ? (" -map 0:" + imageStreamIndex.Value.ToString(CultureInfo.InvariantCulture)) : string.Empty; var mapArg = imageStreamIndex.HasValue ? (" -map 0:" + imageStreamIndex.Value.ToString(CultureInfo.InvariantCulture)) : string.Empty;
var args = string.Format(CultureInfo.InvariantCulture, "-i {0}{3} -threads {4} -v quiet -vframes 1 -vf {2}{5} -f image2 \"{1}\"", inputPath, tempExtractPath, vf, mapArg, _threads, outputResolution); var args = string.Format(CultureInfo.InvariantCulture, "-i {0}{3} -threads {4} -v quiet -vframes 1 -vf {2}{5} -f image2 \"{1}\"", inputPath, tempExtractPath, vf, mapArg, _threads, GetImageResolutionParameter());
if (offset.HasValue) if (offset.HasValue)
{ {

@ -3,6 +3,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using MediaBrowser.Model.Drawing;
using MediaBrowser.Model.Dto; using MediaBrowser.Model.Dto;
using MediaBrowser.Model.Updates; using MediaBrowser.Model.Updates;
@ -257,6 +258,6 @@ namespace MediaBrowser.Model.Configuration
/// Gets or sets the chapter image resolution. /// Gets or sets the chapter image resolution.
/// </summary> /// </summary>
/// <value>The chapter image resolution.</value> /// <value>The chapter image resolution.</value>
public string ChapterImageResolution { get; set; } = "Match Source"; public ImageResolution ChapterImageResolution { get; set; } = ImageResolution.MatchSource;
} }
} }

@ -5,6 +5,16 @@ namespace MediaBrowser.Model.Drawing
/// </summary> /// </summary>
public enum ImageResolution public enum ImageResolution
{ {
/// <summary>
/// MatchSource.
/// </summary>
MatchSource,
/// <summary>
/// 144p.
/// </summary>
P144,
/// <summary> /// <summary>
/// 240p. /// 240p.
/// </summary> /// </summary>

@ -666,7 +666,7 @@ namespace MediaBrowser.Providers.MediaInfo
return Array.Empty<ChapterInfo>(); return Array.Empty<ChapterInfo>();
} }
// Limit to 100 chapters just in case there's some incorrect metadata here // Limit the chapters just in case there's some incorrect metadata here
int chapterCount = (int)Math.Min(runtime / dummyChapterDuration, _config.Configuration.DummyChapterCount); int chapterCount = (int)Math.Min(runtime / dummyChapterDuration, _config.Configuration.DummyChapterCount);
var chapters = new ChapterInfo[chapterCount]; var chapters = new ChapterInfo[chapterCount];

Loading…
Cancel
Save