[PATCH 1/1] add option in file.c: pkt_size to set max_packet_size
From: yangsen5 <1441923451@qq.com> Signed-off-by: yangsen5 <1441923451@qq.com> --- libavformat/file.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libavformat/file.c b/libavformat/file.c index 6a66040b65..8099a7e931 100644 --- a/libavformat/file.c +++ b/libavformat/file.c @@ -94,6 +94,7 @@ typedef struct FileContext { int fd; int trunc; int blocksize; + int pkt_size; int follow; int seekable; #if HAVE_DIRENT_H @@ -106,6 +107,7 @@ static const AVOption file_options[] = { { "blocksize", "set I/O operation maximum block size", offsetof(FileContext, blocksize), AV_OPT_TYPE_INT, { .i64 = INT_MAX }, 1, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM }, { "follow", "Follow a file as it is being written", offsetof(FileContext, follow), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, AV_OPT_FLAG_DECODING_PARAM }, { "seekable", "Sets if the file is seekable", offsetof(FileContext, seekable), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 0, AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_ENCODING_PARAM }, + { "pkt_size", "Maximum file packet size", offsetof(FileContext, pkt_size), AV_OPT_TYPE_INT, { .i64 = 262144 }, -1, INT_MAX, AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_ENCODING_PARAM }, { NULL } }; @@ -313,7 +315,7 @@ static int file_open(URLContext *h, const char *filename, int flags) /* Buffer writes more than the default 32k to improve throughput especially * with networked file systems */ if (!h->is_streamed && flags & AVIO_FLAG_WRITE) - h->min_packet_size = h->max_packet_size = 262144; + h->min_packet_size = h->max_packet_size = c->pkt_size; if (c->seekable >= 0) h->is_streamed = !c->seekable; -- 2.34.1
On 2025-07-17 07:35 pm, yangsen5 via ffmpeg-devel wrote:
From: yangsen5 <1441923451@qq.com>
Signed-off-by: yangsen5 <1441923451@qq.com> --- libavformat/file.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/libavformat/file.c b/libavformat/file.c index 6a66040b65..8099a7e931 100644 --- a/libavformat/file.c +++ b/libavformat/file.c @@ -94,6 +94,7 @@ typedef struct FileContext { int fd; int trunc; int blocksize; + int pkt_size; int follow; int seekable; #if HAVE_DIRENT_H @@ -106,6 +107,7 @@ static const AVOption file_options[] = { { "blocksize", "set I/O operation maximum block size", offsetof(FileContext, blocksize), AV_OPT_TYPE_INT, { .i64 = INT_MAX }, 1, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM }, { "follow", "Follow a file as it is being written", offsetof(FileContext, follow), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, AV_OPT_FLAG_DECODING_PARAM }, { "seekable", "Sets if the file is seekable", offsetof(FileContext, seekable), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 0, AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_ENCODING_PARAM }, + { "pkt_size", "Maximum file packet size", offsetof(FileContext, pkt_size), AV_OPT_TYPE_INT, { .i64 = 262144 }, -1, INT_MAX, AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_ENCODING_PARAM },
I see naive assignment of the value in avio*.c What happens if someone sets the value to -1? Regards, Gyan
On Jul 17, 2025, at 22:05, yangsen5 via ffmpeg-devel <ffmpeg-devel@ffmpeg.org> wrote:
From: yangsen5 <1441923451@qq.com>
Signed-off-by: yangsen5 <1441923451@qq.com> --- libavformat/file.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/libavformat/file.c b/libavformat/file.c index 6a66040b65..8099a7e931 100644 --- a/libavformat/file.c +++ b/libavformat/file.c @@ -94,6 +94,7 @@ typedef struct FileContext { int fd; int trunc; int blocksize; + int pkt_size; int follow; int seekable; #if HAVE_DIRENT_H @@ -106,6 +107,7 @@ static const AVOption file_options[] = { { "blocksize", "set I/O operation maximum block size", offsetof(FileContext, blocksize), AV_OPT_TYPE_INT, { .i64 = INT_MAX }, 1, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM }, { "follow", "Follow a file as it is being written", offsetof(FileContext, follow), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, AV_OPT_FLAG_DECODING_PARAM }, { "seekable", "Sets if the file is seekable", offsetof(FileContext, seekable), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 0, AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_ENCODING_PARAM }, + { "pkt_size", "Maximum file packet size", offsetof(FileContext, pkt_size), AV_OPT_TYPE_INT, { .i64 = 262144 }, -1, INT_MAX, AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_ENCODING_PARAM }, { NULL } };
@@ -313,7 +315,7 @@ static int file_open(URLContext *h, const char *filename, int flags) /* Buffer writes more than the default 32k to improve throughput especially * with networked file systems */ if (!h->is_streamed && flags & AVIO_FLAG_WRITE) - h->min_packet_size = h->max_packet_size = 262144; + h->min_packet_size = h->max_packet_size = c->pkt_size;
What's the use case?
if (c->seekable >= 0) h->is_streamed = !c->seekable; -- 2.34.1
_______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
1+1=10 1441923451@qq.com This modification references the max_packet_size assignment method in other protocols, such as the one in udp.c; This operation not only maintains the original setting but also adds custom settings; For example, when reading a local file, you can first set pkt_size using av_dict_set and then pass the option in avio_open2; This is mainly to deal with the situation where the IoT device has small memory, so that max_packet_size can be customized; > On Jul 17, 2025, at 22:05, yangsen5 via ffmpeg-devel <ffmpeg-devel@ffmpeg.org> wrote: > > From: yangsen5 <1441923451@qq.com> > > Signed-off-by: yangsen5 <1441923451@qq.com> > --- > libavformat/file.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/libavformat/file.c b/libavformat/file.c > index 6a66040b65..8099a7e931 100644 > --- a/libavformat/file.c > +++ b/libavformat/file.c > @@ -94,6 +94,7 @@ typedef struct FileContext { > int fd; > int trunc; > int blocksize; > + int pkt_size; > int follow; > int seekable; > #if HAVE_DIRENT_H > @@ -106,6 +107,7 @@ static const AVOption file_options[] = { > { "blocksize", "set I/O operation maximum block size", offsetof(FileContext, blocksize), AV_OPT_TYPE_INT, { .i64 = INT_MAX }, 1, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM }, > { "follow", "Follow a file as it is being written", offsetof(FileContext, follow), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, AV_OPT_FLAG_DECODING_PARAM }, > { "seekable", "Sets if the file is seekable", offsetof(FileContext, seekable), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 0, AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_ENCODING_PARAM }, > + { "pkt_size", "Maximum file packet size", offsetof(FileContext, pkt_size), AV_OPT_TYPE_INT, { .i64 = 262144 }, -1, INT_MAX, AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_ENCODING_PARAM }, > { NULL } > }; > > @@ -313,7 +315,7 @@ static int file_open(URLContext *h, const char *filename, int flags) > /* Buffer writes more than the default 32k to improve throughput especially > * with networked file systems */ > if (!h->is_streamed && flags & AVIO_FLAG_WRITE) > - h->min_packet_size = h->max_packet_size = 262144; > + h->min_packet_size = h->max_packet_size = c->pkt_size; What's the use case? > > if (c->seekable >= 0) > h->is_streamed = !c->seekable; > -- > 2.34.1 > 原始邮件 发件人:Zhao Zhili <quinkblack@foxmail.com> 发件时间:2025年7月17日 23:01 收件人:FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org> 抄送:1441923451 <1441923451@qq.com> 主题:Re: [FFmpeg-devel] [PATCH 1/1] add option in file.c: pkt_size to setmax_packet_size > On Jul 17, 2025, at 22:05, yangsen5 via ffmpeg-devel <ffmpeg-devel@ffmpeg.org> wrote: > > From: yangsen5 <1441923451@qq.com> > > Signed-off-by: yangsen5 <1441923451@qq.com> > --- > libavformat/file.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/libavformat/file.c b/libavformat/file.c > index 6a66040b65..8099a7e931 100644 > --- a/libavformat/file.c > +++ b/libavformat/file.c > @@ -94,6 +94,7 @@ typedef struct FileContext { > int fd; > int trunc; > int blocksize; > + int pkt_size; > int follow; > int seekable; > #if HAVE_DIRENT_H > @@ -106,6 +107,7 @@ static const AVOption file_options[] = { > { "blocksize", "set I/O operation maximum block size", offsetof(FileContext, blocksize), AV_OPT_TYPE_INT, { .i64 = INT_MAX }, 1, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM }, > { "follow", "Follow a file as it is being written", offsetof(FileContext, follow), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, AV_OPT_FLAG_DECODING_PARAM }, > { "seekable", "Sets if the file is seekable", offsetof(FileContext, seekable), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 0, AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_ENCODING_PARAM }, > + { "pkt_size", "Maximum file packet size", offsetof(FileContext, pkt_size), AV_OPT_TYPE_INT, { .i64 = 262144 }, -1, INT_MAX, AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_ENCODING_PARAM }, > { NULL } > }; > > @@ -313,7 +315,7 @@ static int file_open(URLContext *h, const char *filename, int flags) > /* Buffer writes more than the default 32k to improve throughput especially > * with networked file systems */ > if (!h->is_streamed && flags & AVIO_FLAG_WRITE) > - h->min_packet_size = h->max_packet_size = 262144; > + h->min_packet_size = h->max_packet_size = c->pkt_size; What's the use case? > > if (c->seekable >= 0) > h->is_streamed = !c->seekable; > -- > 2.34.1 > > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
This modification references the max_packet_size assignment method in other protocols, such as the one in udp.c; This operation not only maintains the original setting but also adds custom settings; For example, when reading a local file, you can first set pkt_size using av_dict_set and then pass the option in avio_open2; This is mainly to deal with the situation where the IoT device has small memory, so that max_packet_size can be customized; > --- > libavformat/file.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/libavformat/file.c b/libavformat/file.c > index 6a66040b65..8099a7e931 100644 > --- a/libavformat/file.c > +++ b/libavformat/file.c > @@ -94,6 +94,7 @@ typedef struct FileContext { > int fd; > int trunc; > int blocksize; > + int pkt_size; > int follow; > int seekable; > #if HAVE_DIRENT_H > @@ -106,6 +107,7 @@ static const AVOption file_options[] = { > { "blocksize", "set I/O operation maximum block size", offsetof(FileContext, blocksize), AV_OPT_TYPE_INT, { .i64 = INT_MAX }, 1, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM }, > { "follow", "Follow a file as it is being written", offsetof(FileContext, follow), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, AV_OPT_FLAG_DECODING_PARAM }, > { "seekable", "Sets if the file is seekable", offsetof(FileContext, seekable), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 0, AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_ENCODING_PARAM }, > + { "pkt_size", "Maximum file packet size", offsetof(FileContext, pkt_size), AV_OPT_TYPE_INT, { .i64 = 262144 }, -1, INT_MAX, AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_ENCODING_PARAM }, > { NULL } > }; > > @@ -313,7 +315,7 @@ static int file_open(URLContext *h, const char *filename, int flags) > /* Buffer writes more than the default 32k to improve throughput especially > * with networked file systems */ > if (!h->is_streamed && flags & AVIO_FLAG_WRITE) > - h->min_packet_size = h->max_packet_size = 262144; > + h->min_packet_size = h->max_packet_size = c->pkt_size; What's the use case? 1+1=10 1441923451@qq.com 原始邮件 发件人:Zhao Zhili <quinkblack@foxmail.com> 发件时间:2025年7月17日 23:01 收件人:FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org> 抄送:1441923451 <1441923451@qq.com> 主题:Re: [FFmpeg-devel] [PATCH 1/1] add option in file.c: pkt_size to setmax_packet_size > On Jul 17, 2025, at 22:05, yangsen5 via ffmpeg-devel <ffmpeg-devel@ffmpeg.org> wrote: > > From: yangsen5 <1441923451@qq.com> > > Signed-off-by: yangsen5 <1441923451@qq.com> > --- > libavformat/file.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/libavformat/file.c b/libavformat/file.c > index 6a66040b65..8099a7e931 100644 > --- a/libavformat/file.c > +++ b/libavformat/file.c > @@ -94,6 +94,7 @@ typedef struct FileContext { > int fd; > int trunc; > int blocksize; > + int pkt_size; > int follow; > int seekable; > #if HAVE_DIRENT_H > @@ -106,6 +107,7 @@ static const AVOption file_options[] = { > { "blocksize", "set I/O operation maximum block size", offsetof(FileContext, blocksize), AV_OPT_TYPE_INT, { .i64 = INT_MAX }, 1, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM }, > { "follow", "Follow a file as it is being written", offsetof(FileContext, follow), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, AV_OPT_FLAG_DECODING_PARAM }, > { "seekable", "Sets if the file is seekable", offsetof(FileContext, seekable), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 0, AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_ENCODING_PARAM }, > + { "pkt_size", "Maximum file packet size", offsetof(FileContext, pkt_size), AV_OPT_TYPE_INT, { .i64 = 262144 }, -1, INT_MAX, AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_ENCODING_PARAM }, > { NULL } > }; > > @@ -313,7 +315,7 @@ static int file_open(URLContext *h, const char *filename, int flags) > /* Buffer writes more than the default 32k to improve throughput especially > * with networked file systems */ > if (!h->is_streamed && flags & AVIO_FLAG_WRITE) > - h->min_packet_size = h->max_packet_size = 262144; > + h->min_packet_size = h->max_packet_size = c->pkt_size; What's the use case? > > if (c->seekable >= 0) > h->is_streamed = !c->seekable; > -- > 2.34.1 > > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
From: yangsen5 <1441923451@qq.com> Signed-off-by: yangsen5 <1441923451@qq.com> --- libavformat/file.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libavformat/file.c b/libavformat/file.c index 6a66040b65..856a6cbd0a 100644 --- a/libavformat/file.c +++ b/libavformat/file.c @@ -94,6 +94,7 @@ typedef struct FileContext { int fd; int trunc; int blocksize; + int pkt_size; int follow; int seekable; #if HAVE_DIRENT_H @@ -106,6 +107,7 @@ static const AVOption file_options[] = { { "blocksize", "set I/O operation maximum block size", offsetof(FileContext, blocksize), AV_OPT_TYPE_INT, { .i64 = INT_MAX }, 1, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM }, { "follow", "Follow a file as it is being written", offsetof(FileContext, follow), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, AV_OPT_FLAG_DECODING_PARAM }, { "seekable", "Sets if the file is seekable", offsetof(FileContext, seekable), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 0, AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_ENCODING_PARAM }, + { "pkt_size", "Maximum file packet size", offsetof(FileContext, pkt_size), AV_OPT_TYPE_INT, { .i64 = 262144 }, 1, INT_MAX, AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_ENCODING_PARAM }, { NULL } }; @@ -313,7 +315,7 @@ static int file_open(URLContext *h, const char *filename, int flags) /* Buffer writes more than the default 32k to improve throughput especially * with networked file systems */ if (!h->is_streamed && flags & AVIO_FLAG_WRITE) - h->min_packet_size = h->max_packet_size = 262144; + h->min_packet_size = h->max_packet_size = c->pkt_size; if (c->seekable >= 0) h->is_streamed = !c->seekable; -- 2.34.1
On Jul 31, 2025, at 17:05, yangsen5 via ffmpeg-devel <ffmpeg-devel@ffmpeg.org> wrote:
From: yangsen5 <1441923451@qq.com>
Signed-off-by: yangsen5 <1441923451@qq.com> --- libavformat/file.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/libavformat/file.c b/libavformat/file.c index 6a66040b65..856a6cbd0a 100644 --- a/libavformat/file.c +++ b/libavformat/file.c @@ -94,6 +94,7 @@ typedef struct FileContext { int fd; int trunc; int blocksize; + int pkt_size; int follow; int seekable; #if HAVE_DIRENT_H @@ -106,6 +107,7 @@ static const AVOption file_options[] = { { "blocksize", "set I/O operation maximum block size", offsetof(FileContext, blocksize), AV_OPT_TYPE_INT, { .i64 = INT_MAX }, 1, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM }, { "follow", "Follow a file as it is being written", offsetof(FileContext, follow), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, AV_OPT_FLAG_DECODING_PARAM }, { "seekable", "Sets if the file is seekable", offsetof(FileContext, seekable), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 0, AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_ENCODING_PARAM }, + { "pkt_size", "Maximum file packet size", offsetof(FileContext, pkt_size), AV_OPT_TYPE_INT, { .i64 = 262144 }, 1, INT_MAX, AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_ENCODING_PARAM }, { NULL } };
@@ -313,7 +315,7 @@ static int file_open(URLContext *h, const char *filename, int flags) /* Buffer writes more than the default 32k to improve throughput especially * with networked file systems */ if (!h->is_streamed && flags & AVIO_FLAG_WRITE) - h->min_packet_size = h->max_packet_size = 262144; + h->min_packet_size = h->max_packet_size = c->pkt_size;
if (c->seekable >= 0) h->is_streamed = !c->seekable; --
Pushed after rewords on the commit message.
participants (4)
-
1+1=10 -
1441923451@qq.com -
Gyan Doshi -
Zhao Zhili