[FFmpeg-devel] [PATCH 1/7] avformat/hlsenc: correctly compute target duration

Stefano Sabatini stefasab at gmail.com
Tue Jul 22 15:01:09 CEST 2014


On date Friday 2014-07-18 10:57:41 +0200, Nicolas Martyanoff encoded:
> With HLS, the duration of all segments must be lower or equal to the target
> duration. Therefore floor(duration + 0.5) yields incorrect results.
> 
> For example, for duration = 1.35, floor(duration + 0.5) yields 1.0, but the
> correct result is 2.0.
> ---
>  libavformat/hlsenc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
> index 86447d8..388a23a 100644
> --- a/libavformat/hlsenc.c
> +++ b/libavformat/hlsenc.c
> @@ -141,7 +141,7 @@ static int hls_window(AVFormatContext *s, int last)
>  
>      for (en = hls->list; en; en = en->next) {
>          if (target_duration < en->duration)
> -            target_duration = (int) floor(en->duration + 0.5);
> +            target_duration = ceil(en->duration);
>      }

LGTM.
-- 
FFmpeg = Formidable & Free Most Pitiless Extroverse Gadget


More information about the ffmpeg-devel mailing list