diff options
| author | Bond-009 <bond.009@outlook.com> | 2025-04-04 01:44:47 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-04-03 17:44:47 -0600 |
| commit | 1c2b48182a5f555be7dcf260139e118f0e716fbd (patch) | |
| tree | fe3f7bea115ab14eec722872c1151fbaf9e95042 | |
| parent | d1ed6593ad36c360df734c0ad0847d10c9c544be (diff) | |
Fix ArgumentNullException on playlist creation (#13837)
mediaSourceId can be null, the IDE doesn't know this as nullable is disabled for BaseEncodingJobOptions
3 files changed, 7 insertions, 5 deletions
diff --git a/Jellyfin.Api/Controllers/DynamicHlsController.cs b/Jellyfin.Api/Controllers/DynamicHlsController.cs index b501bae4c..c82853362 100644 --- a/Jellyfin.Api/Controllers/DynamicHlsController.cs +++ b/Jellyfin.Api/Controllers/DynamicHlsController.cs @@ -1419,9 +1419,9 @@ public class DynamicHlsController : BaseJellyfinApiController TranscodingJobType, cancellationTokenSource.Token) .ConfigureAwait(false); - + var mediaSourceId = state.BaseRequest.MediaSourceId; var request = new CreateMainPlaylistRequest( - Guid.Parse(state.BaseRequest.MediaSourceId), + mediaSourceId is null ? null : Guid.Parse(mediaSourceId), state.MediaPath, state.SegmentLength * 1000, state.RunTimeTicks ?? 0, diff --git a/src/Jellyfin.MediaEncoding.Hls/Playlist/CreateMainPlaylistRequest.cs b/src/Jellyfin.MediaEncoding.Hls/Playlist/CreateMainPlaylistRequest.cs index ac9d30b33..f5af50062 100644 --- a/src/Jellyfin.MediaEncoding.Hls/Playlist/CreateMainPlaylistRequest.cs +++ b/src/Jellyfin.MediaEncoding.Hls/Playlist/CreateMainPlaylistRequest.cs @@ -18,7 +18,7 @@ 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(Guid mediaSourceId, 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; @@ -33,7 +33,7 @@ public class CreateMainPlaylistRequest /// <summary> /// Gets the media source id. /// </summary> - public Guid MediaSourceId { get; } + public Guid? MediaSourceId { get; } /// <summary> /// Gets the file path. diff --git a/src/Jellyfin.MediaEncoding.Hls/Playlist/DynamicHlsPlaylistGenerator.cs b/src/Jellyfin.MediaEncoding.Hls/Playlist/DynamicHlsPlaylistGenerator.cs index 343f3e562..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.MediaSourceId, 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); } |
