[FFmpeg-cvslog] vf_drawtext: Add pkt_pos, pkt_duration, pkt_size as variables

Calvin Walton git at videolan.org
Sun Jul 7 08:43:08 EEST 2019


ffmpeg | branch: master | Calvin Walton <calvin.walton at kepstin.ca> | Fri Jun 21 09:08:03 2019 -0400| [2bd21b96096320bc12532119a6b0f7a974db6c19] | committer: Gyan Doshi

vf_drawtext: Add pkt_pos, pkt_duration, pkt_size as variables

Changes to vf_drawtext.c written by
Calvin Walton <calvin.walton at kepstin.ca>

Changes to filters.texi written by
greg Luce <electron.rotoscope at gmail.com>
with lots of help from Moritz Barsnick and Gyan

Fixes #7947.

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

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

diff --git a/doc/filters.texi b/doc/filters.texi
index 3c406a4791..ee6a93ffbf 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -9002,6 +9002,17 @@ to each other, so you can for example specify @code{y=x/dar}.
 
 @item pict_type
 A one character description of the current frame's picture type.
+
+ at item pkt_pos
+The current packet's position in the input file or stream
+(in bytes, from the start of the input). A value of -1 indicates
+this info is not available.
+
+ at item pkt_duration
+The current packet's duration, in seconds.
+
+ at item pkt_size
+The current packet's size (in bytes).
 @end table
 
 @anchor{drawtext_expansion}
diff --git a/libavfilter/version.h b/libavfilter/version.h
index 1347e4c7b7..5bf37fa8b4 100644
--- a/libavfilter/version.h
+++ b/libavfilter/version.h
@@ -31,7 +31,8 @@
 
 #define LIBAVFILTER_VERSION_MAJOR   7
 #define LIBAVFILTER_VERSION_MINOR  56
-#define LIBAVFILTER_VERSION_MICRO 100
+#define LIBAVFILTER_VERSION_MICRO 101
+
 
 #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 01cd7fa122..8f4badbdb5 100644
--- a/libavfilter/vf_drawtext.c
+++ b/libavfilter/vf_drawtext.c
@@ -88,6 +88,9 @@ static const char *const var_names[] = {
     "x",
     "y",
     "pict_type",
+    "pkt_pos",
+    "pkt_duration",
+    "pkt_size",
     NULL
 };
 
@@ -125,6 +128,9 @@ enum var_name {
     VAR_X,
     VAR_Y,
     VAR_PICT_TYPE,
+    VAR_PKT_POS,
+    VAR_PKT_DURATION,
+    VAR_PKT_SIZE,
     VAR_VARS_NB
 };
 
@@ -1516,6 +1522,9 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
         NAN : frame->pts * av_q2d(inlink->time_base);
 
     s->var_values[VAR_PICT_TYPE] = frame->pict_type;
+    s->var_values[VAR_PKT_POS] = frame->pkt_pos;
+    s->var_values[VAR_PKT_DURATION] = frame->pkt_duration * av_q2d(inlink->time_base);
+    s->var_values[VAR_PKT_SIZE] = frame->pkt_size;
     s->metadata = frame->metadata;
 
     draw_text(ctx, frame, frame->width, frame->height);



More information about the ffmpeg-cvslog mailing list