mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-06-03 13:44:22 -04:00
Specify threads to ffmpeg properly
This commit is contained in:
parent
d7cdaeea7d
commit
94cae4f145
@ -9,6 +9,7 @@ using System.Text;
|
|||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using MediaBrowser.Controller;
|
using MediaBrowser.Controller;
|
||||||
|
using MediaBrowser.Controller.Configuration;
|
||||||
using MediaBrowser.Controller.Library;
|
using MediaBrowser.Controller.Library;
|
||||||
using MediaBrowser.Controller.MediaEncoding;
|
using MediaBrowser.Controller.MediaEncoding;
|
||||||
using MediaBrowser.Model.Dto;
|
using MediaBrowser.Model.Dto;
|
||||||
@ -25,6 +26,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
|
|||||||
private readonly IServerApplicationPaths _appPaths;
|
private readonly IServerApplicationPaths _appPaths;
|
||||||
private readonly IJsonSerializer _json;
|
private readonly IJsonSerializer _json;
|
||||||
private readonly TaskCompletionSource<bool> _taskCompletionSource = new TaskCompletionSource<bool>();
|
private readonly TaskCompletionSource<bool> _taskCompletionSource = new TaskCompletionSource<bool>();
|
||||||
|
private readonly IServerConfigurationManager _serverConfigurationManager;
|
||||||
|
|
||||||
private bool _hasExited;
|
private bool _hasExited;
|
||||||
private Stream _logFileStream;
|
private Stream _logFileStream;
|
||||||
@ -35,12 +37,14 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
|
|||||||
ILogger logger,
|
ILogger logger,
|
||||||
IMediaEncoder mediaEncoder,
|
IMediaEncoder mediaEncoder,
|
||||||
IServerApplicationPaths appPaths,
|
IServerApplicationPaths appPaths,
|
||||||
IJsonSerializer json)
|
IJsonSerializer json,
|
||||||
|
IServerConfigurationManager serverConfigurationManager)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_mediaEncoder = mediaEncoder;
|
_mediaEncoder = mediaEncoder;
|
||||||
_appPaths = appPaths;
|
_appPaths = appPaths;
|
||||||
_json = json;
|
_json = json;
|
||||||
|
_serverConfigurationManager = serverConfigurationManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static bool CopySubtitles => false;
|
private static bool CopySubtitles => false;
|
||||||
@ -179,15 +183,17 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
|
|||||||
|
|
||||||
var outputParam = string.Empty;
|
var outputParam = string.Empty;
|
||||||
|
|
||||||
|
var threads = EncodingHelper.GetNumberOfThreads(null, _serverConfigurationManager.GetEncodingOptions(), null);
|
||||||
var commandLineArgs = string.Format(
|
var commandLineArgs = string.Format(
|
||||||
CultureInfo.InvariantCulture,
|
CultureInfo.InvariantCulture,
|
||||||
"-i \"{0}\" {2} -map_metadata -1 -threads 0 {3}{4}{5} -y \"{1}\"",
|
"-i \"{0}\" {2} -map_metadata -1 -threads {6} {3}{4}{5} -y \"{1}\"",
|
||||||
inputTempFile,
|
inputTempFile,
|
||||||
targetFile,
|
targetFile,
|
||||||
videoArgs,
|
videoArgs,
|
||||||
GetAudioArgs(mediaSource),
|
GetAudioArgs(mediaSource),
|
||||||
subtitleArgs,
|
subtitleArgs,
|
||||||
outputParam);
|
outputParam,
|
||||||
|
threads);
|
||||||
|
|
||||||
return inputModifier + " " + commandLineArgs;
|
return inputModifier + " " + commandLineArgs;
|
||||||
}
|
}
|
||||||
|
@ -64,6 +64,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
|
|||||||
|
|
||||||
private string _ffmpegPath = string.Empty;
|
private string _ffmpegPath = string.Empty;
|
||||||
private string _ffprobePath;
|
private string _ffprobePath;
|
||||||
|
private int threads;
|
||||||
|
|
||||||
public MediaEncoder(
|
public MediaEncoder(
|
||||||
ILogger<MediaEncoder> logger,
|
ILogger<MediaEncoder> logger,
|
||||||
@ -129,6 +130,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
|
|||||||
SetAvailableDecoders(validator.GetDecoders());
|
SetAvailableDecoders(validator.GetDecoders());
|
||||||
SetAvailableEncoders(validator.GetEncoders());
|
SetAvailableEncoders(validator.GetEncoders());
|
||||||
SetAvailableHwaccels(validator.GetHwaccels());
|
SetAvailableHwaccels(validator.GetHwaccels());
|
||||||
|
threads = EncodingHelper.GetNumberOfThreads(null, _configurationManager.GetEncodingOptions(), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
_logger.LogInformation("FFmpeg: {EncoderLocation}: {FfmpegPath}", EncoderLocation, _ffmpegPath ?? string.Empty);
|
_logger.LogInformation("FFmpeg: {EncoderLocation}: {FfmpegPath}", EncoderLocation, _ffmpegPath ?? string.Empty);
|
||||||
@ -377,9 +379,9 @@ namespace MediaBrowser.MediaEncoding.Encoder
|
|||||||
CancellationToken cancellationToken)
|
CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var args = extractChapters
|
var args = extractChapters
|
||||||
? "{0} -i {1} -threads 0 -v warning -print_format json -show_streams -show_chapters -show_format"
|
? "{0} -i {1} -threads {2} -v warning -print_format json -show_streams -show_chapters -show_format"
|
||||||
: "{0} -i {1} -threads 0 -v warning -print_format json -show_streams -show_format";
|
: "{0} -i {1} -threads {2} -v warning -print_format json -show_streams -show_format";
|
||||||
args = string.Format(CultureInfo.InvariantCulture, args, probeSizeArgument, inputPath).Trim();
|
args = string.Format(CultureInfo.InvariantCulture, args, probeSizeArgument, inputPath, threads).Trim();
|
||||||
|
|
||||||
var process = new Process
|
var process = new Process
|
||||||
{
|
{
|
||||||
@ -555,8 +557,8 @@ namespace MediaBrowser.MediaEncoding.Encoder
|
|||||||
// Use ffmpeg to sample 100 (we can drop this if required using thumbnail=50 for 50 frames) frames and pick the best thumbnail. Have a fall back just in case.
|
// Use ffmpeg to sample 100 (we can drop this if required using thumbnail=50 for 50 frames) frames and pick the best thumbnail. Have a fall back just in case.
|
||||||
var thumbnail = enableThumbnail ? ",thumbnail=24" : string.Empty;
|
var thumbnail = enableThumbnail ? ",thumbnail=24" : string.Empty;
|
||||||
|
|
||||||
var args = useIFrame ? string.Format(CultureInfo.InvariantCulture, "-i {0}{3} -threads 0 -v quiet -vframes 1 -vf \"{2}{4}\" -f image2 \"{1}\"", inputPath, tempExtractPath, vf, mapArg, thumbnail) :
|
var args = useIFrame ? string.Format(CultureInfo.InvariantCulture, "-i {0}{3} -threads {5} -v quiet -vframes 1 -vf \"{2}{4}\" -f image2 \"{1}\"", inputPath, tempExtractPath, vf, mapArg, thumbnail, threads) :
|
||||||
string.Format(CultureInfo.InvariantCulture, "-i {0}{3} -threads 0 -v quiet -vframes 1 -vf \"{2}\" -f image2 \"{1}\"", inputPath, tempExtractPath, vf, mapArg);
|
string.Format(CultureInfo.InvariantCulture, "-i {0}{3} -threads {4} -v quiet -vframes 1 -vf \"{2}\" -f image2 \"{1}\"", inputPath, tempExtractPath, vf, mapArg, threads);
|
||||||
|
|
||||||
var probeSizeArgument = EncodingHelper.GetProbeSizeArgument(1);
|
var probeSizeArgument = EncodingHelper.GetProbeSizeArgument(1);
|
||||||
var analyzeDurationArgument = EncodingHelper.GetAnalyzeDurationArgument(1);
|
var analyzeDurationArgument = EncodingHelper.GetAnalyzeDurationArgument(1);
|
||||||
@ -693,7 +695,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
|
|||||||
Directory.CreateDirectory(targetDirectory);
|
Directory.CreateDirectory(targetDirectory);
|
||||||
var outputPath = Path.Combine(targetDirectory, filenamePrefix + "%05d.jpg");
|
var outputPath = Path.Combine(targetDirectory, filenamePrefix + "%05d.jpg");
|
||||||
|
|
||||||
var args = string.Format(CultureInfo.InvariantCulture, "-i {0} -threads 0 -v quiet -vf \"{2}\" -f image2 \"{1}\"", inputArgument, outputPath, vf);
|
var args = string.Format(CultureInfo.InvariantCulture, "-i {0} -threads {3} -v quiet -vf \"{2}\" -f image2 \"{1}\"", inputArgument, outputPath, vf, threads);
|
||||||
|
|
||||||
var probeSizeArgument = EncodingHelper.GetProbeSizeArgument(1);
|
var probeSizeArgument = EncodingHelper.GetProbeSizeArgument(1);
|
||||||
var analyzeDurationArgument = EncodingHelper.GetAnalyzeDurationArgument(1);
|
var analyzeDurationArgument = EncodingHelper.GetAnalyzeDurationArgument(1);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user