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

`-reconnect` and the other reconnect options apply only to the hls, dash or imf 
manifest request, not to the segments. A segment connection that closes 
mid-body loses the rest of that segment.

- `avformat/aviobuf: forward http reconnect options to nested opens` (all 
except `reconnect_at_eof`, because segment requests end at EOF)

Not covered: there is no FATE test, since FATE has no HTTP server that can drop 
a connection mid-body.

A 5-segment HLS VOD whose server closes the `seg2.ts` connection once halfway: 
455/504 frames before, 504/504 after with `-reconnect 1`, the retry carrying 
`Range: bytes=1270692-`. Without `-reconnect`, both give 455. Tested on Linux 
x86-64 with a local server.

Written with Claude Opus 5.5 in Claude Code; `Assisted-by` trailer on the 
commit.



>From b5f143807b354e06b79342b8af30aa7e11f02fd0 Mon Sep 17 00:00:00 2001
From: Julius Bairaktaris <[email protected]>
Date: Mon, 28 Sep 2026 02:00:14 +0200
Subject: [PATCH] avformat/aviobuf: forward http reconnect options to nested
 opens

ffio_copy_url_options() does not copy the reconnect options, so the hls,
dash and imf demuxers open their segments without them. A segment
connection that closes mid-body then ends the segment early, even with
-reconnect 1. Forward all reconnect options except reconnect_at_eof.
Segment requests end at EOF by design, so forwarding it would re-request
every segment after it is read.

Assisted-by: Claude Opus 5.5
Signed-off-by: Julius Bairaktaris <[email protected]>
---
 libavformat/aviobuf.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c
index edbbc5ffd6..eb898de229 100644
--- a/libavformat/aviobuf.c
+++ b/libavformat/aviobuf.c
@@ -953,7 +953,9 @@ void ffio_write_lines(AVIOContext *s, const unsigned char 
*buf, int size,
 int ffio_copy_url_options(AVIOContext* pb, AVDictionary** avio_opts)
 {
     const char *opts[] = {
-        "headers", "user_agent", "cookies", "http_proxy", "referer", 
"rw_timeout", "icy", "prefer_libcurl", NULL };
+        "headers", "user_agent", "cookies", "http_proxy", "referer", 
"rw_timeout", "icy", "prefer_libcurl",
+        "reconnect", "reconnect_streamed", "reconnect_on_network_error", 
"reconnect_on_http_error",
+        "reconnect_delay_max", "reconnect_max_retries", 
"reconnect_delay_total_max", NULL };
     const char **opt = opts;
     uint8_t *buf = NULL;
     int ret = 0;
-- 
2.54.0

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

Reply via email to