PR #24326 opened by michaelni URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24326 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24326.patch
Protocols that read from the network get a 256k AVIO buffer instead of the 32k default; local files and everything else keep 32k, and protocols that report a max_packet_size still get exactly one packet. Measured against the parent commit, 153M rust.webm, -c copy, n=12-100: local files, 241 small clips and the webm: no change (p >= 0.26) HTTP with Range, netem 300 Mbit/s 20 ms RTT: 4.761 -> 4.644 s (-2.5%, p=6e-8) HTTP with Range, netem 100 Mbit/s 40 ms RTT: 13.563 -> 13.334 s (-1.7%, p=1e-8) HTTP without Range, netem 300 Mbit/s 20 ms: 4.691 -> 4.649 s (-0.9%, p=4e-6) >From 71e30951e163275f78cb169cd30a523b8b4216af Mon Sep 17 00:00:00 2001 From: Michael Niedermayer <[email protected]> Date: Sun, 30 Aug 2026 04:38:54 +0200 Subject: [PATCH] avformat/avio: use a 256k I/O buffer for network protocols Protocols that read from the network get a 256k AVIO buffer instead of the 32k default; local files and everything else keep 32k, and protocols that report a max_packet_size still get exactly one packet. Measured against the parent commit, 153M rust.webm, -c copy, n=12-100: local files, 241 small clips and the webm: no change (p >= 0.26) HTTP with Range, netem 300 Mbit/s 20 ms RTT: 4.761 -> 4.644 s (-2.5%, p=6e-8) HTTP with Range, netem 100 Mbit/s 40 ms RTT: 13.563 -> 13.334 s (-1.7%, p=1e-8) HTTP without Range, netem 300 Mbit/s 20 ms: 4.691 -> 4.649 s (-0.9%, p=4e-6) --- libavformat/avio.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libavformat/avio.c b/libavformat/avio.c index 22b4948481..d49ca9f60c 100644 --- a/libavformat/avio.c +++ b/libavformat/avio.c @@ -38,6 +38,7 @@ #include "url.h" #define IO_BUFFER_SIZE 32768 +#define NETWORK_IO_BUFFER_SIZE 262144 /** @name Logging context. */ /*@{*/ @@ -476,6 +477,8 @@ int ffio_fdopen(AVIOContext **sp, URLContext *h) max_packet_size = h->max_packet_size; if (max_packet_size) { buffer_size = max_packet_size; /* no need to bufferize more than one packet */ + } else if (h->prot->flags & URL_PROTOCOL_FLAG_NETWORK) { + buffer_size = NETWORK_IO_BUFFER_SIZE; } else { buffer_size = IO_BUFFER_SIZE; } -- 2.52.0 _______________________________________________ ffmpeg-devel mailing list -- [email protected] To unsubscribe send an email to [email protected]
