[FFmpeg-devel] [PATCH] lavf/segment: fix slight refactor to seg_write_packet

Jason Pontious jpontious at gmail.com
Thu Mar 30 23:43:12 EEST 2017


I found an issue with a previous commit and I'm submitting the patch here.
The previous commit was from March '16 https://github.com/FFmpeg/
FFmpeg/commit/5b4f44f66ae3c42b7497929b6ef5f67e8b1ff0ad

Previous refactor commit did not produce an equivalent segment end_time in
all cases.
When setting end_time, the addition to start_time was completely removed.
---
 libavformat/segment.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavformat/segment.c b/libavformat/segment.c
index 8ec3653..951ca91 100644
--- a/libavformat/segment.c
+++ b/libavformat/segment.c
@@ -904,7 +904,8 @@ calc_times:
         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;
+        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;

         if (seg->times || (!seg->frames && !seg->use_clocktime) &&
seg->write_empty)
             goto calc_times;
-- 
2.9.3


More information about the ffmpeg-devel mailing list