diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2012-09-26 15:55:16 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2012-09-26 15:55:16 +0200 |
commit | 3ba0dab76ac32f0c9f50c916a73bc64e43c1fdf9 (patch) | |
tree | 220fbc9a57cab1990672a8a5beb1b29fd17d3aee /libavformat/utils.c | |
parent | e9350c44ad97b7d85478696912c88142b0d25e3b (diff) | |
download | ffmpeg-3ba0dab76ac32f0c9f50c916a73bc64e43c1fdf9.tar.gz |
lavf: Add support offset timestamps on muxing.
This allows avoiding negative timestamps.
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat/utils.c')
-rw-r--r-- | libavformat/utils.c | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/libavformat/utils.c b/libavformat/utils.c index 5bc5ada0dd..5cb380a954 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -3699,16 +3699,36 @@ int ff_interleave_packet_per_dts(AVFormatContext *s, AVPacket *out, } } if(stream_count && flush){ + AVStream *st; pktl= s->packet_buffer; *out= pktl->pkt; + st = s->streams[out->stream_index]; s->packet_buffer= pktl->next; if(!s->packet_buffer) s->packet_buffer_end= NULL; - if(s->streams[out->stream_index]->last_in_packet_buffer == pktl) - s->streams[out->stream_index]->last_in_packet_buffer= NULL; + if(st->last_in_packet_buffer == pktl) + st->last_in_packet_buffer= NULL; av_freep(&pktl); + + if (s->avoid_negative_ts > 0) { + if (out->dts != AV_NOPTS_VALUE) { + if (!st->mux_ts_offset && out->dts < 0) { + for(i=0; i < s->nb_streams; i++) { + s->streams[i]->mux_ts_offset = + av_rescale_q_rnd(-out->dts, + st->time_base, + s->streams[i]->time_base, + AV_ROUND_UP); + } + } + out->dts += st->mux_ts_offset; + } + if (out->pts != AV_NOPTS_VALUE) + out->pts += st->mux_ts_offset; + } + return 1; }else{ av_init_packet(out); |