[FFmpeg-cvslog] vf_drawtext: add basetime argument to allow specifying the wall clock time of PTS=0

Michael Niedermayer git at videolan.org
Tue Aug 30 23:44:29 CEST 2011


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Tue Aug 30 23:37:49 2011 +0200| [595cfdef979f5ab22ae168bd9e9d7741a9bf4e22] | committer: Michael Niedermayer

vf_drawtext: add basetime argument to allow specifying the wall clock time of PTS=0
the basetime argument also enables useage of pts instead of time()

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

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

 libavfilter/vf_drawtext.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/libavfilter/vf_drawtext.c b/libavfilter/vf_drawtext.c
index 4e65e61..d95e712 100644
--- a/libavfilter/vf_drawtext.c
+++ b/libavfilter/vf_drawtext.c
@@ -81,6 +81,7 @@ typedef struct {
     int pixel_step[4];              ///< distance in bytes between the component of each pixel
     uint8_t rgba_map[4];            ///< map RGBA offsets to the positions in the packed RGBA format
     uint8_t *box_line[4];           ///< line used for filling the box background
+    int64_t basetime;               ///< base pts time in the real world for display
 } DrawTextContext;
 
 #define OFFSET(x) offsetof(DrawTextContext, x)
@@ -99,6 +100,8 @@ static const AVOption drawtext_options[]= {
 {"shadowx",  "set x",                OFFSET(shadowx),            FF_OPT_TYPE_INT,    {.dbl=0},     INT_MIN,  INT_MAX  },
 {"shadowy",  "set y",                OFFSET(shadowy),            FF_OPT_TYPE_INT,    {.dbl=0},     INT_MIN,  INT_MAX  },
 {"tabsize",  "set tab size",         OFFSET(tabsize),            FF_OPT_TYPE_INT,    {.dbl=4},     0,        INT_MAX  },
+{"basetime", "set base time",        OFFSET(basetime),           FF_OPT_TYPE_INT64,  {.dbl=AV_NOPTS_VALUE},     INT64_MIN,        INT64_MAX  },
+
 
 /* FT_LOAD_* flags */
 {"ft_load_flags", "set font loading flags for libfreetype",   OFFSET(ft_load_flags),  FF_OPT_TYPE_FLAGS,  {.dbl=FT_LOAD_DEFAULT|FT_LOAD_RENDER}, 0, INT_MAX, 0, "ft_load_flags" },
@@ -574,6 +577,9 @@ static int draw_text(AVFilterContext *ctx, AVFilterBufferRef *picref,
     uint8_t *buf = dtext->expanded_text;
     int buf_size = dtext->expanded_text_size;
 
+    if(dtext->basetime != AV_NOPTS_VALUE)
+        now= picref->pts*av_q2d(ctx->inputs[0]->time_base) + dtext->basetime/1000000;
+
     if (!buf) {
         buf_size = 2*strlen(dtext->text)+1;
         buf = av_malloc(buf_size);



More information about the ffmpeg-cvslog mailing list