Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH 1/1] add option in file.c: pkt_size to set max_packet_size
@ 2025-07-17 14:05 yangsen5 via ffmpeg-devel
  2025-07-17 14:27 ` Gyan Doshi
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: yangsen5 via ffmpeg-devel @ 2025-07-17 14:05 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: 1441923451

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

_______________________________________________
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".

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [FFmpeg-devel] [PATCH 1/1] add option in file.c: pkt_size to set max_packet_size
  2025-07-17 14:05 [FFmpeg-devel] [PATCH 1/1] add option in file.c: pkt_size to set max_packet_size yangsen5 via ffmpeg-devel
@ 2025-07-17 14:27 ` Gyan Doshi
       [not found]   ` <tencent_F5DB935EB016EAA13A72B320FCBC9331010A@qq.com>
  2025-07-17 15:01 ` [FFmpeg-devel] [PATCH 1/1] add option in file.c: pkt_size to set max_packet_size Zhao Zhili
  2025-07-31  9:05 ` [FFmpeg-devel] [PATCH] add option in file.c: pkt_size to set max_packet_size yangsen5 via ffmpeg-devel
  2 siblings, 1 reply; 7+ messages in thread
From: Gyan Doshi @ 2025-07-17 14:27 UTC (permalink / raw)
  To: ffmpeg-devel



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


_______________________________________________
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".

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [FFmpeg-devel] [PATCH 1/1] add option in file.c: pkt_size to set max_packet_size
  2025-07-17 14:05 [FFmpeg-devel] [PATCH 1/1] add option in file.c: pkt_size to set max_packet_size yangsen5 via ffmpeg-devel
  2025-07-17 14:27 ` Gyan Doshi
@ 2025-07-17 15:01 ` Zhao Zhili
  2025-07-31  5:16   ` [FFmpeg-devel] [PATCH 1/1] add option in file.c: pkt_size to setmax_packet_size 1+1=10 via ffmpeg-devel
  2025-07-31  5:47   ` 1+1=10 via ffmpeg-devel
  2025-07-31  9:05 ` [FFmpeg-devel] [PATCH] add option in file.c: pkt_size to set max_packet_size yangsen5 via ffmpeg-devel
  2 siblings, 2 replies; 7+ messages in thread
From: Zhao Zhili @ 2025-07-17 15:01 UTC (permalink / raw)
  To: FFmpeg development discussions and patches; +Cc: 1441923451



> 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".

