[FFmpeg-devel] [PATCH] vf_drawtext: Add pkt_pos, pkt_duration, pkt_size as variables
greg Luce
electron.rotoscope at gmail.com
Tue Jun 11 02:05:21 EEST 2019
I created this issue on the bugtracker but I'm trying to format it
properly for this channel
https://trac.ffmpeg.org/ticket/7947
The actual filter change was written by Calvin Walton <calvin.walton at kepstin.ca>
---
diff --git a/doc/filters.texi b/doc/filters.texi
index ec1c7c7591..332f4ddc80 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -8584,6 +8584,17 @@ The thickness of the drawn box.
These constants allow the @var{x}, @var{y}, @var{w}, @var{h} and
@var{t} expressions to refer to
each other, so you may for example specify @code{y=x/dar} or @code{h=w/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)
+
+ at item pkt_duration
+The current packet's input duration
+
+ at item pkt_size
+The current packet's input size (in bytes)
@end table
@@ -9032,6 +9043,14 @@ 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.
+The use of the term metadata in ffmpeg refers to extra data,
+often user-provided or generated live during decode by other filters.
+
+If you're trying to read data from teh frames in a stream or file, run
+ at code{ffprobe -show_frames}. If the information doesn't show up between
+ at code{[FRAME]} and @code{[/FRAME]} in the form
@code{TAG:[metadata_key]=[metadata_value]}
+then it won't be visible to this function.
+
@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);
---
More information about the ffmpeg-devel
mailing list