[FFmpeg-devel] [PATCH v2] vf_drawtext: Add pkt_pos, pkt_duration, pkt_size as variables
greg Luce
electron.rotoscope at gmail.com
Wed Jun 12 01:02:10 EEST 2019
This is on the bug tracker at https://trac.ffmpeg.org/ticket/7947
Created with the help of the excellent Calvin Walton <calvin.walton at kepstin.ca>
and rewritten with the advice of the excellent Gyan <ffmpeg at gyani.pro>
---
doc/filters.texi | 24 +++++++++++++++++++++++-
libavfilter/vf_drawtext.c | 9 +++++++++
2 files changed, 32 insertions(+), 1 deletion(-)
diff --git a/doc/filters.texi b/doc/filters.texi
index ec1c7c7591..e2ca2a8c08 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -8961,8 +8961,23 @@ the width of the rendered text
@item y
the x and y offset coordinates where the text is drawn.
-These parameters allow the @var{x} and @var{y} expressions to refer
+These parameters allow the @var{x} and @var{y} expressions to refer to
each other, so you can for example specify @code{y=x/dar}.
+
+ at item pict_type
+A 1 character description of the current packet's input picture type.
+
+ at item pkt_pos
+The current packet's position in the input datastream (in bytes from
the head of the source file).
+
+A value of -1 indicates this info is not available.
+
+ at item pkt_duration
+The current packet's input duration.
+
+ at item pkt_size
+The current packet's input size (in bytes).
+
@end table
@anchor{drawtext_expansion}
@@ -9032,6 +9047,13 @@ The first argument is mandatory and specifies
the metadata key.
The second argument is optional and specifies a default value, used when the
metadata key is not found or empty.
+Available metadata can be identified by inspecting entries starting with
+TAG included within each frame section printed by running @code{ffprobe
+-show_frames}.
+
+String metadata generated in filters leading to the drawtext filter are
+also available.
+
@item n, frame_num
The frame number, starting from 0.
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);
--
2.22.0.windows.1
More information about the ffmpeg-devel
mailing list