_______________________________________________
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".

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [FFmpeg-devel] [PATCH 1/1] add option in file.c: pkt_size to setmax_packet_size
  2025-07-17 15:01 ` [FFmpeg-devel] [PATCH 1/1] add option in file.c: pkt_size to set max_packet_size Zhao Zhili
@ 2025-07-31  5:16   ` 1+1=10 via ffmpeg-devel
  2025-07-31  5:47   ` 1+1=10 via ffmpeg-devel
  1 sibling, 0 replies; 7+ messages in thread
From: 1+1=10 via ffmpeg-devel @ 2025-07-31  5:16 UTC (permalink / raw)
  To: Zhao Zhili, FFmpeg development discussions and patches; +Cc: 1+1=10

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;






&gt;&nbsp;On&nbsp;Jul&nbsp;17,&nbsp;2025,&nbsp;at&nbsp;22:05,&nbsp;yangsen5&nbsp;via&nbsp;ffmpeg-devel&nbsp;<ffmpeg-devel@ffmpeg.org&gt;&nbsp;wrote:
&gt;&nbsp;
&gt;&nbsp;From:&nbsp;yangsen5&nbsp;<1441923451@qq.com&gt;
&gt;&nbsp;
&gt;&nbsp;Signed-off-by:&nbsp;yangsen5&nbsp;<1441923451@qq.com&gt;
&gt;&nbsp;---
&gt;&nbsp;libavformat/file.c&nbsp;|&nbsp;4&nbsp;+++-
&gt;&nbsp;1&nbsp;file&nbsp;changed,&nbsp;3&nbsp;insertions(+),&nbsp;1&nbsp;deletion(-)
&gt;&nbsp;
&gt;&nbsp;diff&nbsp;--git&nbsp;a/libavformat/file.c&nbsp;b/libavformat/file.c
&gt;&nbsp;index&nbsp;6a66040b65..8099a7e931&nbsp;100644
&gt;&nbsp;---&nbsp;a/libavformat/file.c
&gt;&nbsp;+++&nbsp;b/libavformat/file.c
&gt;&nbsp;@@&nbsp;-94,6&nbsp;+94,7&nbsp;@@&nbsp;typedef&nbsp;struct&nbsp;FileContext&nbsp;{
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;int&nbsp;fd;
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;int&nbsp;trunc;
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;int&nbsp;blocksize;
&gt;&nbsp;+&nbsp;&nbsp;&nbsp;&nbsp;int&nbsp;pkt_size;
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;int&nbsp;follow;
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;int&nbsp;seekable;
&gt;&nbsp;#if&nbsp;HAVE_DIRENT_H
&gt;&nbsp;@@&nbsp;-106,6&nbsp;+107,7&nbsp;@@&nbsp;static&nbsp;const&nbsp;AVOption&nbsp;file_options[]&nbsp;=&nbsp;{
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;"blocksize",&nbsp;"set&nbsp;I/O&nbsp;operation&nbsp;maximum&nbsp;block&nbsp;size",&nbsp;offsetof(FileContext,&nbsp;blocksize),&nbsp;AV_OPT_TYPE_INT,&nbsp;{&nbsp;.i64&nbsp;=&nbsp;INT_MAX&nbsp;},&nbsp;1,&nbsp;INT_MAX,&nbsp;AV_OPT_FLAG_ENCODING_PARAM&nbsp;},
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;"follow",&nbsp;"Follow&nbsp;a&nbsp;file&nbsp;as&nbsp;it&nbsp;is&nbsp;being&nbsp;written",&nbsp;offsetof(FileContext,&nbsp;follow),&nbsp;AV_OPT_TYPE_INT,&nbsp;{&nbsp;.i64&nbsp;=&nbsp;0&nbsp;},&nbsp;0,&nbsp;1,&nbsp;AV_OPT_FLAG_DECODING_PARAM&nbsp;},
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;"seekable",&nbsp;"Sets&nbsp;if&nbsp;the&nbsp;file&nbsp;is&nbsp;seekable",&nbsp;offsetof(FileContext,&nbsp;seekable),&nbsp;AV_OPT_TYPE_INT,&nbsp;{&nbsp;.i64&nbsp;=&nbsp;-1&nbsp;},&nbsp;-1,&nbsp;0,&nbsp;AV_OPT_FLAG_DECODING_PARAM&nbsp;|&nbsp;AV_OPT_FLAG_ENCODING_PARAM&nbsp;},
&gt;&nbsp;+&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;"pkt_size",&nbsp;"Maximum&nbsp;file&nbsp;packet&nbsp;size",&nbsp;offsetof(FileContext,&nbsp;pkt_size),&nbsp;AV_OPT_TYPE_INT,&nbsp;{&nbsp;.i64&nbsp;=&nbsp;262144&nbsp;},&nbsp;-1,&nbsp;INT_MAX,&nbsp;AV_OPT_FLAG_DECODING_PARAM&nbsp;|&nbsp;AV_OPT_FLAG_ENCODING_PARAM&nbsp;},
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;NULL&nbsp;}
&gt;&nbsp;};
&gt;&nbsp;
&gt;&nbsp;@@&nbsp;-313,7&nbsp;+315,7&nbsp;@@&nbsp;static&nbsp;int&nbsp;file_open(URLContext&nbsp;*h,&nbsp;const&nbsp;char&nbsp;*filename,&nbsp;int&nbsp;flags)
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/*&nbsp;Buffer&nbsp;writes&nbsp;more&nbsp;than&nbsp;the&nbsp;default&nbsp;32k&nbsp;to&nbsp;improve&nbsp;throughput&nbsp;especially
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;with&nbsp;networked&nbsp;file&nbsp;systems&nbsp;*/
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(!h-&gt;is_streamed&nbsp;&amp;&amp;&nbsp;flags&nbsp;&amp;&nbsp;AVIO_FLAG_WRITE)
&gt;&nbsp;-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;h-&gt;min_packet_size&nbsp;=&nbsp;h-&gt;max_packet_size&nbsp;=&nbsp;262144;
&gt;&nbsp;+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;h-&gt;min_packet_size&nbsp;=&nbsp;h-&gt;max_packet_size&nbsp;=&nbsp;c-&gt;pkt_size;

What's&nbsp;the&nbsp;use&nbsp;case?

&gt;&nbsp;
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(c-&gt;seekable&nbsp;&gt;=&nbsp;0)
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;h-&gt;is_streamed&nbsp;=&nbsp;!c-&gt;seekable;
&gt;&nbsp;--&nbsp;
&gt;&nbsp;2.34.1
&gt;&nbsp;




         原始邮件
         
       
发件人:Zhao Zhili <quinkblack@foxmail.com&gt;
发件时间:2025年7月17日 23:01
收件人:FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org&gt;
抄送:1441923451 <1441923451@qq.com&gt;
主题:Re: [FFmpeg-devel] [PATCH 1/1] add option in file.c: pkt_size to setmax_packet_size





&gt;&nbsp;On&nbsp;Jul&nbsp;17,&nbsp;2025,&nbsp;at&nbsp;22:05,&nbsp;yangsen5&nbsp;via&nbsp;ffmpeg-devel&nbsp;<ffmpeg-devel@ffmpeg.org&gt;&nbsp;wrote:
&gt;&nbsp;
&gt;&nbsp;From:&nbsp;yangsen5&nbsp;<1441923451@qq.com&gt;
&gt;&nbsp;
&gt;&nbsp;Signed-off-by:&nbsp;yangsen5&nbsp;<1441923451@qq.com&gt;
&gt;&nbsp;---
&gt;&nbsp;libavformat/file.c&nbsp;|&nbsp;4&nbsp;+++-
&gt;&nbsp;1&nbsp;file&nbsp;changed,&nbsp;3&nbsp;insertions(+),&nbsp;1&nbsp;deletion(-)
&gt;&nbsp;
&gt;&nbsp;diff&nbsp;--git&nbsp;a/libavformat/file.c&nbsp;b/libavformat/file.c
&gt;&nbsp;index&nbsp;6a66040b65..8099a7e931&nbsp;100644
&gt;&nbsp;---&nbsp;a/libavformat/file.c
&gt;&nbsp;+++&nbsp;b/libavformat/file.c
&gt;&nbsp;@@&nbsp;-94,6&nbsp;+94,7&nbsp;@@&nbsp;typedef&nbsp;struct&nbsp;FileContext&nbsp;{
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;int&nbsp;fd;
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;int&nbsp;trunc;
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;int&nbsp;blocksize;
&gt;&nbsp;+&nbsp;&nbsp;&nbsp;&nbsp;int&nbsp;pkt_size;
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;int&nbsp;follow;
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;int&nbsp;seekable;
&gt;&nbsp;#if&nbsp;HAVE_DIRENT_H
&gt;&nbsp;@@&nbsp;-106,6&nbsp;+107,7&nbsp;@@&nbsp;static&nbsp;const&nbsp;AVOption&nbsp;file_options[]&nbsp;=&nbsp;{
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;"blocksize",&nbsp;"set&nbsp;I/O&nbsp;operation&nbsp;maximum&nbsp;block&nbsp;size",&nbsp;offsetof(FileContext,&nbsp;blocksize),&nbsp;AV_OPT_TYPE_INT,&nbsp;{&nbsp;.i64&nbsp;=&nbsp;INT_MAX&nbsp;},&nbsp;1,&nbsp;INT_MAX,&nbsp;AV_OPT_FLAG_ENCODING_PARAM&nbsp;},
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;"follow",&nbsp;"Follow&nbsp;a&nbsp;file&nbsp;as&nbsp;it&nbsp;is&nbsp;being&nbsp;written",&nbsp;offsetof(FileContext,&nbsp;follow),&nbsp;AV_OPT_TYPE_INT,&nbsp;{&nbsp;.i64&nbsp;=&nbsp;0&nbsp;},&nbsp;0,&nbsp;1,&nbsp;AV_OPT_FLAG_DECODING_PARAM&nbsp;},
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;"seekable",&nbsp;"Sets&nbsp;if&nbsp;the&nbsp;file&nbsp;is&nbsp;seekable",&nbsp;offsetof(FileContext,&nbsp;seekable),&nbsp;AV_OPT_TYPE_INT,&nbsp;{&nbsp;.i64&nbsp;=&nbsp;-1&nbsp;},&nbsp;-1,&nbsp;0,&nbsp;AV_OPT_FLAG_DECODING_PARAM&nbsp;|&nbsp;AV_OPT_FLAG_ENCODING_PARAM&nbsp;},
&gt;&nbsp;+&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;"pkt_size",&nbsp;"Maximum&nbsp;file&nbsp;packet&nbsp;size",&nbsp;offsetof(FileContext,&nbsp;pkt_size),&nbsp;AV_OPT_TYPE_INT,&nbsp;{&nbsp;.i64&nbsp;=&nbsp;262144&nbsp;},&nbsp;-1,&nbsp;INT_MAX,&nbsp;AV_OPT_FLAG_DECODING_PARAM&nbsp;|&nbsp;AV_OPT_FLAG_ENCODING_PARAM&nbsp;},
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;NULL&nbsp;}
&gt;&nbsp;};
&gt;&nbsp;
&gt;&nbsp;@@&nbsp;-313,7&nbsp;+315,7&nbsp;@@&nbsp;static&nbsp;int&nbsp;file_open(URLContext&nbsp;*h,&nbsp;const&nbsp;char&nbsp;*filename,&nbsp;int&nbsp;flags)
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/*&nbsp;Buffer&nbsp;writes&nbsp;more&nbsp;than&nbsp;the&nbsp;default&nbsp;32k&nbsp;to&nbsp;improve&nbsp;throughput&nbsp;especially
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;with&nbsp;networked&nbsp;file&nbsp;systems&nbsp;*/
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(!h-&gt;is_streamed&nbsp;&amp;&amp;&nbsp;flags&nbsp;&amp;&nbsp;AVIO_FLAG_WRITE)
&gt;&nbsp;-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;h-&gt;min_packet_size&nbsp;=&nbsp;h-&gt;max_packet_size&nbsp;=&nbsp;262144;
&gt;&nbsp;+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;h-&gt;min_packet_size&nbsp;=&nbsp;h-&gt;max_packet_size&nbsp;=&nbsp;c-&gt;pkt_size;

What's&nbsp;the&nbsp;use&nbsp;case?

&gt;&nbsp;
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(c-&gt;seekable&nbsp;&gt;=&nbsp;0)
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;h-&gt;is_streamed&nbsp;=&nbsp;!c-&gt;seekable;
&gt;&nbsp;--&nbsp;
&gt;&nbsp;2.34.1
&gt;&nbsp;
&gt;&nbsp;_______________________________________________
&gt;&nbsp;ffmpeg-devel&nbsp;mailing&nbsp;list
&gt;&nbsp;ffmpeg-devel@ffmpeg.org
&gt;&nbsp;https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
&gt;&nbsp;
&gt;&nbsp;To&nbsp;unsubscribe,&nbsp;visit&nbsp;link&nbsp;above,&nbsp;or&nbsp;email
&gt;&nbsp;ffmpeg-devel-request@ffmpeg.org&nbsp;with&nbsp;subject&nbsp;"unsubscribe".
_______________________________________________
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".

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [FFmpeg-devel] [PATCH 1/1] add option in file.c: pkt_size to setmax_packet_size
  2025-07-17 15:01 ` [FFmpeg-devel] [PATCH 1/1] add option in file.c: pkt_size to set max_packet_size Zhao Zhili
  2025-07-31  5:16   ` [FFmpeg-devel] [PATCH 1/1] add option in file.c: pkt_size to setmax_packet_size 1+1=10 via ffmpeg-devel
@ 2025-07-31  5:47   ` 1+1=10 via ffmpeg-devel
  1 sibling, 0 replies; 7+ messages in thread
