aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs
diff options
context:
space:
mode:
authorgnattu <gnattu@users.noreply.github.com>2024-05-17 13:51:54 -0400
committerJoshua M. Boniface <joshua@boniface.me>2024-05-17 13:51:54 -0400
commit424ca49c266349563786a7f1dcfb5fbf7db4b48d (patch)
tree9aa21cbfd152f374d71b9e7f61a160a276ca8d77 /MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs
parenta2eb4c5e6010dffc38560efa650d94c6c85c1cdd (diff)
Backport pull request #11689 from jellyfin/release-10.9.z
Workaround ffmpeg keyframe seeking for external subtitles Original-merge: 02937873b1f4e132a50d21fd2eca4c72160dd286 Merged-by: nielsvanvelzen <nielsvanvelzen@users.noreply.github.com> Backported-by: Joshua M. Boniface <joshua@boniface.me>
Diffstat (limited to 'MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs')
-rw-r--r--MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs8
1 files changed, 7 insertions, 1 deletions
diff --git a/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs b/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs
index d6907fdf9..49c208b77 100644
--- a/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs
+++ b/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs
@@ -2771,7 +2771,13 @@ namespace MediaBrowser.Controller.MediaEncoding
if (time > 0)
{
- seekParam += string.Format(CultureInfo.InvariantCulture, "-ss {0}", _mediaEncoder.GetTimeParameter(time));
+ // For direct streaming/remuxing, we seek at the exact position of the keyframe
+ // However, ffmpeg will seek to previous keyframe when the exact time is the input
+ // Workaround this by adding 0.5s offset to the seeking time to get the exact keyframe on most videos.
+ // This will help subtitle syncing.
+ var isHlsRemuxing = state.IsVideoRequest && state.TranscodingType is TranscodingJobType.Hls && IsCopyCodec(state.OutputVideoCodec);
+ var seekTick = isHlsRemuxing ? time + 5000000L : time;
+ seekParam += string.Format(CultureInfo.InvariantCulture, "-ss {0}", _mediaEncoder.GetTimeParameter(seekTick));
if (state.IsVideoRequest)
{