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] avfilter/drawtext: make reload value an interval
@ 2022-02-28  7:28 Gyan Doshi
  2022-03-01 17:51 ` Gyan Doshi
  0 siblings, 1 reply; 3+ messages in thread
From: Gyan Doshi @ 2022-02-28  7:28 UTC (permalink / raw)
  To: ffmpeg-devel

Allows user to specify a frame interval at which textfile is reloaded.
---
 doc/filters.texi          | 6 ++++--
 libavfilter/vf_drawtext.c | 6 +++---
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index b3ae139613..1ecc03eeae 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -11271,8 +11271,10 @@ text data in detection bboxes of side data. So please do not use this parameter
 if you are not sure about the text source.
 
 @item reload
-If set to 1, the @var{textfile} will be reloaded before each frame.
-Be sure to update it atomically, or it may be read partially, or even fail.
+The @var{textfile} will be reloaded at specified frame interval.
+Be sure to update @var{textfile} atomically, or it may be read partially,
+or even fail.
+Range is 0 to INT_MAX. Default is 0.
 
 @item x
 @item y
diff --git a/libavfilter/vf_drawtext.c b/libavfilter/vf_drawtext.c
index 2a88692cbd..6ba3f6622a 100644
--- a/libavfilter/vf_drawtext.c
+++ b/libavfilter/vf_drawtext.c
@@ -198,7 +198,7 @@ typedef struct DrawTextContext {
     AVRational  tc_rate;            ///< frame rate for timecode
     AVTimecode  tc;                 ///< timecode context
     int tc24hmax;                   ///< 1 if timecode is wrapped to 24 hours, 0 otherwise
-    int reload;                     ///< reload text file for each frame
+    int reload;                     ///< reload text file at specified frame interval
     int start_number;               ///< starting frame number for n/frame_num var
     char *text_source_string;       ///< the string to specify text data source
     enum AVFrameSideDataType text_source;
@@ -245,7 +245,7 @@ static const AVOption drawtext_options[]= {
     {"timecode_rate",   "set rate (timecode only)",         OFFSET(tc_rate),       AV_OPT_TYPE_RATIONAL, {.dbl=0},           0,  INT_MAX, FLAGS},
     {"r",               "set rate (timecode only)",         OFFSET(tc_rate),       AV_OPT_TYPE_RATIONAL, {.dbl=0},           0,  INT_MAX, FLAGS},
     {"rate",            "set rate (timecode only)",         OFFSET(tc_rate),       AV_OPT_TYPE_RATIONAL, {.dbl=0},           0,  INT_MAX, FLAGS},
-    {"reload",     "reload text file for each frame",                       OFFSET(reload),     AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, FLAGS},
+    {"reload",     "reload text file at specified frame interval", OFFSET(reload),     AV_OPT_TYPE_INT, {.i64=0}, 0, INT_MAX, FLAGS},
     { "alpha",       "apply alpha while rendering", OFFSET(a_expr),      AV_OPT_TYPE_STRING, { .str = "1"     },          .flags = FLAGS },
     {"fix_bounds", "check and fix text coords to avoid clipping", OFFSET(fix_bounds), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, FLAGS},
     {"start_number", "start frame number for n/frame_num variable", OFFSET(start_number), AV_OPT_TYPE_INT, {.i64=0}, 0, INT_MAX, FLAGS},
@@ -1565,7 +1565,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
         }
     }
 
-    if (s->reload) {
+    if (s->reload && !(inlink->frame_count_out % s->reload)) {
         if ((ret = load_textfile(ctx)) < 0) {
             av_frame_free(&frame);
             return ret;
-- 
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] 3+ messages in thread

* Re: [FFmpeg-devel] [PATCH] avfilter/drawtext: make reload value an interval
  2022-02-28  7:28 [FFmpeg-devel] [PATCH] avfilter/drawtext: make reload value an interval Gyan Doshi
@ 2022-03-01 17:51 ` Gyan Doshi
  2022-03-02  7:28   ` Gyan Doshi
  0 siblings, 1 reply; 3+ messages in thread
From: Gyan Doshi @ 2022-03-01 17:51 UTC (permalink / raw)
  To: ffmpeg-devel

Plan to push tomorrow.

On 2022-02-28 12:58 pm, Gyan Doshi wrote:
> Allows user to specify a frame interval at which textfile is reloaded.
> ---
>   doc/filters.texi          | 6 ++++--
>   libavfilter/vf_drawtext.c | 6 +++---
>   2 files changed, 7 insertions(+), 5 deletions(-)
>
> diff --git a/doc/filters.texi b/doc/filters.texi
> index b3ae139613..1ecc03eeae 100644
> --- a/doc/filters.texi
> +++ b/doc/filters.texi
> @@ -11271,8 +11271,10 @@ text data in detection bboxes of side data. So please do not use this parameter
>   if you are not sure about the text source.
>   
>   @item reload
> -If set to 1, the @var{textfile} will be reloaded before each frame.
> -Be sure to update it atomically, or it may be read partially, or even fail.
> +The @var{textfile} will be reloaded at specified frame interval.
> +Be sure to update @var{textfile} atomically, or it may be read partially,
> +or even fail.
> +Range is 0 to INT_MAX. Default is 0.
>   
>   @item x
>   @item y
> diff --git a/libavfilter/vf_drawtext.c b/libavfilter/vf_drawtext.c
> index 2a88692cbd..6ba3f6622a 100644
> --- a/libavfilter/vf_drawtext.c
> +++ b/libavfilter/vf_drawtext.c
> @@ -198,7 +198,7 @@ typedef struct DrawTextContext {
>       AVRational  tc_rate;            ///< frame rate for timecode
>       AVTimecode  tc;                 ///< timecode context
>       int tc24hmax;                   ///< 1 if timecode is wrapped to 24 hours, 0 otherwise
> -    int reload;                     ///< reload text file for each frame
> +    int reload;                     ///< reload text file at specified frame interval
>       int start_number;               ///< starting frame number for n/frame_num var
>       char *text_source_string;       ///< the string to specify text data source
>       enum AVFrameSideDataType text_source;
> @@ -245,7 +245,7 @@ static const AVOption drawtext_options[]= {
>       {"timecode_rate",   "set rate (timecode only)",         OFFSET(tc_rate),       AV_OPT_TYPE_RATIONAL, {.dbl=0},           0,  INT_MAX, FLAGS},
>       {"r",               "set rate (timecode only)",         OFFSET(tc_rate),       AV_OPT_TYPE_RATIONAL, {.dbl=0},           0,  INT_MAX, FLAGS},
>       {"rate",            "set rate (timecode only)",         OFFSET(tc_rate),       AV_OPT_TYPE_RATIONAL, {.dbl=0},           0,  INT_MAX, FLAGS},
> -    {"reload",     "reload text file for each frame",                       OFFSET(reload),     AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, FLAGS},
> +    {"reload",     "reload text file at specified frame interval", OFFSET(reload),     AV_OPT_TYPE_INT, {.i64=0}, 0, INT_MAX, FLAGS},
>       { "alpha",       "apply alpha while rendering", OFFSET(a_expr),      AV_OPT_TYPE_STRING, { .str = "1"     },          .flags = FLAGS },
>       {"fix_bounds", "check and fix text coords to avoid clipping", OFFSET(fix_bounds), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, FLAGS},
>       {"start_number", "start frame number for n/frame_num variable", OFFSET(start_number), AV_OPT_TYPE_INT, {.i64=0}, 0, INT_MAX, FLAGS},
> @@ -1565,7 +1565,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
>           }
>       }
>   
> -    if (s->reload) {
> +    if (s->reload && !(inlink->frame_count_out % s->reload)) {
>           if ((ret = load_textfile(ctx)) < 0) {
>               av_frame_free(&frame);
>               return ret;

_______________________________________________
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] 3+ messages in thread

* Re: [FFmpeg-devel] [PATCH] avfilter/drawtext: make reload value an interval
  2022-03-01 17:51 ` Gyan Doshi
