diff options
Diffstat (limited to 'src/Jellyfin.MediaEncoding.Hls/Playlist')
| -rw-r--r-- | src/Jellyfin.MediaEncoding.Hls/Playlist/CreateMainPlaylistRequest.cs | 11 | ||||
| -rw-r--r-- | src/Jellyfin.MediaEncoding.Hls/Playlist/DynamicHlsPlaylistGenerator.cs | 8 |
2 files changed, 15 insertions, 4 deletions
diff --git a/src/Jellyfin.MediaEncoding.Hls/Playlist/CreateMainPlaylistRequest.cs b/src/Jellyfin.MediaEncoding.Hls/Playlist/CreateMainPlaylistRequest.cs index 21d9bb658..f5af50062 100644 --- a/src/Jellyfin.MediaEncoding.Hls/Playlist/CreateMainPlaylistRequest.cs +++ b/src/Jellyfin.MediaEncoding.Hls/Playlist/CreateMainPlaylistRequest.cs @@ -1,3 +1,5 @@ +using System; + namespace Jellyfin.MediaEncoding.Hls.Playlist; /// <summary> @@ -8,6 +10,7 @@ public class CreateMainPlaylistRequest /// <summary> /// Initializes a new instance of the <see cref="CreateMainPlaylistRequest"/> class. /// </summary> + /// <param name="mediaSourceId">The media source id.</param> /// <param name="filePath">The absolute file path to the file.</param> /// <param name="desiredSegmentLengthMs">The desired segment length in milliseconds.</param> /// <param name="totalRuntimeTicks">The total duration of the file in ticks.</param> @@ -15,8 +18,9 @@ public class CreateMainPlaylistRequest /// <param name="endpointPrefix">The URI prefix for the relative URL in the playlist.</param> /// <param name="queryString">The desired query string to append (must start with ?).</param> /// <param name="isRemuxingVideo">Whether the video is being remuxed.</param> - public CreateMainPlaylistRequest(string filePath, int desiredSegmentLengthMs, long totalRuntimeTicks, string segmentContainer, string endpointPrefix, string queryString, bool isRemuxingVideo) + public CreateMainPlaylistRequest(Guid? mediaSourceId, string filePath, int desiredSegmentLengthMs, long totalRuntimeTicks, string segmentContainer, string endpointPrefix, string queryString, bool isRemuxingVideo) { + MediaSourceId = mediaSourceId; FilePath = filePath; DesiredSegmentLengthMs = desiredSegmentLengthMs; TotalRuntimeTicks = totalRuntimeTicks; @@ -27,6 +31,11 @@ public class CreateMainPlaylistRequest } /// <summary> + /// Gets the media source id. + /// </summary> + public Guid? MediaSourceId { get; } + + /// <summary> /// Gets the file path. /// </summary> public string FilePath { get; } diff --git a/src/Jellyfin.MediaEncoding.Hls/Playlist/DynamicHlsPlaylistGenerator.cs b/src/Jellyfin.MediaEncoding.Hls/Playlist/DynamicHlsPlaylistGenerator.cs index 1846ba26b..fb5027e5b 100644 --- a/src/Jellyfin.MediaEncoding.Hls/Playlist/DynamicHlsPlaylistGenerator.cs +++ b/src/Jellyfin.MediaEncoding.Hls/Playlist/DynamicHlsPlaylistGenerator.cs @@ -35,7 +35,9 @@ public class DynamicHlsPlaylistGenerator : IDynamicHlsPlaylistGenerator { IReadOnlyList<double> segments; // For video transcodes it is sufficient with equal length segments as ffmpeg will create new keyframes - if (request.IsRemuxingVideo && TryExtractKeyframes(request.FilePath, out var keyframeData)) + if (request.IsRemuxingVideo + && request.MediaSourceId is not null + && TryExtractKeyframes(request.MediaSourceId.Value, request.FilePath, out var keyframeData)) { segments = ComputeSegments(keyframeData, request.DesiredSegmentLengthMs); } @@ -104,7 +106,7 @@ public class DynamicHlsPlaylistGenerator : IDynamicHlsPlaylistGenerator return builder.ToString(); } - private bool TryExtractKeyframes(string filePath, [NotNullWhen(true)] out KeyframeData? keyframeData) + private bool TryExtractKeyframes(Guid itemId, string filePath, [NotNullWhen(true)] out KeyframeData? keyframeData) { keyframeData = null; if (!IsExtractionAllowedForFile(filePath, _serverConfigurationManager.GetEncodingOptions().AllowOnDemandMetadataBasedKeyframeExtractionForExtensions)) @@ -116,7 +118,7 @@ public class DynamicHlsPlaylistGenerator : IDynamicHlsPlaylistGenerator for (var i = 0; i < len; i++) { var extractor = _extractors[i]; - if (!extractor.TryExtractKeyframes(filePath, out var result)) + if (!extractor.TryExtractKeyframes(itemId, filePath, out var result)) { continue; } |
