[FFmpeg-cvslog] lavfi/drawtext: add support for printing frame numbers

Stefano Sabatini git at videolan.org
Thu Nov 22 13:17:46 CET 2012


ffmpeg | branch: master | Stefano Sabatini <stefasab at gmail.com> | Thu Nov 22 12:08:45 2012 +0100| [eb87b340e8c8ad3902e9dc0857724c8f659a113f] | committer: Stefano Sabatini

lavfi/drawtext: add support for printing frame numbers

Fix trac ticket #1949.

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

 doc/filters.texi          |    3 +++
 libavfilter/version.h     |    2 +-
 libavfilter/vf_drawtext.c |   11 +++++++++++
 3 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index 5bdd745..99654eb 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -2083,6 +2083,9 @@ It can accept an argument: a strftime() format string.
 The time at which the filter is running, expressed in the local time zone.
 It can accept an argument: a strftime() format string.
 
+ at item n, frame_num
+The frame number, starting from 0.
+
 @item pts
 The timestamp of the current frame, in seconds, with microsecond accuracy.
 
diff --git a/libavfilter/version.h b/libavfilter/version.h
index ddebb1a..04d6fa1 100644
--- a/libavfilter/version.h
+++ b/libavfilter/version.h
@@ -30,7 +30,7 @@
 
 #define LIBAVFILTER_VERSION_MAJOR  3
 #define LIBAVFILTER_VERSION_MINOR  23
-#define LIBAVFILTER_VERSION_MICRO 101
+#define LIBAVFILTER_VERSION_MICRO 102
 
 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
                                                LIBAVFILTER_VERSION_MINOR, \
diff --git a/libavfilter/vf_drawtext.c b/libavfilter/vf_drawtext.c
index a78a3ea..96512ab 100644
--- a/libavfilter/vf_drawtext.c
+++ b/libavfilter/vf_drawtext.c
@@ -611,6 +611,15 @@ static int func_pts(AVFilterContext *ctx, AVBPrint *bp,
     return 0;
 }
 
+static int func_frame_num(AVFilterContext *ctx, AVBPrint *bp,
+                          char *fct, unsigned argc, char **argv, int tag)
+{
+    DrawTextContext *dtext = ctx->priv;
+
+    av_bprintf(bp, "%d", (int)dtext->var_values[VAR_N]);
+    return 0;
+}
+
 #if !HAVE_LOCALTIME_R
 static void localtime_r(const time_t *t, struct tm *tm)
 {
@@ -643,6 +652,8 @@ static const struct drawtext_function {
     { "pts",       0, 0, 0,   func_pts      },
     { "gmtime",    0, 1, 'G', func_strftime },
     { "localtime", 0, 1, 'L', func_strftime },
+    { "frame_num", 0, 0, 0,   func_frame_num },
+    { "n",         0, 0, 0,   func_frame_num },
 };
 
 static int eval_function(AVFilterContext *ctx, AVBPrint *bp, char *fct,



More information about the ffmpeg-cvslog mailing list