[FFmpeg-devel] [PATCH] lavfi: add asendcmd and sendcmd filters

Clément Bœsch ubitux at gmail.com
Mon Sep 3 03:36:24 CEST 2012


On Sun, Sep 02, 2012 at 06:18:42PM +0200, Stefano Sabatini wrote:
> On date Wednesday 2012-08-15 10:20:33 +0200, Nicolas George encoded:
> > Le nonidi 29 thermidor, an CCXX, Nicolas George a écrit :
> > > I do not believe having a solution for that problem right now is mandatory,
> > > but having a syntax that be extended to implement a solution would be
> > > better.
> > 
> > I suggest the following syntax:
> > 
> > 0:05:00-0:15:00         delogo set 10:10:160:120
> > +               [leave] delogo set 0
> > 
> > In other words:
> > 
> > - command timestamps can be intervals, with the end defaulting to infinity
> >   (INT64_MAX should be infinite enough);
> > 
> > - these intervals can have several associated commands, using a '+' instead
> >   of the timestamp to add to the current interval;
> 
> What about:
> 
> 0:05:00-0:15:00 [enter] delogo set 10:10:160:120
>                 [leave] delogo set 0;
> 
> ?
> 
> Basically this is setting several commands in a given interval (so the
> primitive will be parse_interval_commands()), possibly with different
> targets.
>  
> > - flags can be set between the timestamp and target using brackets, and some
> >   of these flags can specify when the corresponding command is sent
> >   depending on the evolution of the current timestamp with regard to the
> >   interval (default: "enter").
> > 
> > I believe this syntax could cover most reasonable needs without being too
> > much trouble to implement.
> > 
> > And if we agree that the target of a command can not have brackets in its
> > name (or that they must be escaped), it is completely compatible with what
> > you already wrote, so you can go ahead with it.
> 
> Updated WIP patch with token escaping (for the old syntax), and
> command terminator.
> -- 
> FFmpeg = Fierce & Frenzy Monstrous Plastic Evil Geisha

> From 362b7ee4dfa0a4d2d78a6baf3ab7b7d8287fe0c0 Mon Sep 17 00:00:00 2001
> From: Stefano Sabatini <stefasab at gmail.com>
> Date: Mon, 13 Aug 2012 20:13:26 +0200
> Subject: [PATCH] lavfi: add asendcmd and sendcmd filters
> 
> ---
>  doc/filters.texi         |   70 +++++++++
>  libavfilter/Makefile     |    2 +
>  libavfilter/allfilters.c |    2 +
>  libavfilter/f_sendcmd.c  |  369 ++++++++++++++++++++++++++++++++++++++++++++++
>  4 files changed, 443 insertions(+), 0 deletions(-)
>  create mode 100644 libavfilter/f_sendcmd.c
> 
> diff --git a/doc/filters.texi b/doc/filters.texi
> index 712936d..938758c 100644
> --- a/doc/filters.texi
> +++ b/doc/filters.texi
> @@ -4176,6 +4176,76 @@ tools.
>  
>  Below is a description of the currently available multimedia filters.
>  
> + at section asendcmd, sendcmd
> +
> +Send commands to filters in the filtergraph.
> +
> +These filters read commands to be sent to other filters in the
> +filtergraph.
> +
> + at code{asendcmd} must be inserted between two audio filters,
> + at code{sendcmd} must be inserted between two video filters, but apart
> +from that they act the same way.
> +

nit: I think something like this would be more obvious for users:

  @code{sendcmd} must be inserted between two video filters.
  @code{asendcmd} works the same way as sendcmd but for audio.

> +The specification of commands can be specified in the filter arguments
> +with the @var{commands} option, or in a file specified with the
> + at var{filename} option.
> +
> +Commands are sent the first time when a frame with time greater or
> +equal to the specified command time is processed by the filter.
> +
> +These filters accept the following options:
> + at table @option
> + at item commands, c
> +Set the commands to be read and sent to the other filters.
> + at item filename, f
> +Set the filename of the commands to be read and sent to the other
> +filters.
> + at end table
> +
> + at subsection Commands syntax
> +
> +Commands are specified one per line. Empty lines or lines starting
> +with @code{#} are ignored.
> +
> +A command line has the syntax:
> + at example
> + at var{target} @var{time} @var{command} @var{arg}
> + at end example
> +
> + at var{target} specify the target of the command, usually the name of
> +the filter class or of the specific filter instance.
> +

Here and below, "specifies"? (it appears like a sentence to me, not an
itemized thing like the other entries)

Even if "filter class" and "specific filter instance" sounds more correct
from a developer perspective, would it make more sense to say that it's
just the filter name?

And by the way, how do you identify the different target instances of the
same filter? ("volume", "volume1", "volume2", ...?)

> + at var{time} specify the time when the filter command is sent, expressed
> +as a time duration.
> +

Note: as I said on IRC, I really think this should allow frame accurate
timing range at some point.

> + at var{command} specify the name of the command, and depends on the
> +target filter.
> +

How does it "depends" on the target filter? Wouldn't it be more obvious to
say that it is a "specific command for the @var{target} filter"?

> + at var{arg} specify the optional list of argument for the given command.
> +
> + at subsection Examples
> +
> + at itemize
> + at item
> +Specify audio tempo change at second 4:
> + at example
> +asendcmd=c='atempo 4 tempo 1.5',atempo
> + at end example
> +
> + at item
> +Specify a list of drawtext commands in a file.
> + at example
> +drawtext 5 reinit fontsize=25:fontfile=FreeSerif.ttf:x=100+30*(t-5):text='hello world 5'
> +drawtext 10 reinit fontsize=25:fontfile=FreeSerif.ttf:x=100+30*(t-10):text='hello world 10'
> + at end example
> +
> +The file containing the list of commands can be specified with:
> + at example
> +sendcmd=f=test.cmd,drawtext=fontfile=FreeSerif.ttf:text='hello world 0'
> + at end example
> + at end itemize
> +

I didn't really follow the evolution of the talk about the time range, but
would it be possible to have something like:

    % cat timeline
    drawtext 00:01:02.123 start
    drawtext 00:05:23.435 stop
    %

Using the following filtergraph:

    sendcmd=f=timeline,drawtext=fontfile=FreeSerif.ttf:x=10*t:text='hello world'

the text would start appearing at 01:02.123 and be removed at 05.23.435

Would that be allowed?

[...]

Anyway, sorry for commenting only from a user perspective, but I believe
this filter will be intensively (ab)used by users so I'd like to see it
kind of well designed. That filter really is very welcome, thanks!

-- 
Clément B.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 490 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20120903/6c33c411/attachment.asc>


More information about the ffmpeg-devel mailing list