* [FFmpeg-devel] [PATCH] avformat/file: respect pkt_size even in streaming mode (PR #21321)
@ 2025-12-30 17:11 Marton Balint via ffmpeg-devel
0 siblings, 0 replies; only message in thread
From: Marton Balint via ffmpeg-devel @ 2025-12-30 17:11 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Marton Balint
PR #21321 opened by Marton Balint (cus)
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21321
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21321.patch
Also clarify the documentation a bit.
Signed-off-by: Marton Balint <cus@passwd.hu>
>From 3c14b23663d09be291799af0b6a62dfe553a072a Mon Sep 17 00:00:00 2001
From: Marton Balint <cus@passwd.hu>
Date: Tue, 30 Dec 2025 02:36:04 +0100
Subject: [PATCH] avformat/file: respect pkt_size even in streaming mode
Also clarify the documentation a bit.
Signed-off-by: Marton Balint <cus@passwd.hu>
---
doc/protocols.texi | 12 +++++++-----
libavformat/file.c | 18 +++++++++++-------
2 files changed, 18 insertions(+), 12 deletions(-)
diff --git a/doc/protocols.texi b/doc/protocols.texi
index b5330a1160..350c52a465 100644
--- a/doc/protocols.texi
+++ b/doc/protocols.texi
@@ -354,13 +354,15 @@ overriding this might speed up opening certain files at the cost of losing some
features (e.g. accurate seeking).
@item pkt_size
-Set the maximum packet size used for file I/O.
+Set the maximum packet size used for file I/O. A smaller value may reduce
+memory usage. A higher value may increase throughput especially with networked
+filesystems.
-For writing, this sets the size of each write operation. The default is
-262144 bytes.
For reading, if explicitly set, it overrides the default internal buffer size
-(32768 bytes) and limits the maximum amount of data read per operation.
-Setting a smaller value may reduce memory usage when reading files sequentially.
+(32 KB) and limits the maximum amount of data read per operation.
+
+For writing, this sets the size of each write operation. The default is 256 KB
+for regular files, 32 KB otherwise.
@end table
@section ftp
diff --git a/libavformat/file.c b/libavformat/file.c
index 23dc7081d3..3ceddc8c25 100644
--- a/libavformat/file.c
+++ b/libavformat/file.c
@@ -312,14 +312,18 @@ static int file_open(URLContext *h, const char *filename, int flags)
h->is_streamed = !fstat(fd, &st) && S_ISFIFO(st.st_mode);
- /* Buffer writes more than the default 32k to improve throughput especially
- * with networked file systems */
- if (!h->is_streamed) {
- if (flags & AVIO_FLAG_WRITE)
- h->min_packet_size = h->max_packet_size = c->pkt_size ? c->pkt_size : 262144;
- else if (flags & AVIO_FLAG_READ && c->pkt_size)
- h->max_packet_size = c->pkt_size;
+ if (c->pkt_size) {
+ h->max_packet_size = c->pkt_size;
+ } else {
+ /* Buffer writes more than the default 32k to improve throughput especially
+ * with networked file systems */
+ if (!h->is_streamed && flags & AVIO_FLAG_WRITE)
+ h->max_packet_size = 262144;
}
+ /* Disable per-packet flushing by default to improve throughput especially
+ * with networked file systems */
+ if (!h->is_streamed && flags & AVIO_FLAG_WRITE)
+ h->min_packet_size = h->max_packet_size;
if (c->seekable >= 0)
h->is_streamed = !c->seekable;
--
2.49.1
_______________________________________________
ffmpeg-devel mailing list -- ffmpeg-devel@ffmpeg.org
To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2025-12-30 17:12 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-12-30 17:11 [FFmpeg-devel] [PATCH] avformat/file: respect pkt_size even in streaming mode (PR #21321) Marton Balint via ffmpeg-devel
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git