diff options
Diffstat (limited to 'Jellyfin.Api/Controllers/DynamicHlsController.cs')
| -rw-r--r-- | Jellyfin.Api/Controllers/DynamicHlsController.cs | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/Jellyfin.Api/Controllers/DynamicHlsController.cs b/Jellyfin.Api/Controllers/DynamicHlsController.cs index 034a9dea55..6df76de0b4 100644 --- a/Jellyfin.Api/Controllers/DynamicHlsController.cs +++ b/Jellyfin.Api/Controllers/DynamicHlsController.cs @@ -1778,6 +1778,16 @@ public class DynamicHlsController : BaseJellyfinApiController } /// <summary> + /// Selects the HEVC Dolby Vision sample entry tag. + /// </summary> + /// <param name="stream">The video stream.</param> + /// <returns>The MP4 sample entry tag.</returns> + internal static string GetDolbyVisionHevcCodecTag(MediaStream stream) + { + return stream.DvProfile == 8 ? "hvc1" : "dvh1"; + } + + /// <summary> /// Gets the video arguments for transcoding. /// </summary> /// <param name="state">The <see cref="StreamState"/>.</param> @@ -1819,8 +1829,7 @@ public class DynamicHlsController : BaseJellyfinApiController { if (isActualOutputVideoCodecHevc) { - // Use hvc1 for 8.4. This is what Dolby uses for its official sample streams. Tagging with dvh1 would break some players with strict tag checking like Apple Safari. - var codecTag = state.VideoStream.VideoRangeType == VideoRangeType.DOVIWithHLG ? "hvc1" : "dvh1"; + var codecTag = GetDolbyVisionHevcCodecTag(state.VideoStream); args += $" -tag:v:0 {codecTag} -strict -2"; } else if (isActualOutputVideoCodecAv1) @@ -1928,7 +1937,7 @@ public class DynamicHlsController : BaseJellyfinApiController { // Transcoding job is over, so assume all existing files are ready _logger.LogDebug("serving up {0} as transcode is over", segmentPath); - return GetSegmentResult(state, segmentPath, transcodingJob); + return GetSegmentResult(state, segmentPath, segmentIndex, transcodingJob); } var currentTranscodingIndex = GetCurrentTranscodingIndex(playlistPath, segmentExtension); @@ -1937,7 +1946,7 @@ public class DynamicHlsController : BaseJellyfinApiController if (segmentIndex < currentTranscodingIndex) { _logger.LogDebug("serving up {0} as transcode index {1} is past requested point {2}", segmentPath, currentTranscodingIndex, segmentIndex); - return GetSegmentResult(state, segmentPath, transcodingJob); + return GetSegmentResult(state, segmentPath, segmentIndex, transcodingJob); } } @@ -1953,7 +1962,7 @@ public class DynamicHlsController : BaseJellyfinApiController if (transcodingJob.HasExited || System.IO.File.Exists(nextSegmentPath)) { _logger.LogDebug("Serving up {SegmentPath} as it deemed ready", segmentPath); - return GetSegmentResult(state, segmentPath, transcodingJob); + return GetSegmentResult(state, segmentPath, segmentIndex, transcodingJob); } } else @@ -1984,10 +1993,10 @@ public class DynamicHlsController : BaseJellyfinApiController _logger.LogWarning("cannot serve {0} as it doesn't exist and no transcode is running", segmentPath); } - return GetSegmentResult(state, segmentPath, transcodingJob); + return GetSegmentResult(state, segmentPath, segmentIndex, transcodingJob); } - private ActionResult GetSegmentResult(StreamState state, string segmentPath, TranscodingJob? transcodingJob) + private ActionResult GetSegmentResult(StreamState state, string segmentPath, int segmentIndex, TranscodingJob? transcodingJob) { var segmentEndingPositionTicks = state.Request.CurrentRuntimeTicks + state.Request.ActualSegmentLengthTicks; @@ -1997,6 +2006,7 @@ public class DynamicHlsController : BaseJellyfinApiController if (transcodingJob is not null) { transcodingJob.DownloadPositionTicks = Math.Max(transcodingJob.DownloadPositionTicks ?? segmentEndingPositionTicks, segmentEndingPositionTicks); + transcodingJob.ReportSegmentDownloaded(segmentIndex, segmentEndingPositionTicks); _transcodeManager.OnTranscodeEndRequest(transcodingJob); } |
