[FFmpeg-devel] [PATCH v2] avformat/hlsenc: compute segment duration use current pts minus last segment end pts
Steven Liu
lq at chinaffmpeg.org
Wed Apr 29 15:39:22 EEST 2020
segment duration is using vs duration which compute by frame per second,
that can not fix problem of VFR video stream, so compute the duration
when split the segment, set the segment target duration use
current packet pts minus the prev segment end pts..
Reported-by: Zhao Jun <barryjzhao at tencent.com>
Signed-off-by: Steven Liu <liuqi05 at kuaishou.com>
---
libavformat/hlsenc.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index d75684741f..4a83db04e9 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -2460,7 +2460,8 @@ static int hls_write_packet(AVFormatContext *s, AVPacket *pkt)
}
if (vs->start_pos || hls->segment_type != SEGMENT_TYPE_FMP4) {
- ret = hls_append_segment(s, hls, vs, vs->duration, vs->start_pos, vs->size);
+ double cur_duration = (double)(pkt->pts - vs->end_pts) * st->time_base.num / st->time_base.den;
+ ret = hls_append_segment(s, hls, vs, cur_duration, vs->start_pos, vs->size);
vs->end_pts = pkt->pts;
vs->duration = 0;
if (ret < 0) {
--
2.25.0
More information about the ffmpeg-devel
mailing list