aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs
diff options
context:
space:
mode:
Diffstat (limited to 'MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs')
-rw-r--r--MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs39
1 files changed, 12 insertions, 27 deletions
diff --git a/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs b/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs
index b7c49ed99..91bf42b15 100644
--- a/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs
+++ b/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs
@@ -75,7 +75,8 @@ namespace MediaBrowser.MediaEncoding.Encoder
private bool _isVaapiDeviceInteli965 = false;
private bool _isVaapiDeviceSupportVulkanFmtModifier = false;
- private static string[] _vulkanFmtModifierExts = {
+ private static string[] _vulkanFmtModifierExts =
+ {
"VK_KHR_sampler_ycbcr_conversion",
"VK_EXT_image_drm_format_modifier",
"VK_KHR_external_memory_fd",
@@ -156,7 +157,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
_configurationManager.SaveConfiguration("encoding", options);
// Only if mpeg path is set, try and set path to probe
- if (_ffmpegPath != null)
+ if (_ffmpegPath is not null)
{
// Determine a probe path from the mpeg path
_ffprobePath = Regex.Replace(_ffmpegPath, @"[^\/\\]+?(\.[^\/\\\n.]+)?$", @"ffprobe$1");
@@ -414,8 +415,6 @@ namespace MediaBrowser.MediaEncoding.Encoder
analyzeDuration = "-analyzeduration " + ffmpegAnalyzeDuration;
}
- var forceEnableLogging = request.MediaSource.Protocol != MediaProtocol.File;
-
return GetMediaInfoInternal(
GetInputArgument(inputFile, request.MediaSource),
request.MediaSource.Path,
@@ -424,7 +423,6 @@ namespace MediaBrowser.MediaEncoding.Encoder
analyzeDuration,
request.MediaType == DlnaProfileType.Audio,
request.MediaSource.VideoType,
- forceEnableLogging,
cancellationToken);
}
@@ -472,7 +470,6 @@ namespace MediaBrowser.MediaEncoding.Encoder
string probeSizeArgument,
bool isAudio,
VideoType? videoType,
- bool forceEnableLogging,
CancellationToken cancellationToken)
{
var args = extractChapters
@@ -487,7 +484,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
CreateNoWindow = true,
UseShellExecute = false,
- // Must consume both or ffmpeg may hang due to deadlocks. See comments below.
+ // Must consume both or ffmpeg may hang due to deadlocks.
RedirectStandardOutput = true,
FileName = _ffprobePath,
@@ -499,21 +496,13 @@ namespace MediaBrowser.MediaEncoding.Encoder
EnableRaisingEvents = true
};
- if (forceEnableLogging)
- {
- _logger.LogInformation("{ProcessFileName} {ProcessArgs}", process.StartInfo.FileName, process.StartInfo.Arguments);
- }
- else
- {
- _logger.LogDebug("{ProcessFileName} {ProcessArgs}", process.StartInfo.FileName, process.StartInfo.Arguments);
- }
+ _logger.LogInformation("Starting {ProcessFileName} with args {ProcessArgs}", _ffprobePath, args);
using (var processWrapper = new ProcessWrapper(process, this))
{
await using var memoryStream = new MemoryStream();
- _logger.LogDebug("Starting ffprobe with args {Args}", args);
StartProcess(processWrapper);
- await process.StandardOutput.BaseStream.CopyToAsync(memoryStream, cancellationToken: cancellationToken);
+ await process.StandardOutput.BaseStream.CopyToAsync(memoryStream, cancellationToken);
memoryStream.Seek(0, SeekOrigin.Begin);
InternalMediaInfoResult result;
try
@@ -521,7 +510,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
result = await JsonSerializer.DeserializeAsync<InternalMediaInfoResult>(
memoryStream,
_jsonSerializerOptions,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ cancellationToken).ConfigureAwait(false);
}
catch
{
@@ -530,12 +519,12 @@ namespace MediaBrowser.MediaEncoding.Encoder
throw;
}
- if (result == null || (result.Streams == null && result.Format == null))
+ if (result is null || (result.Streams is null && result.Format is null))
{
throw new FfmpegException("ffprobe failed - streams and format are both null.");
}
- if (result.Streams != null)
+ if (result.Streams is not null)
{
// Normalize aspect ratio if invalid
foreach (var stream in result.Streams)
@@ -634,13 +623,9 @@ namespace MediaBrowser.MediaEncoding.Encoder
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));
- }
+ ArgumentException.ThrowIfNullOrEmpty(inputPath);
var outputExtension = targetFormat switch
{
@@ -660,7 +645,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
var filters = new List<string>();
// deinterlace using bwdif algorithm for video stream.
- if (videoStream != null && videoStream.IsInterlaced)
+ if (videoStream is not null && videoStream.IsInterlaced)
{
filters.Add("bwdif=0:-1:0");
}
@@ -1017,7 +1002,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
{
if (!_disposed)
{
- if (Process != null)
+ if (Process is not null)
{
Process.Exited -= OnProcessExited;
DisposeProcess(Process);