[FFmpeg-devel] [PATCH] vf_drawtext: Add pkt_pos, pkt_duration, pkt_size as variables
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 --- 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}. +@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) + +@item pkt_duration +The current packet's input duration + +@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 +@code{ffprobe -show_frames}. If the information doesn't show up between +@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); --- ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] vf_drawtext: Add pkt_pos, pkt_duration, pkt_size as variables
On Mon, 10 Jun 2019 at 19:05, greg Luce wrote: > +If you're trying to read data from teh frames in a stream or file, run Sorry, this should read "the" not "teh" ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v2] vf_drawtext: Add pkt_pos, pkt_duration, pkt_size as variables
This is on the bug tracker at https://trac.ffmpeg.org/ticket/7947 Created with the help of the excellent Calvin Walton and rewritten with the advice of the excellent Gyan --- 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}. + +@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; draw_text(ctx, frame, frame->width, frame->height); -- 2.22.0.windows.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v2] vf_drawtext: Add pkt_pos, pkt_duration, pkt_size as variables
Ooops apologies, .patch file attached and with hopefully better line breaks On Wed, 12 Jun 2019 at 03:43, Michael Niedermayer 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 > > > > and rewritten with the advice of the excellent Gyan > > > > --- > > 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-requ...@ffmpeg.org with subject "unsubscribe". [PATCH v2] vf_drawtext_ Add pkt_pos, pkt_duration, pkt_size as variables.patch Description: Binary data ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v2] vf_drawtext: Add pkt_pos, pkt_duration, pkt_size as variables
> 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! [PATCH] filters doc typo fix.patch Description: Binary data [PATCH] REVISED vf_drawtext - Add pkt_pos, pkt_duration, pkt_size as variables.patch Description: Binary data ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] dash: change default MP4 extension to .m4s
> > the background for this is the extension for DASH media files > > used to be *.m4s and it is now *.mp4 I don't know about the official standard, but at least one implimentation (vimeo.com) has a bunch of moov atoms in a .mp4 file at the start of the stream, followed by .m4s segments ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v3] vf_drawtext - Add variables
Adds pkt_pos, pkt_duration, and pkt_size to drawtext as variables for text expansion, and adds documentation for pict_type which already exists. [PATCH v3] vf_drawtext - Add variables.patch Description: Binary data ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v3] vf_drawtext - Add variables
> Who has written the patch that you attached? > > Thank you, Carl Eugen The C code was written by kepstin I wrote the change to the documentation with help from several people There's a trac ticket at https://trac.ffmpeg.org/ticket/7947 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v4] vf_drawtext: Add pkt_pos, pkt_duration, pkt_size as variables
Info at https://trac.ffmpeg.org/ticket/7947 C code in file 0001, documentation and version tick in file 0002 Documentation written with help from Gyan and Moritz Barsnick Documentation patch has info in what I hope is the commit message 0001-vf_drawtext-Add-pkt_pos-pkt_duration-pkt_size-as-var.patch Description: Binary data 0002-vf_drawtext-Add-pkt_pos-pkt_duration-pkt_size-as-var.patch Description: Binary data ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH] vf_drawtext documentation additions and correction
Split this patch off since it just deals with documentation for features already present in the code. Hope I formatted everything correctly! Gyan and kepstin helped write the documentation 0001-vf_drawtext documentation additions and correction.patch Description: Binary data ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] vf_drawtext documentation additions and correction
> > +A 1 character description of the current packet's picture type. > > packet --> frame. You know I was thinking about that. I'll change and resubmit ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v2] vf_drawtext documentation additions and correction
Split this patch off since it just deals with documentation for features already present in the code. Hope I formatted everything correctly! Gyan and kepstin helped write the documentation 0001-vf_drawtext documentation additions and correction.patch Description: Binary data ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v4] vf_drawtext: Add pkt_pos, pkt_duration, pkt_size as variables
> code changes should be ok > the doc and code belong in the same patch/commit though I had them in a single patch before but split them as requested here http://ffmpeg.org/pipermail/ffmpeg-devel/2019-June/245613.html Is there something I'm missing that allows me to split the patch but have the code and doc in the same patch? ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v4] vf_drawtext: Add pkt_pos, pkt_duration, pkt_size as variables
Thanks will resubmit that way On Fri, 21 Jun 2019 at 08:53, Nicolas George wrote: > > greg Luce (12019-06-21): > > I had them in a single patch before but split them as requested here > > http://ffmpeg.org/pipermail/ffmpeg-devel/2019-June/245613.html > > Is there something I'm missing that allows me to split the patch but > > have the code and doc in the same patch? > > Asking you to split was, I think, a mistake: a new feature and its > documentation belong in the same commit, even if they were written by > different persons. > > Just make sure the commit message states authorship accurately. > > Regards, > > -- > Nicolas George > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v5] vf_drawtext: Add pkt_pos, pkt_duration, pkt_size as variables
Info at https://trac.ffmpeg.org/ticket/7947 Changes to vf_drawtext.c written by Calvin Walton Changes to filters.texi written by greg Luce with lots of help from Moritz Barsnick and Gyan [PATCH]-vf_drawtext-Add-pkt_pos-pkt_duration-pkt_size-as-var.patch Description: Binary data ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v5] vf_drawtext: Add pkt_pos, pkt_duration, pkt_size as variables
> Do you consider the doc change to be more important than the code > change? > > If not, you need to change the From line of the commit. Makes sense! ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v6] vf_drawtext: Add pkt_pos, pkt_duration, pkt_size as variables
Info at https://trac.ffmpeg.org/ticket/7947 Changes to vf_drawtext.c written by Calvin Walton Changes to filters.texi written by greg Luce with lots of help from Moritz Barsnick and Gyan [PATCH]-vf_drawtext-Add-pkt_pos-pkt_duration-pkt_size-as-var.patch Description: Binary data ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v4] vf_drawtext: Add pkt_pos, pkt_duration, pkt_size as variables
> These were two different and independent patches written by two different > persons. I'm totally fine with them going in either way, but just to clarify the 0002 file was written as a companion to update the documentation to go along with 0001, it isn't meant to exist on its own. I can't speak to what the proper method is If the joined version is preferred it's been submitted at http://ffmpeg.org/pipermail/ffmpeg-devel/2019-June/245662.html ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v6] vf_drawtext: Add pkt_pos, pkt_duration, pkt_size as variables
There's also a version as two separate patches submitted at http://ffmpeg.org/pipermail/ffmpeg-devel/2019-June/245625.html if that's better etiquette. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v4] vf_drawtext: Add pkt_pos, pkt_duration, pkt_size as variables
Hello, Just wondering if there’s anything else I should do to get this in Thanks! ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] print pts as min:sec
> > is there a functionality in the ffmpeg library to print AVFrame pts > values in respect to AVRational time_base in human readable form? I wonder if vf_drawtext might have an example of what you’re looking for with the pts keyword? > ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v4] vf_drawtext: Add pkt_pos, pkt_duration, pkt_size as variables
> If the joined version is preferred it's been submitted at > http://ffmpeg.org/pipermail/ffmpeg-devel/2019-June/245662.html Pinging. Would it be possible to get one of these two versions applied, if no other changes are required? ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [FFmpeg-cvslog] vf_drawtext: Add pkt_pos, pkt_duration, pkt_size as variables
> > This makes very little sense, please try hard to avoid similar commits in > > the future. > What makes very little sense? > > Gyan Carl, if you mean the language is confusing I'm happy to write stuff differently! I'm very new to ffmpeg-devel in general. If you mean you can't picture someone actually using the feature this patch adds, I actually agree with you. I misunderstood what the patch would change, and am testing a further modification to add these variables to text expansion where they'd probably be more useful (and where I'd actually have a use for them) I've attached the patch, though I haven't tested building with it yet vf_drawtext - Add pkt_pos, pkt_duration, pkt_size to text expansion.patch Description: Binary data ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [FFmpeg-cvslog] vf_drawtext: Add pkt_pos, pkt_duration, pkt_size as variables
> What output were you expecting with the first patch and what command did > you test to check? I was hoping it would make -filter_complex [0:v]drawtext=text='%{pkt_duration}' (and also pkt_size and pkt_pos) work the same way as -filter_complex [0:v]drawtext=text='%{frame_num}' does currently, but all I got was error messages as if I'd put nonsense between the {brackets} Would this new patch make that work now? ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [FFmpeg-cvslog] vf_drawtext: Add pkt_pos, pkt_duration, pkt_size as variables
> You haven't tested your patch? Correct ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [FFmpeg-cvslog] vf_drawtext: Add pkt_pos, pkt_duration, pkt_size as variables
> Yes, but it's not needed. These are constants, so they have to be > referenced within a function. There are two suitable ones: e and eif > > e.g. > > drawtext=text='pos %{e\:pkt_pos}, dur %{e\:pkt_duration}, size > %{e\:pkt_size}' Oh my goodness gracious that's amazing! Thanks, I'll try that out now! So I guess does that mean %{e\:n} does the same thing as %{n} ? ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".