1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

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@gmx.at>
This commit is contained in:
Michael Niedermayer 2011-08-30 23:37:49 +02:00
parent cc2b4e889d
commit 595cfdef97

View File

@ -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);