[FFmpeg-devel] [PATCH] Add asetpts audio filter

Stefano Sabatini stefasab at gmail.com
Wed Feb 29 19:10:53 CET 2012


On date Wednesday 2012-02-29 14:00:01 +0200, Andrey Utkin encoded:
> ---
>  libavfilter/Makefile     |    1 +
>  libavfilter/af_asetpts.c |  145 ++++++++++++++++++++++++++++++++++++++++++++++
>  libavfilter/allfilters.c |    1 +
>  3 files changed, 147 insertions(+), 0 deletions(-)
>  create mode 100644 libavfilter/af_asetpts.c
> 
> diff --git a/libavfilter/Makefile b/libavfilter/Makefile
> index db7397b..37e006e 100644
> --- a/libavfilter/Makefile
> +++ b/libavfilter/Makefile
> @@ -31,6 +31,7 @@ OBJS-$(CONFIG_AFORMAT_FILTER)                += af_aformat.o
>  OBJS-$(CONFIG_AMERGE_FILTER)                 += af_amerge.o
>  OBJS-$(CONFIG_ANULL_FILTER)                  += af_anull.o
>  OBJS-$(CONFIG_ARESAMPLE_FILTER)              += af_aresample.o
> +OBJS-$(CONFIG_ASETPTS_FILTER)                += af_asetpts.o
>  OBJS-$(CONFIG_ASHOWINFO_FILTER)              += af_ashowinfo.o
>  OBJS-$(CONFIG_ASPLIT_FILTER)                 += af_asplit.o
>  OBJS-$(CONFIG_ASTREAMSYNC_FILTER)            += af_astreamsync.o
> diff --git a/libavfilter/af_asetpts.c b/libavfilter/af_asetpts.c
> new file mode 100644
> index 0000000..ed15f9b
> --- /dev/null
> +++ b/libavfilter/af_asetpts.c
> @@ -0,0 +1,145 @@
> +/*
> + * Copyright (c) 2012 Andrey Utkin
> + * Copyright (c) 2010 Stefano Sabatini
> + * Copyright (c) 2008 Victor Paesa
> + *
> + * This file is part of FFmpeg.
> + *
> + * FFmpeg is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU Lesser General Public
> + * License as published by the Free Software Foundation; either
> + * version 2.1 of the License, or (at your option) any later version.
> + *
> + * FFmpeg is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with FFmpeg; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
> + */
> +
> +/**
> + * @file
> + * audio presentation timestamp (PTS) modification filter
> + */
> +
> +/* #define DEBUG */
> +
> +#include "libavutil/eval.h"
> +#include "libavutil/mathematics.h"
> +#include "avfilter.h"
> +
> +static const char *const var_names[] = {
> +    "N",           ///< frame number (starting at zero)
> +    "POS",         ///< original position in the file of the frame
> +    "PREV_INPTS",  ///< previous  input PTS
> +    "PREV_OUTPTS", ///< previous output PTS
> +    "PTS",         ///< original pts in the file of the frame
> +    "STARTPTS",   ///< PTS at start of movie
> +    "TB",          ///< timebase
> +    NULL
> +};

In the context of audio, also useful:
SAMPLE_RATE
NB_SAMPLES          ///< number of samples in the current frame
NB_CONSUMED_SAMPLES ///< number of samples consumed by the filter

[...]

Most of this can be factorized with setpts, so it should stay in the
same file.
-- 
FFmpeg = Fostering and Fundamental Mastering Prodigious Eager God


More information about the ffmpeg-devel mailing list