From 5871ee5072f725fce77cd51597ee91570de3743d Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Mon, 27 Jan 2014 19:16:45 +0100 Subject: 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. --- libavformat/mux.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'libavformat/mux.c') 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; -- cgit v1.2.3