PR #22791 opened by Blasman
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/22791
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/22791.patch

Band-aid fix for using Sponsorblock with subtitles in yt-dlp and other 
applications. Should no longer crash ffmpeg and instead forcibly add the 
subtitles to the subtitle file.
See: 
[https://github.com/yt-dlp/yt-dlp/issues/9929](https://github.com/yt-dlp/yt-dlp/issues/9929)


>From bfec6fbb4c8de80edc03f9dd02709a7d7beb9716 Mon Sep 17 00:00:00 2001
From: Blasman <[email protected]>
Date: Sat, 11 Apr 2026 18:35:01 +0000
Subject: [PATCH] Prevens ffmpeg from crashing when adding subtitles with
 multiple edited out parts of video

Band-aid fix for using Sponsorblock with subtitles. Should no longer crash 
ffmpeg and instead forcibly add the subtitles to the subtitle file.
See: https://github.com/yt-dlp/yt-dlp/issues/9929
---
 libavformat/subtitles.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/libavformat/subtitles.c b/libavformat/subtitles.c
index 69e4df88a3..bd8bfb2b6b 100644
--- a/libavformat/subtitles.c
+++ b/libavformat/subtitles.c
@@ -289,8 +289,10 @@ int ff_subtitles_queue_seek(FFDemuxSubtitlesQueue *q, 
AVFormatContext *s, int st
                 idx = i;
 
         ts_selected = q->subs[idx]->pts;
-        if (ts_selected < min_ts || ts_selected > max_ts)
-            return AVERROR(ERANGE);
+        if (ts_selected < min_ts || ts_selected > max_ts) {
+            q->current_sub_idx = idx + 1;
+            return 0;
+        }
 
         /* look back in the latest subtitles for overlapping subtitles */
         for (i = idx - 1; i >= 0; i--) {
-- 
2.52.0

_______________________________________________
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to