[FFmpeg-devel] [PATCH 1/2] lavfi/ebur128: add metadata injection.

Stefano Sabatini stefasab at gmail.com
Sun Feb 24 23:42:39 CET 2013


On date Friday 2013-02-22 00:22:39 +0100, Clément Bœsch encoded:
> ---
>  doc/filters.texi        |  5 +++++
>  libavfilter/f_ebur128.c | 29 +++++++++++++++++++++++++++++
>  2 files changed, 34 insertions(+)
> 
> diff --git a/doc/filters.texi b/doc/filters.texi
> index a93b433..9fbda34 100644
> --- a/doc/filters.texi
> +++ b/doc/filters.texi
> @@ -6252,6 +6252,11 @@ Set the EBU scale meter. Default is @code{9}. Common values are @code{9} and
>  @code{18}, respectively for EBU scale meter +9 and EBU scale meter +18. Any
>  other integer value between this range is allowed.
>  
> + at item metadata

> +Set metadata injection. Default is @code{0}. If set to @code{1}, the audio will
> +be divided into 100ms frames, each of them out of the filter containing various
> +loudness information.

Set metadata injection. If set to @code{1}, the audio will be segment
the input into 100ms output frames, each of them containing various
loudness information in metadata.

Default is @code{0}.
...

Also you may specify the exact name of the injected metadata keys.

> +
>  @end table
>  
>  Example of real-time graph using @command{ffplay}, with a EBU scale meter +18:
> diff --git a/libavfilter/f_ebur128.c b/libavfilter/f_ebur128.c
> index 66cc133..1d0513d 100644
> --- a/libavfilter/f_ebur128.c
> +++ b/libavfilter/f_ebur128.c
> @@ -33,6 +33,7 @@
>  #include "libavutil/avassert.h"
>  #include "libavutil/avstring.h"
>  #include "libavutil/channel_layout.h"
> +#include "libavutil/dict.h"
>  #include "libavutil/xga_font_data.h"
>  #include "libavutil/opt.h"
>  #include "libavutil/timestamp.h"
> @@ -90,6 +91,7 @@ struct rect { int x, y, w, h; };
>  
>  typedef struct {
>      const AVClass *class;           ///< AVClass context for log and options purpose
> +    int metadata;                   ///< whether or not to inject loudness results in buffers
>  
>      /* video  */
>      int do_video;                   ///< 1 if video output enabled, 0 otherwise
> @@ -133,6 +135,7 @@ static const AVOption ebur128_options[] = {
>      { "video", "set video output", OFFSET(do_video), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 1, V|F },
>      { "size",  "set video size",   OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, {.str = "640x480"}, 0, 0, V|F },
>      { "meter", "set scale meter (+9 to +18)",  OFFSET(meter), AV_OPT_TYPE_INT, {.i64 = 9}, 9, 18, V|F },
> +    { "metadata", "inject metadata in the filtergraph", OFFSET(metadata), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 1, V|F },

flags = A|F?

>      { NULL },
>  };
>  
> @@ -311,6 +314,20 @@ static int config_video_output(AVFilterLink *outlink)
>      return 0;
>  }
>  
> +static int config_audio_input(AVFilterLink *inlink)
> +{
> +    AVFilterContext *ctx = inlink->dst;
> +    EBUR128Context *ebur128 = ctx->priv;
> +

> +    /* force 100ms framing in case of metadata injection: the frames must have
> +     * a granularity of the window overlap to be accurately exploited */
> +    if (ebur128->metadata)
> +        inlink->min_samples =
> +        inlink->max_samples =
> +        inlink->partial_buf_size = inlink->sample_rate / 10;

How do you get 100ms from this relation?

[...]
-- 
FFmpeg = Forgiving & Faithful MultiPurpose Exxagerate God


More information about the ffmpeg-devel mailing list