diff options
| author | Cody Robibero <cody@robibe.ro> | 2024-03-18 08:37:02 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-03-18 08:37:02 -0600 |
| commit | 833bc06eb4e49d86ac8e5140f9a1cd4ef8dce9f5 (patch) | |
| tree | d61a87e423cbb36cea27cd7a511612b7dbb9a6c3 /MediaBrowser.MediaEncoding/Transcoding | |
| parent | bd1060b306334eee7f6e3630a75db1cf5deed507 (diff) | |
| parent | 9b35b4e8f28e95fbd583f12e3192da3e8132dae2 (diff) | |
Merge pull request #11161 from nyanmisaka/fix-segment-deletion
Co-authored-by: Claus Vium <cvium@users.noreply.github.com>
Diffstat (limited to 'MediaBrowser.MediaEncoding/Transcoding')
| -rw-r--r-- | MediaBrowser.MediaEncoding/Transcoding/TranscodeManager.cs | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/MediaBrowser.MediaEncoding/Transcoding/TranscodeManager.cs b/MediaBrowser.MediaEncoding/Transcoding/TranscodeManager.cs index 5d51a901a..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, |
