Commit 526bd7bd authored by Stefano Sabatini's avatar Stefano Sabatini

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.
parent 3d38c990
......@@ -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));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment