diff options
| author | IceStormNG <IceStormNG@users.noreply.github.com> | 2026-01-28 12:11:24 -0500 |
|---|---|---|
| committer | Bond_009 <bond.009@outlook.com> | 2026-01-28 12:11:24 -0500 |
| commit | 5045c2e4488bf60965b1f5f4893a3539bd7c3da0 (patch) | |
| tree | c415de4876b944b802b2f5f1b6a24662bdb76a44 | |
| parent | ec4744709df1664f263937ae41baadc48d7d6c9b (diff) | |
Backport pull request #16053 from jellyfin/release-10.11.z
Fix HLS playlist generation for transcodes with fractional framerate
Original-merge: 893a849f28b651657b3797d1711da8f696b4120c
Merged-by: crobibero <cody@robibe.ro>
Backported-by: Bond_009 <bond.009@outlook.com>
| -rw-r--r-- | Jellyfin.Api/Controllers/DynamicHlsController.cs | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/Jellyfin.Api/Controllers/DynamicHlsController.cs b/Jellyfin.Api/Controllers/DynamicHlsController.cs index 15b04051f..f80b36c39 100644 --- a/Jellyfin.Api/Controllers/DynamicHlsController.cs +++ b/Jellyfin.Api/Controllers/DynamicHlsController.cs @@ -1400,10 +1400,20 @@ public class DynamicHlsController : BaseJellyfinApiController cancellationTokenSource.Token) .ConfigureAwait(false); var mediaSourceId = state.BaseRequest.MediaSourceId; + double fps = state.TargetFramerate ?? 0.0f; + int segmentLength = state.SegmentLength * 1000; + + // If framerate is fractional (i.e. 23.976), we need to slightly adjust segment length + if (Math.Abs(fps - Math.Floor(fps + 0.001f)) > 0.001) + { + double nearestIntFramerate = Math.Ceiling(fps); + segmentLength = (int)Math.Ceiling(segmentLength * (nearestIntFramerate / fps)); + } + var request = new CreateMainPlaylistRequest( mediaSourceId is null ? null : Guid.Parse(mediaSourceId), state.MediaPath, - state.SegmentLength * 1000, + segmentLength, state.RunTimeTicks ?? 0, state.Request.SegmentContainer ?? string.Empty, "hls1/main/", |
