mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-12-16 14:03:03 +03:00
Add TranscodingSegmentCleaner to replace ffmpeg's hlsenc deletion
FFmpeg deletes segments based on its own transcoding progress, but we need to delete segments based on client download progress. Since disk and GPU speeds vary, using hlsenc's built-in deletion will result in premature deletion of some segments. As a consequence, the server has to constantly respin new ffmpeg instances, resulting in choppy video playback. Signed-off-by: nyanmisaka <nst799610810@gmail.com>
This commit is contained in:
@@ -1604,7 +1604,7 @@ public class DynamicHlsController : BaseJellyfinApiController
|
||||
Path.GetFileNameWithoutExtension(outputPath));
|
||||
}
|
||||
|
||||
var hlsArguments = GetHlsArguments(isEventPlaylist, state.SegmentLength);
|
||||
var hlsArguments = string.Format(CultureInfo.InvariantCulture, "-hls_playlist_type {0} -hls_list_size 0", isEventPlaylist ? "event" : "vod");
|
||||
|
||||
return string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
@@ -1625,33 +1625,6 @@ public class DynamicHlsController : BaseJellyfinApiController
|
||||
EncodingUtils.NormalizePath(outputPath)).Trim();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the HLS arguments for transcoding.
|
||||
/// </summary>
|
||||
/// <returns>The command line arguments for HLS transcoding.</returns>
|
||||
private string GetHlsArguments(bool isEventPlaylist, int segmentLength)
|
||||
{
|
||||
var enableThrottling = _encodingOptions.EnableThrottling;
|
||||
var enableSegmentDeletion = _encodingOptions.EnableSegmentDeletion;
|
||||
|
||||
// Only enable segment deletion when throttling is enabled
|
||||
if (enableThrottling && enableSegmentDeletion)
|
||||
{
|
||||
// Store enough segments for configured seconds of playback; this needs to be above throttling settings
|
||||
var segmentCount = _encodingOptions.SegmentKeepSeconds / segmentLength;
|
||||
|
||||
_logger.LogDebug("Using throttling and segment deletion, keeping {0} segments", segmentCount);
|
||||
|
||||
return string.Format(CultureInfo.InvariantCulture, "-hls_list_size {0} -hls_flags delete_segments", segmentCount.ToString(CultureInfo.InvariantCulture));
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.LogDebug("Using normal playback, is event playlist? {0}", isEventPlaylist);
|
||||
|
||||
return string.Format(CultureInfo.InvariantCulture, "-hls_playlist_type {0} -hls_list_size 0", isEventPlaylist ? "event" : "vod");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the audio arguments for transcoding.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user