aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.MediaEncoding
diff options
context:
space:
mode:
Diffstat (limited to 'MediaBrowser.MediaEncoding')
-rw-r--r--MediaBrowser.MediaEncoding/Attachments/AttachmentExtractor.cs3
-rw-r--r--MediaBrowser.MediaEncoding/Encoder/EncoderValidator.cs25
-rw-r--r--MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs18
-rw-r--r--MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs1
-rw-r--r--MediaBrowser.MediaEncoding/Transcoding/TranscodeManager.cs28
5 files changed, 56 insertions, 19 deletions
diff --git a/MediaBrowser.MediaEncoding/Attachments/AttachmentExtractor.cs b/MediaBrowser.MediaEncoding/Attachments/AttachmentExtractor.cs
index a97cca6b8..a11440ced 100644
--- a/MediaBrowser.MediaEncoding/Attachments/AttachmentExtractor.cs
+++ b/MediaBrowser.MediaEncoding/Attachments/AttachmentExtractor.cs
@@ -139,7 +139,8 @@ namespace MediaBrowser.MediaEncoding.Attachments
var processArgs = string.Format(
CultureInfo.InvariantCulture,
- "-dump_attachment:t \"\" -y -i {0} -t 0 -f null null",
+ "-dump_attachment:t \"\" -y {0} -i {1} -t 0 -f null null",
+ inputPath.EndsWith(".concat\"", StringComparison.OrdinalIgnoreCase) ? "-f concat -safe 0" : string.Empty,
inputPath);
int exitCode;
diff --git a/MediaBrowser.MediaEncoding/Encoder/EncoderValidator.cs b/MediaBrowser.MediaEncoding/Encoder/EncoderValidator.cs
index fdca28390..5f0779dc7 100644
--- a/MediaBrowser.MediaEncoding/Encoder/EncoderValidator.cs
+++ b/MediaBrowser.MediaEncoding/Encoder/EncoderValidator.cs
@@ -69,6 +69,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
"aac_at",
"libfdk_aac",
"ac3",
+ "alac",
"dca",
"libmp3lame",
"libopus",
@@ -128,6 +129,9 @@ namespace MediaBrowser.MediaEncoding.Encoder
"overlay_vulkan",
// videotoolbox
"yadif_videotoolbox",
+ "scale_vt",
+ "overlay_videotoolbox",
+ "tonemap_videotoolbox",
// rkrga
"scale_rkrga",
"vpp_rkrga",
@@ -144,17 +148,18 @@ namespace MediaBrowser.MediaEncoding.Encoder
{ 5, new string[] { "overlay_vulkan", "Action to take when encountering EOF from secondary input" } }
};
- // These are the library versions that corresponds to our minimum ffmpeg version 4.x according to the version table below
+ // These are the library versions that corresponds to our minimum ffmpeg version 4.4 according to the version table below
+ // Refers to the versions in https://ffmpeg.org/download.html
private static readonly Dictionary<string, Version> _ffmpegMinimumLibraryVersions = new Dictionary<string, Version>
{
- { "libavutil", new Version(56, 14) },
- { "libavcodec", new Version(58, 18) },
- { "libavformat", new Version(58, 12) },
- { "libavdevice", new Version(58, 3) },
- { "libavfilter", new Version(7, 16) },
- { "libswscale", new Version(5, 1) },
- { "libswresample", new Version(3, 1) },
- { "libpostproc", new Version(55, 1) }
+ { "libavutil", new Version(56, 70) },
+ { "libavcodec", new Version(58, 134) },
+ { "libavformat", new Version(58, 76) },
+ { "libavdevice", new Version(58, 13) },
+ { "libavfilter", new Version(7, 110) },
+ { "libswscale", new Version(5, 9) },
+ { "libswresample", new Version(3, 9) },
+ { "libpostproc", new Version(55, 9) }
};
private readonly ILogger _logger;
@@ -174,7 +179,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
}
// When changing this, also change the minimum library versions in _ffmpegMinimumLibraryVersions
- public static Version MinVersion { get; } = new Version(4, 0);
+ public static Version MinVersion { get; } = new Version(4, 4);
public static Version? MaxVersion { get; } = null;
diff --git a/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs b/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs
index cc6971c1b..807678025 100644
--- a/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs
+++ b/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs
@@ -154,12 +154,12 @@ namespace MediaBrowser.MediaEncoding.Encoder
/// </summary>
public void SetFFmpegPath()
{
- // 1) Custom path stored in config/encoding xml file under tag <EncoderAppPath> takes precedence
- var ffmpegPath = _configurationManager.GetEncodingOptions().EncoderAppPath;
+ // 1) Check if the --ffmpeg CLI switch has been given
+ var ffmpegPath = _startupOptionFFmpegPath;
if (string.IsNullOrEmpty(ffmpegPath))
{
- // 2) Check if the --ffmpeg CLI switch has been given
- ffmpegPath = _startupOptionFFmpegPath;
+ // 2) Custom path stored in config/encoding xml file under tag <EncoderAppPath> should be used as a fallback
+ ffmpegPath = _configurationManager.GetEncodingOptions().EncoderAppPath;
if (string.IsNullOrEmpty(ffmpegPath))
{
// 3) Check "ffmpeg"
@@ -463,6 +463,11 @@ namespace MediaBrowser.MediaEncoding.Encoder
extraArgs += " -user_agent " + userAgent;
}
+ if (request.MediaSource.Protocol == MediaProtocol.Rtsp)
+ {
+ extraArgs += " -rtsp_transport tcp+udp -rtsp_flags prefer_tcp";
+ }
+
return extraArgs;
}
@@ -691,7 +696,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
Video3DFormat.HalfTopAndBottom => @"crop=iw:ih/2:0:0,scale=(iw*2):ih),setdar=dar=a,crop=min(iw\,ih*dar):min(ih\,iw/dar):(iw-min(iw\,iw*sar))/2:(ih - min (ih\,ih/sar))/2,setsar=sar=1",
// ftab crop height in half, set the display aspect,crop out any black bars we may have made
Video3DFormat.FullTopAndBottom => @"crop=iw:ih/2:0:0,setdar=dar=a,crop=min(iw\,ih*dar):min(ih\,iw/dar):(iw-min(iw\,iw*sar))/2:(ih - min (ih\,ih/sar))/2,setsar=sar=1",
- _ => "scale=trunc(iw*sar):ih"
+ _ => "scale=round(iw*sar/2)*2:round(ih/2)*2"
};
filters.Add(scaler);
@@ -800,6 +805,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
int maxWidth,
TimeSpan interval,
bool allowHwAccel,
+ bool enableHwEncoding,
int? threads,
int? qualityScale,
ProcessPriorityClass? priority,
@@ -828,7 +834,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
MediaPath = inputFile,
OutputVideoCodec = "mjpeg"
};
- var vidEncoder = options.AllowMjpegEncoding ? encodingHelper.GetVideoEncoder(jobState, options) : jobState.OutputVideoCodec;
+ var vidEncoder = enableHwEncoding ? encodingHelper.GetVideoEncoder(jobState, options) : jobState.OutputVideoCodec;
// Get input and filter arguments
var inputArg = encodingHelper.GetInputArgument(jobState, options, container).Trim();
diff --git a/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs b/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs
index 317aba418..5397a6752 100644
--- a/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs
+++ b/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs
@@ -79,6 +79,7 @@ namespace MediaBrowser.MediaEncoding.Probing
"5/8erl in Ehr'n",
"Smith/Kotzen",
"We;Na",
+ "LSR/CITY",
};
/// <summary>
diff --git a/MediaBrowser.MediaEncoding/Transcoding/TranscodeManager.cs b/MediaBrowser.MediaEncoding/Transcoding/TranscodeManager.cs
index 8bace15c6..a07a0f41b 100644
--- a/MediaBrowser.MediaEncoding/Transcoding/TranscodeManager.cs
+++ b/MediaBrowser.MediaEncoding/Transcoding/TranscodeManager.cs
@@ -321,7 +321,7 @@ public sealed class TranscodeManager : ITranscodeManager, IDisposable
}
catch (IOException ex)
{
- (exs ??= new List<Exception>(4)).Add(ex);
+ (exs ??= new List<Exception>()).Add(ex);
_logger.LogError(ex, "Error deleting HLS file {Path}", file);
}
}
@@ -546,6 +546,7 @@ public sealed class TranscodeManager : ITranscodeManager, IDisposable
if (!transcodingJob.HasExited)
{
StartThrottler(state, transcodingJob);
+ StartSegmentCleaner(state, transcodingJob);
}
else if (transcodingJob.ExitCode != 0)
{
@@ -573,6 +574,22 @@ public sealed class TranscodeManager : ITranscodeManager, IDisposable
&& state.IsInputVideo
&& state.VideoType == VideoType.VideoFile;
+ private void StartSegmentCleaner(StreamState state, TranscodingJob transcodingJob)
+ {
+ if (EnableSegmentCleaning(state))
+ {
+ transcodingJob.TranscodingSegmentCleaner = new TranscodingSegmentCleaner(transcodingJob, _loggerFactory.CreateLogger<TranscodingSegmentCleaner>(), _serverConfigurationManager, _fileSystem, _mediaEncoder, state.SegmentLength);
+ transcodingJob.TranscodingSegmentCleaner.Start();
+ }
+ }
+
+ private static bool EnableSegmentCleaning(StreamState state)
+ => state.InputProtocol is MediaProtocol.File or MediaProtocol.Http
+ && state.IsInputVideo
+ && state.TranscodingType == TranscodingJobType.Hls
+ && state.RunTimeTicks.HasValue
+ && state.RunTimeTicks.Value >= TimeSpan.FromMinutes(5).Ticks;
+
private TranscodingJob OnTranscodeBeginning(
string path,
string? playSessionId,
@@ -724,7 +741,14 @@ public sealed class TranscodeManager : ITranscodeManager, IDisposable
foreach (var file in _fileSystem.GetFilePaths(path, true))
{
- _fileSystem.DeleteFile(file);
+ try
+ {
+ _fileSystem.DeleteFile(file);
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Error deleting encoded media cache file {Path}", path);
+ }
}
}