Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FFmpeg/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefano Sabatini <stefasab@gmail.com>2014-07-17 18:36:27 +0400
committerStefano Sabatini <stefasab@gmail.com>2014-07-17 18:51:51 +0400
commit526bd7bdfad7d0e7b18ee45592e68c881abeac2a (patch)
treeb339d26a94b9cc3d8272cd853e8f9a4507dc3ea5 /libavformat/segment.c
parent3d38c9904121b39eff41e8150fdd1ec523f290c7 (diff)
lavf/segment: set segment end time when the first packet arrives
Avoid negative durations in case there is a single packet in the current segment, since in that case the end time is still set to the previous segment end time.
Diffstat (limited to 'libavformat/segment.c')
-rw-r--r--libavformat/segment.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/libavformat/segment.c b/libavformat/segment.c
index c25a2951c4..72bf5e0880 100644
--- a/libavformat/segment.c
+++ b/libavformat/segment.c
@@ -729,6 +729,8 @@ static int seg_write_packet(AVFormatContext *s, AVPacket *pkt)
seg->cur_entry.index = seg->segment_idx + seg->segment_idx_wrap*seg->segment_idx_wrap_nb;
seg->cur_entry.start_time = (double)pkt->pts * av_q2d(st->time_base);
seg->cur_entry.start_pts = av_rescale_q(pkt->pts, st->time_base, AV_TIME_BASE_Q);
+ seg->cur_entry.end_time = seg->cur_entry.start_time +
+ pkt->pts != AV_NOPTS_VALUE ? (double)(pkt->pts + pkt->duration) * av_q2d(st->time_base) : 0;
} else if (pkt->pts != AV_NOPTS_VALUE && pkt->stream_index == seg->reference_stream_index) {
seg->cur_entry.end_time =
FFMAX(seg->cur_entry.end_time, (double)(pkt->pts + pkt->duration) * av_q2d(st->time_base));