@ 2022-03-02  7:28   ` Gyan Doshi
  0 siblings, 0 replies; 3+ messages in thread
From: Gyan Doshi @ 2022-03-02  7:28 UTC (permalink / raw)
  To: ffmpeg-devel



On 2022-03-01 11:21 pm, Gyan Doshi wrote:
> Plan to push tomorrow.

Pushed as 4b72bca6ca3f982614ac2f94160c55abe3778555

Regards,
Gyan

>
> On 2022-02-28 12:58 pm, Gyan Doshi wrote:
>> Allows user to specify a frame interval at which textfile is reloaded.
>> ---
>>   doc/filters.texi          | 6 ++++--
>>   libavfilter/vf_drawtext.c | 6 +++---
>>   2 files changed, 7 insertions(+), 5 deletions(-)
>>
>> diff --git a/doc/filters.texi b/doc/filters.texi
>> index b3ae139613..1ecc03eeae 100644
>> --- a/doc/filters.texi
>> +++ b/doc/filters.texi
>> @@ -11271,8 +11271,10 @@ text data in detection bboxes of side data. 
>> So please do not use this parameter
>>   if you are not sure about the text source.
>>     @item reload
>> -If set to 1, the @var{textfile} will be reloaded before each frame.
>> -Be sure to update it atomically, or it may be read partially, or 
>> even fail.
>> +The @var{textfile} will be reloaded at specified frame interval.
>> +Be sure to update @var{textfile} atomically, or it may be read 
>> partially,
>> +or even fail.
>> +Range is 0 to INT_MAX. Default is 0.
>>     @item x
>>   @item y
>> diff --git a/libavfilter/vf_drawtext.c b/libavfilter/vf_drawtext.c
>> index 2a88692cbd..6ba3f6622a 100644
>> --- a/libavfilter/vf_drawtext.c
>> +++ b/libavfilter/vf_drawtext.c
>> @@ -198,7 +198,7 @@ typedef struct DrawTextContext {
>>       AVRational  tc_rate;            ///< frame rate for timecode
>>       AVTimecode  tc;                 ///< timecode context
>>       int tc24hmax;                   ///< 1 if timecode is wrapped 
>> to 24 hours, 0 otherwise
>> -    int reload;                     ///< reload text file for each 
>> frame
>> +    int reload;                     ///< reload text file at 
>> specified frame interval
>>       int start_number;               ///< starting frame number for 
>> n/frame_num var
>>       char *text_source_string;       ///< the string to specify text 
>> data source
>>       enum AVFrameSideDataType text_source;
>> @@ -245,7 +245,7 @@ static const AVOption drawtext_options[]= {
>>       {"timecode_rate",   "set rate (timecode only)", 
>> OFFSET(tc_rate),       AV_OPT_TYPE_RATIONAL, {.dbl=0}, 0,  INT_MAX, 
>> FLAGS},
>>       {"r",               "set rate (timecode only)", 
>> OFFSET(tc_rate),       AV_OPT_TYPE_RATIONAL, {.dbl=0}, 0,  INT_MAX, 
>> FLAGS},
>>       {"rate",            "set rate (timecode only)", 
>> OFFSET(tc_rate),       AV_OPT_TYPE_RATIONAL, {.dbl=0}, 0,  INT_MAX, 
>> FLAGS},
>> -    {"reload",     "reload text file for each 
>> frame",                       OFFSET(reload), AV_OPT_TYPE_BOOL, 
>> {.i64=0}, 0, 1, FLAGS},
>> +    {"reload",     "reload text file at specified frame interval", 
>> OFFSET(reload),     AV_OPT_TYPE_INT, {.i64=0}, 0, INT_MAX, FLAGS},
>>       { "alpha",       "apply alpha while rendering", 
>> OFFSET(a_expr),      AV_OPT_TYPE_STRING, { .str = "1" },          
>> .flags = FLAGS },
>>       {"fix_bounds", "check and fix text coords to avoid clipping", 
>> OFFSET(fix_bounds), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, FLAGS},
>>       {"start_number", "start frame number for n/frame_num variable", 
>> OFFSET(start_number), AV_OPT_TYPE_INT, {.i64=0}, 0, INT_MAX, FLAGS},
>> @@ -1565,7 +1565,7 @@ static int filter_frame(AVFilterLink *inlink, 
>> AVFrame *frame)
>>           }
>>       }
>>   -    if (s->reload) {
>> +    if (s->reload && !(inlink->frame_count_out % s->reload)) {
>>           if ((ret = load_textfile(ctx)) < 0) {
>>               av_frame_free(&frame);
>>               return ret;
>
> _______________________________________________
> 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] 3+ messages in thread

end of thread, other threads:[~2022-03-02  7:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-28  7:28 [FFmpeg-devel] [PATCH] avfilter/drawtext: make reload value an interval Gyan Doshi
2022-03-01 17:51 ` Gyan Doshi
2022-03-02  7:28   ` Gyan Doshi

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