Message ID | CAFrfS6YY5Pjph3i+5tZH4RL5W+3jWuXrWCZzYMa2k=X3MoxA0w@mail.gmail.com |
---|---|
State | New |
Headers | show |
On Tue, Jun 11, 2019 at 06:02:10PM -0400, greg Luce wrote: > This is on the bug tracker at https://trac.ffmpeg.org/ticket/7947 > Created with the help of the excellent Calvin Walton <calvin.walton@kepstin.ca> > and rewritten with the advice of the excellent Gyan <ffmpeg@gyani.pro> > > --- > doc/filters.texi | 24 +++++++++++++++++++++++- > libavfilter/vf_drawtext.c | 9 +++++++++ > 2 files changed, 32 insertions(+), 1 deletion(-) git doesnt like this patch, probably messed up newlines Applying: vf_drawtext: Add pkt_pos, pkt_duration, pkt_size as variables error: corrupt patch at line 23 error: could not build fake ancestor [...]
Ooops apologies, .patch file attached and with hopefully better line breaks On Wed, 12 Jun 2019 at 03:43, Michael Niedermayer <michael@niedermayer.cc> wrote: > > On Tue, Jun 11, 2019 at 06:02:10PM -0400, greg Luce wrote: > > This is on the bug tracker at https://trac.ffmpeg.org/ticket/7947 > > Created with the help of the excellent Calvin Walton <calvin.walton@kepstin.ca> > > and rewritten with the advice of the excellent Gyan <ffmpeg@gyani.pro> > > > > --- > > doc/filters.texi | 24 +++++++++++++++++++++++- > > libavfilter/vf_drawtext.c | 9 +++++++++ > > 2 files changed, 32 insertions(+), 1 deletion(-) > > git doesnt like this patch, probably messed up newlines > > Applying: vf_drawtext: Add pkt_pos, pkt_duration, pkt_size as variables > error: corrupt patch at line 23 > error: could not build fake ancestor > > > [...] > -- > Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB > > Dictatorship: All citizens are under surveillance, all their steps and > actions recorded, for the politicians to enforce control. > Democracy: All politicians are under surveillance, all their steps and > actions recorded, for the citizens to enforce control. > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
On Wed, Jun 12, 2019 at 12:11:16 -0400, greg Luce wrote: > Ooops apologies, .patch file attached and with hopefully better line breaks Yes, but something went wrong with its contents: > Subject: [PATCH] Signed-off-by: greg Luce <electron.rotoscope@gmail.com> This doesn't look correct. It's supposed to contain Subject: vf_drawtext: Add pkt_pos, pkt_duration, pkt_size as variables and the Signed-off-by line is to be somewhere in the remaining commit message. How did you create the patch? > These parameters allow the @var{x} and @var{y} expressions to refer > -each other, so you can for example specify @code{y=x/dar}. > +to each other, so you can for example specify @code{y=x/dar}. > + > +@item pict_type > +A 1 character description of the current packet's input picture type. > + Strictly speaking, you're fixing and amending existing documentation, not related to your modifications. I personally don't mind, but others will request you to do this is a separate patch. > +@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. A non-related question: Do you understand when this is -1? (I myself am looking for some filter or log info which can give me the pkt_pos related to a certain time offset from the beginning of a file, as when seeked using "-ss".) > +The current packet's input duration. "input duration" sounds confusing. You can likely drop the "input". > +The current packet's input size (in bytes). Ditto. I can't comment on the rest, but like the feature. You may need to bump libavfilter's MICRO version, as you are adding features. Moritz
> This doesn't look correct. It's supposed to contain > Subject: vf_drawtext: Add pkt_pos, pkt_duration, pkt_size as variables > and the Signed-off-by line is to be somewhere in the remaining commit > message. How did you create the patch? I just cloned the main, made the change, and then did "git format-patch -1 HEAD" I'm afraid I don't know git very well. I'll just strip the head out of the patch files so I can't get them wrong! > Strictly speaking, you're fixing and amending existing documentation, > not related to your modifications. I personally don't mind, but others > will request you to do this is a separate patch. Split into two separate patch files (attached) in case that helps > A non-related question: Do you understand when this is -1? (I myself > am looking for some filter or log info which can give me the pkt_pos > related to a certain time offset from the beginning of a file, as when > seeked using "-ss".) I'm afraid I have no help for you there. I'm going on Gyan's advice from https://lists.ffmpeg.org/pipermail/ffmpeg-devel/2019-June/245249.html > > +The current packet's input duration. > > "input duration" sounds confusing. You can likely drop the "input". > > > +The current packet's input size (in bytes). > > Ditto. I'd included "input" since the frame rate and size might be changed later, but you're right people can probably figure that out. I'll take them out > You may need to bump libavfilter's MICRO version, as you are adding > features. I can't speak to that and I wouldn't know how to do it, but good point!
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}. + +@item pict_type +A 1 character description of the current packet's input picture type. + +@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. + +@item pkt_duration +The current packet's input duration. + +@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;