diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2012-11-24 01:34:52 +0100 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2012-11-24 01:54:49 +0100 |
commit | d92073ac9346027de42fda9d934e47f5a2bc97e1 (patch) | |
tree | cf4997b388f6be00a3c37aa223d5b602eec361b8 | |
parent | fe97bf60b8ac448c927816c82c3460ac1b397385 (diff) | |
download | ffmpeg-d92073ac9346027de42fda9d934e47f5a2bc97e1.tar.gz |
ffmpeg: Correct starttime based on non discarded streams.
Fixes Ticket1830
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r-- | ffmpeg.c | 19 |
1 files changed, 19 insertions, 0 deletions
@@ -2775,6 +2775,25 @@ static int process_input(int file_index) } if(!ist->wrap_correction_done && is->start_time != AV_NOPTS_VALUE && ist->st->pts_wrap_bits < 64){ + // Correcting starttime based on the enabled streams + // FIXME this ideally should be done before the first use of starttime but we do not know which are the enabled streams at that point. + // so we instead do it here as part of discontinuity handling + if ( ist->next_dts == AV_NOPTS_VALUE + && ifile->ts_offset == -is->start_time + && (is->iformat->flags & AVFMT_TS_DISCONT)) { + int64_t new_start_time = INT64_MAX; + for (i=0; i<is->nb_streams; i++) { + AVStream *st = is->streams[i]; + if(st->discard == AVDISCARD_ALL || st->start_time == AV_NOPTS_VALUE) + continue; + new_start_time = FFMIN(new_start_time, av_rescale_q(st->start_time, st->time_base, AV_TIME_BASE_Q)); + } + if (new_start_time > is->start_time) { + av_log(is, AV_LOG_VERBOSE, "Correcting start time by %"PRId64"\n", new_start_time - is->start_time); + ifile->ts_offset = -new_start_time; + } + } + int64_t stime = av_rescale_q(is->start_time, AV_TIME_BASE_Q, ist->st->time_base); int64_t stime2= stime + (1ULL<<ist->st->pts_wrap_bits); ist->wrap_correction_done = 1; |