diff options
author | Steven Liu <lq@chinaffmpeg.org> | 2017-03-15 07:37:11 +0800 |
---|---|---|
committer | Steven Liu <lq@chinaffmpeg.org> | 2017-03-15 07:37:11 +0800 |
commit | e90ad882819cc46add0ea5ad2cef81490cef96c4 (patch) | |
tree | 0891a7a6d8222d43be96fa329af1f45ea4b2656b /libavformat/hlsenc.c | |
parent | 55eab1733b9e730ceac33edce9aab56c17ea87b2 (diff) | |
download | ffmpeg-e90ad882819cc46add0ea5ad2cef81490cef96c4.tar.gz |
avformat/hlsenc: fix duration wrong when no pkt duration
when cannot get pkt duration, hlsenc segments duration will
be set to 0, this patch can fix it.
Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
Diffstat (limited to 'libavformat/hlsenc.c')
-rw-r--r-- | libavformat/hlsenc.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c index e2c021b754..e6c378df2e 100644 --- a/libavformat/hlsenc.c +++ b/libavformat/hlsenc.c @@ -1354,7 +1354,12 @@ static int hls_write_packet(AVFormatContext *s, AVPacket *pkt) * st->time_base.num / st->time_base.den; hls->dpp = (double)(pkt->duration) * st->time_base.num / st->time_base.den; } else { - hls->duration += (double)(pkt->duration) * st->time_base.num / st->time_base.den; + if (pkt->duration) { + hls->duration += (double)(pkt->duration) * st->time_base.num / st->time_base.den; + } else { + av_log(s, AV_LOG_WARNING, "pkt->duration = 0, maybe the hls segment duration will not precise\n"); + hls->duration = (double)(pkt->pts - hls->end_pts) * st->time_base.num / st->time_base.den; + } } } |