From: 1+1=10 via ffmpeg-devel @ 2025-07-31  5:47 UTC (permalink / raw)
  To: Zhao Zhili, FFmpeg development discussions and patches; +Cc: 1+1=10

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;


&gt; ---
&gt; libavformat/file.c | 4 +++-
&gt; 1 file changed, 3 insertions(+), 1 deletion(-)
&gt;&nbsp;
&gt; diff --git a/libavformat/file.c b/libavformat/file.c
&gt; index 6a66040b65..8099a7e931 100644
&gt; --- a/libavformat/file.c
&gt; +++ b/libavformat/file.c
&gt; @@ -94,6 +94,7 @@ typedef struct FileContext {
&gt; &nbsp; &nbsp; int fd;
&gt; &nbsp; &nbsp; int trunc;
&gt; &nbsp; &nbsp; int blocksize;
&gt; + &nbsp; &nbsp;int pkt_size;
&gt; &nbsp; &nbsp; int follow;
&gt; &nbsp; &nbsp; int seekable;
&gt; #if HAVE_DIRENT_H
&gt; @@ -106,6 +107,7 @@ static const AVOption file_options[] = {
&gt; &nbsp; &nbsp; { "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 },
&gt; &nbsp; &nbsp; { "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 },
&gt; &nbsp; &nbsp; { "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 },
&gt; + &nbsp; &nbsp;{ "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 },
&gt; &nbsp; &nbsp; { NULL }
&gt; };
&gt;&nbsp;
&gt; @@ -313,7 +315,7 @@ static int file_open(URLContext *h, const char *filename, int flags)
&gt; &nbsp; &nbsp; /* Buffer writes more than the default 32k to improve throughput especially
&gt; &nbsp; &nbsp; &nbsp;* with networked file systems */
&gt; &nbsp; &nbsp; if (!h-&gt;is_streamed &amp;&amp; flags &amp; AVIO_FLAG_WRITE)
&gt; - &nbsp; &nbsp; &nbsp; &nbsp;h-&gt;min_packet_size = h-&gt;max_packet_size = 262144;
&gt; + &nbsp; &nbsp; &nbsp; &nbsp;h-&gt;min_packet_size = h-&gt;max_packet_size = c-&gt;pkt_size;


What's the use case?




1+1=10
1441923451@qq.com



        



         原始邮件
         
       
发件人:Zhao Zhili <quinkblack@foxmail.com&gt;
发件时间:2025年7月17日 23:01
收件人:FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org&gt;
抄送:1441923451 <1441923451@qq.com&gt;
主题:Re: [FFmpeg-devel] [PATCH 1/1] add option in file.c: pkt_size to setmax_packet_size





&gt;&nbsp;On&nbsp;Jul&nbsp;17,&nbsp;2025,&nbsp;at&nbsp;22:05,&nbsp;yangsen5&nbsp;via&nbsp;ffmpeg-devel&nbsp;<ffmpeg-devel@ffmpeg.org&gt;&nbsp;wrote:
&gt;&nbsp;
&gt;&nbsp;From:&nbsp;yangsen5&nbsp;<1441923451@qq.com&gt;
&gt;&nbsp;
&gt;&nbsp;Signed-off-by:&nbsp;yangsen5&nbsp;<1441923451@qq.com&gt;
&gt;&nbsp;---
&gt;&nbsp;libavformat/file.c&nbsp;|&nbsp;4&nbsp;+++-
&gt;&nbsp;1&nbsp;file&nbsp;changed,&nbsp;3&nbsp;insertions(+),&nbsp;1&nbsp;deletion(-)
&gt;&nbsp;
&gt;&nbsp;diff&nbsp;--git&nbsp;a/libavformat/file.c&nbsp;b/libavformat/file.c
&gt;&nbsp;index&nbsp;6a66040b65..8099a7e931&nbsp;100644
&gt;&nbsp;---&nbsp;a/libavformat/file.c
&gt;&nbsp;+++&nbsp;b/libavformat/file.c
&gt;&nbsp;@@&nbsp;-94,6&nbsp;+94,7&nbsp;@@&nbsp;typedef&nbsp;struct&nbsp;FileContext&nbsp;{
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;int&nbsp;fd;
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;int&nbsp;trunc;
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;int&nbsp;blocksize;
&gt;&nbsp;+&nbsp;&nbsp;&nbsp;&nbsp;int&nbsp;pkt_size;
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;int&nbsp;follow;
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;int&nbsp;seekable;
&gt;&nbsp;#if&nbsp;HAVE_DIRENT_H
&gt;&nbsp;@@&nbsp;-106,6&nbsp;+107,7&nbsp;@@&nbsp;static&nbsp;const&nbsp;AVOption&nbsp;file_options[]&nbsp;=&nbsp;{
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;"blocksize",&nbsp;"set&nbsp;I/O&nbsp;operation&nbsp;maximum&nbsp;block&nbsp;size",&nbsp;offsetof(FileContext,&nbsp;blocksize),&nbsp;AV_OPT_TYPE_INT,&nbsp;{&nbsp;.i64&nbsp;=&nbsp;INT_MAX&nbsp;},&nbsp;1,&nbsp;INT_MAX,&nbsp;AV_OPT_FLAG_ENCODING_PARAM&nbsp;},
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;"follow",&nbsp;"Follow&nbsp;a&nbsp;file&nbsp;as&nbsp;it&nbsp;is&nbsp;being&nbsp;written",&nbsp;offsetof(FileContext,&nbsp;follow),&nbsp;AV_OPT_TYPE_INT,&nbsp;{&nbsp;.i64&nbsp;=&nbsp;0&nbsp;},&nbsp;0,&nbsp;1,&nbsp;AV_OPT_FLAG_DECODING_PARAM&nbsp;},
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;"seekable",&nbsp;"Sets&nbsp;if&nbsp;the&nbsp;file&nbsp;is&nbsp;seekable",&nbsp;offsetof(FileContext,&nbsp;seekable),&nbsp;AV_OPT_TYPE_INT,&nbsp;{&nbsp;.i64&nbsp;=&nbsp;-1&nbsp;},&nbsp;-1,&nbsp;0,&nbsp;AV_OPT_FLAG_DECODING_PARAM&nbsp;|&nbsp;AV_OPT_FLAG_ENCODING_PARAM&nbsp;},
&gt;&nbsp;+&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;"pkt_size",&nbsp;"Maximum&nbsp;file&nbsp;packet&nbsp;size",&nbsp;offsetof(FileContext,&nbsp;pkt_size),&nbsp;AV_OPT_TYPE_INT,&nbsp;{&nbsp;.i64&nbsp;=&nbsp;262144&nbsp;},&nbsp;-1,&nbsp;INT_MAX,&nbsp;AV_OPT_FLAG_DECODING_PARAM&nbsp;|&nbsp;AV_OPT_FLAG_ENCODING_PARAM&nbsp;},
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;NULL&nbsp;}
&gt;&nbsp;};
&gt;&nbsp;
&gt;&nbsp;@@&nbsp;-313,7&nbsp;+315,7&nbsp;@@&nbsp;static&nbsp;int&nbsp;file_open(URLContext&nbsp;*h,&nbsp;const&nbsp;char&nbsp;*filename,&nbsp;int&nbsp;flags)
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/*&nbsp;Buffer&nbsp;writes&nbsp;more&nbsp;than&nbsp;the&nbsp;default&nbsp;32k&nbsp;to&nbsp;improve&nbsp;throughput&nbsp;especially
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;with&nbsp;networked&nbsp;file&nbsp;systems&nbsp;*/
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(!h-&gt;is_streamed&nbsp;&amp;&amp;&nbsp;flags&nbsp;&amp;&nbsp;AVIO_FLAG_WRITE)
&gt;&nbsp;-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;h-&gt;min_packet_size&nbsp;=&nbsp;h-&gt;max_packet_size&nbsp;=&nbsp;262144;
&gt;&nbsp;+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;h-&gt;min_packet_size&nbsp;=&nbsp;h-&gt;max_packet_size&nbsp;=&nbsp;c-&gt;pkt_size;

What's&nbsp;the&nbsp;use&nbsp;case?

&gt;&nbsp;
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(c-&gt;seekable&nbsp;&gt;=&nbsp;0)
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;h-&gt;is_streamed&nbsp;=&nbsp;!c-&gt;seekable;
&gt;&nbsp;--&nbsp;
&gt;&nbsp;2.34.1
&gt;&nbsp;
&gt;&nbsp;_______________________________________________
&gt;&nbsp;ffmpeg-devel&nbsp;mailing&nbsp;list
&gt;&nbsp;ffmpeg-devel@ffmpeg.org
&gt;&nbsp;https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
&gt;&nbsp;
&gt;&nbsp;To&nbsp;unsubscribe,&nbsp;visit&nbsp;link&nbsp;above,&nbsp;or&nbsp;email
&gt;&nbsp;ffmpeg-devel-request@ffmpeg.org&nbsp;with&nbsp;subject&nbsp;"unsubscribe".
_______________________________________________
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".

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [FFmpeg-devel] [PATCH 1/1] add option in file.c: pkt_size toset max_packet_size
       [not found]   ` <tencent_F5DB935EB016EAA13A72B320FCBC9331010A@qq.com>
@ 2025-07-31  8:16     ` Gyan Doshi
  0 siblings, 0 replies; 7+ messages in thread
From: Gyan Doshi @ 2025-07-31  8:16 UTC (permalink / raw)
  To: 1+1=10, FFmpeg development discussions and patches



On 2025-07-31 01:06 pm, 1+1=10 wrote:
> If max_packet_size is -1, a crash will occur in the ffio_fdopen function due to malloc(-1),
> but max_packet_size is initialized to 0 in the url_alloc_for_protocol function.
> If it is not customized to -1, this situation should not occur.

But your added option allows the user to set it to an invalid value. 
Rectify that.

Regards,
Gyan

_______________________________________________
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".

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [FFmpeg-devel] [PATCH] add option in file.c: pkt_size to set max_packet_size
  2025-07-17 14:05 [FFmpeg-devel] [PATCH 1/1] add option in file.c: pkt_size to set max_packet_size yangsen5 via ffmpeg-devel
  2025-07-17 14:27 ` Gyan Doshi
  2025-07-17 15:01 ` [FFmpeg-devel] [PATCH 1/1] add option in file.c: pkt_size to set max_packet_size Zhao Zhili
@ 2025-07-31  9:05 ` yangsen5 via ffmpeg-devel
  2 siblings, 0 replies; 7+ messages in thread
From: yangsen5 via ffmpeg-devel @ 2025-07-31  9:05 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: 1441923451

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

_______________________________________________
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".

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2025-07-31  9:05 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-07-17 14:05 [FFmpeg-devel] [PATCH 1/1] add option in file.c: pkt_size to set max_packet_size yangsen5 via ffmpeg-devel
2025-07-17 14:27 ` Gyan Doshi
     [not found]   ` <tencent_F5DB935EB016EAA13A72B320FCBC9331010A@qq.com>
2025-07-31  8:16     ` [FFmpeg-devel] [PATCH 1/1] add option in file.c: pkt_size toset max_packet_size Gyan Doshi
2025-07-17 15:01 ` [FFmpeg-devel] [PATCH 1/1] add option in file.c: pkt_size to set max_packet_size Zhao Zhili
2025-07-31  5:16   ` [FFmpeg-devel] [PATCH 1/1] add option in file.c: pkt_size to setmax_packet_size 1+1=10 via ffmpeg-devel
2025-07-31  5:47   ` 1+1=10 via ffmpeg-devel
2025-07-31  9:05 ` [FFmpeg-devel] [PATCH] add option in file.c: pkt_size to set max_packet_size yangsen5 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