summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefano Sabatini <stefasab@gmail.com>2014-01-27 19:16:45 +0100
committerStefano Sabatini <stefasab@gmail.com>2014-02-02 13:16:17 +0100
commit5871ee5072f725fce77cd51597ee91570de3743d (patch)
treed468a50fff2ad91786ff18475128203015dacc50
parenta535d3952c66b93fc96752421da46ce2fd96158a (diff)
lavf: add output_ts_offset option to AVFormatContext
This option can be generally useful to set an output offset, needed when setting an absolute index in the output.
-rw-r--r--doc/APIchanges3
-rw-r--r--doc/formats.texi12
-rw-r--r--libavformat/avformat.h5
-rw-r--r--libavformat/mux.c10
-rw-r--r--libavformat/options_table.h1
-rw-r--r--libavformat/version.h4
6 files changed, 33 insertions, 2 deletions
diff --git a/doc/APIchanges b/doc/APIchanges
index c6cbe7797c..af74c935e2 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -15,6 +15,9 @@ libavutil: 2012-10-22
API changes, most recent first:
+2014-02-02 - xxxxxxx - lavf 55.29.100 - avformat.h
+ Add output_ts_offset muxing option to AVFormatContext.
+
2014-01-27 - 102bd64 - lavd 55.7.100 - avdevice.h
lavf 55.28.100 - avformat.h
Add avdevice_dev_to_app_control_message() function.
diff --git a/doc/formats.texi b/doc/formats.texi
index ba9d2776ef..bdd144e451 100644
--- a/doc/formats.texi
+++ b/doc/formats.texi
@@ -148,6 +148,18 @@ Correct single timestamp overflows if set to 1. Default is 1.
Flush the underlying I/O stream after each packet. Default 1 enables it, and
has the effect of reducing the latency; 0 disables it and may slightly
increase performance in some cases.
+
+@item output_ts_offset @var{offset} (@emph{output})
+Set the output time offset.
+
+@var{offset} must be a time duration specification,
+see @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}.
+
+The offset is added by the muxer to the output timestamps.
+
+Specifying a positive offset means that the corresponding streams are
+delayed bt the time duration specified in @var{offset}. Default value
+is @code{0} (meaning that no offset is applied).
@end table
@c man end FORMAT OPTIONS
diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index 76b0652cec..50b710816b 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -1380,6 +1380,11 @@ typedef struct AVFormatContext {
*/
av_format_control_message control_message_cb;
+ /**
+ * Output timestamp offset, in microseconds.
+ * Muxing: set by user via AVOptions (NO direct access)
+ */
+ int64_t output_ts_offset;
} AVFormatContext;
int av_format_get_probe_score(const AVFormatContext *s);
diff --git a/libavformat/mux.c b/libavformat/mux.c
index bd50191b87..70b60640a1 100644
--- a/libavformat/mux.c
+++ b/libavformat/mux.c
@@ -510,6 +510,16 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt)
{
int ret, did_split;
+ if (s->output_ts_offset) {
+ AVStream *st = s->streams[pkt->stream_index];
+ int64_t offset = av_rescale_q(s->output_ts_offset, AV_TIME_BASE_Q, st->time_base);
+
+ if (pkt->dts != AV_NOPTS_VALUE)
+ pkt->dts += offset;
+ if (pkt->pts != AV_NOPTS_VALUE)
+ pkt->pts += offset;
+ }
+
if (s->avoid_negative_ts > 0) {
AVStream *st = s->streams[pkt->stream_index];
int64_t offset = st->mux_ts_offset;
diff --git a/libavformat/options_table.h b/libavformat/options_table.h
index 32210422c9..b42a762738 100644
--- a/libavformat/options_table.h
+++ b/libavformat/options_table.h
@@ -78,6 +78,7 @@ static const AVOption avformat_options[] = {
{"correct_ts_overflow", "correct single timestamp overflows", OFFSET(correct_ts_overflow), AV_OPT_TYPE_INT, {.i64 = 1}, 0, 1, D},
{"flush_packets", "enable flushing of the I/O context after each packet", OFFSET(flush_packets), AV_OPT_TYPE_INT, {.i64 = 1}, 0, 1, E},
{"metadata_header_padding", "set number of bytes to be written as padding in a metadata header", OFFSET(metadata_header_padding), AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX, E},
+{"output_ts_offset", "set output timestamp offset", OFFSET(output_ts_offset), AV_OPT_TYPE_DURATION, {.i64 = 0}, -INT64_MAX, INT64_MAX, E},
{NULL},
};
diff --git a/libavformat/version.h b/libavformat/version.h
index a052d3c32c..38945a57fd 100644
--- a/libavformat/version.h
+++ b/libavformat/version.h
@@ -30,8 +30,8 @@
#include "libavutil/version.h"
#define LIBAVFORMAT_VERSION_MAJOR 55
-#define LIBAVFORMAT_VERSION_MINOR 28
-#define LIBAVFORMAT_VERSION_MICRO 101
+#define LIBAVFORMAT_VERSION_MINOR 29
+#define LIBAVFORMAT_VERSION_MICRO 100
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
LIBAVFORMAT_VERSION_MINOR, \