summaryrefslogtreecommitdiff
path: root/libavformat/mux.c
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 /libavformat/mux.c
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.
Diffstat (limited to 'libavformat/mux.c')
-rw-r--r--libavformat/mux.c10
1 files changed, 10 insertions, 0 deletions
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;