Browse Source

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>
tags/n3.3
Steven Liu 9 years ago
parent
commit
e90ad88281
1 changed files with 6 additions and 1 deletions
  1. +6
    -1
      libavformat/hlsenc.c

+ 6
- 1
libavformat/hlsenc.c View File

@@ -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;
}
}

}


Loading…
Cancel
Save