[FFmpeg-cvslog] avformat/udp: increase the default buffer size of a receiving socket to 384K

Marton Balint git at videolan.org
Sun Jan 26 00:28:28 EET 2020


ffmpeg | branch: master | Marton Balint <cus at passwd.hu> | Tue Jan 14 19:18:01 2020 +0100| [15d160cc0b23f531a3f7f3f4c9eb463b179227f3] | committer: Marton Balint

avformat/udp: increase the default buffer size of a receiving socket to 384K

It is a common mistake that people only increase fifo_size when they experience
drops, unfortunately this does not help for higher bitrate (> 100 Mbps) streams
when the reader thread simply might not receive the packets in time (especially
under high CPU load) if the default 64 KB of kernel buffer size is used.

New default is determined so that common linux systems can set this buffer size
without tuning kernel parameters.

Signed-off-by: Marton Balint <cus at passwd.hu>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=15d160cc0b23f531a3f7f3f4c9eb463b179227f3
---

 doc/protocols.texi | 2 +-
 libavformat/udp.c  | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/doc/protocols.texi b/doc/protocols.texi
index d2935fc666..5e8c97d164 100644
--- a/doc/protocols.texi
+++ b/doc/protocols.texi
@@ -1653,7 +1653,7 @@ The list of supported options follows.
 @item buffer_size=@var{size}
 Set the UDP maximum socket buffer size in bytes. This is used to set either
 the receive or send buffer size, depending on what the socket is used for.
-Default is 64KB.  See also @var{fifo_size}.
+Default is 32 KB for output, 384 KB for input.  See also @var{fifo_size}.
 
 @item bitrate=@var{bitrate}
 If set to nonzero, the output will have the specified constant bitrate if the
diff --git a/libavformat/udp.c b/libavformat/udp.c
index 7e59d51cc6..dce4cf76c7 100644
--- a/libavformat/udp.c
+++ b/libavformat/udp.c
@@ -71,6 +71,7 @@
 #endif
 
 #define UDP_TX_BUF_SIZE 32768
+#define UDP_RX_BUF_SIZE 393216
 #define UDP_MAX_PKT_SIZE 65536
 #define UDP_HEADER_SIZE 8
 
@@ -636,7 +637,7 @@ static int udp_open(URLContext *h, const char *uri, int flags)
 
     is_output = !(flags & AVIO_FLAG_READ);
     if (s->buffer_size < 0)
-        s->buffer_size = is_output ? UDP_TX_BUF_SIZE : UDP_MAX_PKT_SIZE;
+        s->buffer_size = is_output ? UDP_TX_BUF_SIZE : UDP_RX_BUF_SIZE;
 
     if (s->sources) {
         if (ff_ip_parse_sources(h, s->sources, &s->filters) < 0)



More information about the ffmpeg-cvslog mailing list