On 04/11/2013 09:10 PM, Anton Khirnov wrote:
> ---
> Changelog | 1 +
> doc/filters.texi | 69 ++++++++++++
> libavfilter/Makefile | 3 +-
> libavfilter/allfilters.c | 1 +
> libavfilter/setpts.c | 261
> ++++++++++++++++++++++++++++++++++++++++++++++
> libavfilter/version.h | 2 +-
> libavfilter/vf_setpts.c | 195 ----------------------------------
> 7 files changed, 335 insertions(+), 197 deletions(-)
> create mode 100644 libavfilter/setpts.c
> delete mode 100644 libavfilter/vf_setpts.c
>
> diff --git a/Changelog b/Changelog
> index 5089ba7..b03f48c 100644
> --- a/Changelog
> +++ b/Changelog
> @@ -10,6 +10,7 @@ version 10:
> - new avconv options -filter_script and -filter_complex_script, which allow a
> filtergraph description to be read from a file
> - uniform options syntax across all filters
> +- new asetpts filter (same as setpts, but for audio)
>
>
> version 9:
> diff --git a/doc/filters.texi b/doc/filters.texi
> index 853d047..82436e8 100644
> --- a/doc/filters.texi
> +++ b/doc/filters.texi
> @@ -192,6 +192,75 @@ stream ends. The default value is 2 seconds.
>
> Pass the audio source unchanged to the output.
>
> +@section asetpts
> +
> +Change the PTS (presentation timestamp) of the input audio frames.
> +
> +This filter accepts the following options:
> +
> +@table @option
> +
> +@item expr
> +The expression which is evaluated for each frame to construct its timestamp.
> +
> +@end table
> +
> +The expression is evaluated through the eval API and can contain the
> following
> +constants:
> +
> +@table @option
> +@item PTS
> +the presentation timestamp in input
> +
> +@item PI
> +Greek PI
> +
> +@item PHI
> +golden ratio
> +
> +@item E
> +Euler number
> +
> +@item N
> +Number of the audio samples pass through the filter so far, starting at 0.
> +
> +@item S
> +Number of the audio samples in the current frame.
> +
> +@item SR
> +Audio sample rate.
> +
> +@item STARTPTS
> +the PTS of the first frame
> +
> +@item PREV_INPTS
> +previous input PTS
> +
> +@item PREV_OUTPTS
> +previous output PTS
> +
> +@item RTCTIME
> +wallclock (RTC) time in microseconds
> +
> +@item RTCSTART
> +wallclock (RTC) time at the start of the movie in microseconds
> +
> +@end table
> +
> +Some examples follow:
> +
> +@example
> +# start counting PTS from zero
> +asetpts=expr=PTS-STARTPTS
> +
> +#generate timestamps by counting samples
> +asetpts=expr=N/SR/TB
> +
> +# generate timestamps from a "live source" and rebase onto the current
> timebase
> +asetpts='(RTCTIME - RTCSTART) / (TB * 1000000)"
> +@end example
> +
> +
> @section ashowinfo
>
> Show a line containing various information for each input audio frame.
> diff --git a/libavfilter/Makefile b/libavfilter/Makefile
> index 4a3331a..c4eb386 100644
> --- a/libavfilter/Makefile
> +++ b/libavfilter/Makefile
> @@ -27,6 +27,7 @@ OBJS = allfilters.o
> \
> OBJS-$(CONFIG_AFORMAT_FILTER) += af_aformat.o
> OBJS-$(CONFIG_AMIX_FILTER) += af_amix.o
> OBJS-$(CONFIG_ANULL_FILTER) += af_anull.o
> +OBJS-$(CONFIG_ASETPTS_FILTER) += setpts.o
> OBJS-$(CONFIG_ASHOWINFO_FILTER) += af_ashowinfo.o
> OBJS-$(CONFIG_ASPLIT_FILTER) += split.o
> OBJS-$(CONFIG_ASYNCTS_FILTER) += af_asyncts.o
> @@ -69,7 +70,7 @@ OBJS-$(CONFIG_PIXDESCTEST_FILTER) +=
> vf_pixdesctest.o
> OBJS-$(CONFIG_SCALE_FILTER) += vf_scale.o
> OBJS-$(CONFIG_SELECT_FILTER) += vf_select.o
> OBJS-$(CONFIG_SETDAR_FILTER) += vf_aspect.o
> -OBJS-$(CONFIG_SETPTS_FILTER) += vf_setpts.o
> +OBJS-$(CONFIG_SETPTS_FILTER) += setpts.o
> OBJS-$(CONFIG_SETSAR_FILTER) += vf_aspect.o
> OBJS-$(CONFIG_SETTB_FILTER) += vf_settb.o
> OBJS-$(CONFIG_SHOWINFO_FILTER) += vf_showinfo.o
> diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
> index f3ce91c..5d15837 100644
> --- a/libavfilter/allfilters.c
> +++ b/libavfilter/allfilters.c
> @@ -47,6 +47,7 @@ void avfilter_register_all(void)
> REGISTER_FILTER(AFORMAT, aformat, af);
> REGISTER_FILTER(AMIX, amix, af);
> REGISTER_FILTER(ANULL, anull, af);
> + REGISTER_FILTER(ASETPTS, asetpts, af);
> REGISTER_FILTER(ASHOWINFO, ashowinfo, af);
> REGISTER_FILTER(ASPLIT, asplit, af);
> REGISTER_FILTER(ASYNCTS, asyncts, af);
> diff --git a/libavfilter/setpts.c b/libavfilter/setpts.c
> new file mode 100644
> index 0000000..bb2bcef
> --- /dev/null
> +++ b/libavfilter/setpts.c
> @@ -0,0 +1,261 @@
> +/*
> + * Copyright (c) 2010 Stefano Sabatini
> + * Copyright (c) 2008 Victor Paesa
> + *
> + * This file is part of Libav.
> + *
> + * Libav 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.
> + *
> + * Libav 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 Libav; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
> USA
> + */
> +
> +/**
> + * @file
> + * video presentation timestamp (PTS) modification filter
> + */
> +
> +/* #define DEBUG */
> +
> +#include "libavutil/eval.h"
> +#include "libavutil/internal.h"
> +#include "libavutil/mathematics.h"
> +#include "libavutil/opt.h"
> +#include "libavutil/time.h"
> +
> +#include "audio.h"
> +#include "avfilter.h"
> +#include "internal.h"
> +#include "video.h"
> +
> +#include "config.h"
> +
> +static const char *const var_names[] = {
> + "E", ///< Euler number
> + "INTERLACED", ///< tell if the current frame is interlaced
> + "N", ///< frame / sample number (starting at zero)
> + "PHI", ///< golden ratio
> + "PI", ///< greek pi
> + "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
^
While at it vertical align, the rest seems ok.
lu
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel