summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2013-01-25 15:04:41 +0100
committerMichael Niedermayer <michaelni@gmx.at>2013-01-25 15:04:41 +0100
commitfc2922836bc289e443c0c7a20450bf8f03c0785d (patch)
tree20843987f14580004c6f67314783eb39d00e2e93
parent25be63005f0ba0b4cb8bf2569202ad0e89b4dae3 (diff)
parent0b55b16abc15c3fad0ae8b7cedc8f63f1162e89c (diff)
Merge remote-tracking branch 'qatar/master'
* qatar/master: avfilter: allow setpts filter to use wallclock time for calculations Conflicts: doc/filters.texi Merged-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r--doc/filters.texi13
-rw-r--r--libavfilter/f_setpts.c7
2 files changed, 20 insertions, 0 deletions
diff --git a/doc/filters.texi b/doc/filters.texi
index ad8b5daee9..583cc30cb0 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -5466,6 +5466,13 @@ previous output PTS
@item PREV_OUTT
previous output time in seconds
+
+@item RTCTIME
+wallclock (RTC) time in microseconds
+
+@item RTCSTART
+wallclock (RTC) time at the start of the movie in microseconds
+
@end table
@subsection Examples
@@ -5506,6 +5513,12 @@ Apply an offset of 10 seconds to the input PTS:
@example
setpts=PTS+10/TB
@end example
+
+@item
+generate timestamps from a "live source" and rebase onto the current timebase
+@example
+setpts='(RTCTIME - RTCSTART) / (TB * 1000000)'
+@end example
@end itemize
@section ebur128
diff --git a/libavfilter/f_setpts.c b/libavfilter/f_setpts.c
index db1d91cf4e..1c2edb826b 100644
--- a/libavfilter/f_setpts.c
+++ b/libavfilter/f_setpts.c
@@ -27,6 +27,7 @@
#include "libavutil/eval.h"
#include "libavutil/internal.h"
#include "libavutil/mathematics.h"
+#include "libavutil/time.h"
#include "avfilter.h"
#include "internal.h"
#include "audio.h"
@@ -49,6 +50,8 @@ static const char *const var_names[] = {
"STARTT", ///< time at start of movie
"T", ///< original time in the file of the frame
"TB", ///< timebase
+ "RTCTIME", ///< wallclock (RTC) time in micro seconds
+ "RTCSTART", ///< wallclock (RTC) time at the start of the movie in micro seconds
NULL
};
@@ -69,6 +72,8 @@ enum var_name {
VAR_STARTT,
VAR_T,
VAR_TB,
+ VAR_RTCTIME,
+ VAR_RTCSTART,
VAR_VARS_NB
};
@@ -103,6 +108,7 @@ static int config_input(AVFilterLink *inlink)
setpts->type = inlink->type;
setpts->var_values[VAR_TB] = av_q2d(inlink->time_base);
+ setpts->var_values[VAR_RTCSTART] = av_gettime();
setpts->var_values[VAR_SAMPLE_RATE] =
setpts->type == AVMEDIA_TYPE_AUDIO ? inlink->sample_rate : NAN;
@@ -145,6 +151,7 @@ static int filter_frame(AVFilterLink *inlink, AVFilterBufferRef *frame)
setpts->var_values[VAR_PTS ] = TS2D(frame->pts);
setpts->var_values[VAR_T ] = TS2T(frame->pts, inlink->time_base);
setpts->var_values[VAR_POS ] = frame->pos == -1 ? NAN : frame->pos;
+ setpts->var_values[VAR_RTCTIME ] = av_gettime();
switch (inlink->type) {
case AVMEDIA_TYPE_VIDEO: