summaryrefslogtreecommitdiff
path: root/libavformat/hlsenc.c
diff options
context:
space:
mode:
authorSteven Liu <lq@chinaffmpeg.org>2020-04-29 20:39:22 +0800
committerSteven Liu <lq@chinaffmpeg.org>2020-05-06 11:32:26 +0800
commita7bab199e50619df0a6d31a247f7186868e6e4e0 (patch)
tree4b46db630edf90ed70ede60b99e1e2d3d236c8ab /libavformat/hlsenc.c
parent03b1b96832d53fc9f9581f06157d6c97ad692d38 (diff)
avformat/hlsenc: compute segment duration use current pts minus last segment end pts
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@tencent.com> Reviewed-by: Zhao Jun <barryjzhao@tencent.com> Signed-off-by: Steven Liu <liuqi05@kuaishou.com>
Diffstat (limited to 'libavformat/hlsenc.c')
-rw-r--r--libavformat/hlsenc.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index 008a3f3947..10984dddb8 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -2463,7 +2463,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) {