[FFmpeg-devel] [PATCH] avformat/hlsenc: fix duration wrong when no pkt duration

Steven Liu lingjiujianke at gmail.com
Wed Mar 15 01:38:13 EET 2017


2017-03-13 17:12 GMT+08:00 Steven Liu <lq at chinaffmpeg.org>:

> when cannot get pkt duration, hlsenc segments duration will
> be set to 0, this patch can fix it.
>
> Signed-off-by: Steven Liu <lq at chinaffmpeg.org>
> ---
>  libavformat/hlsenc.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
> index 5df2514..d6f0631 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;
> +            }
>          }
>
>      }
> --
> 2.10.1.382.ga23ca1b.dirty
>
>
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>

applied!


More information about the ffmpeg-devel mailing list