Fix ArgumentNullException on playlist creation (#13837)

mediaSourceId can be null, the IDE doesn't know this as nullable is disabled for BaseEncodingJobOptions
This commit is contained in:
Bond-009 2025-04-04 01:44:47 +02:00 committed by GitHub
parent d1ed6593ad
commit 1c2b48182a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 7 additions and 5 deletions

View File

@ -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,

View File

@ -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.

View File

@ -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);
}