diff mbox

[FFmpeg-devel,2/2] hlsenc: set target duration always exact or longer than max segment duration

Message ID 20180323224251.29626-2-jeebjp@gmail.com
State New
Headers show

Commit Message

Jan Ekström March 23, 2018, 10:42 p.m. UTC
From: Jan Ekström <jan.ekstrom@aminocom.com>

Follows the RFC with floating point durations.
F.ex., 5.005 => 6

Signed-off-by: Jan Ekström <jan.ekstrom@aminocom.com>
---
 libavformat/hlsenc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Steven Liu March 24, 2018, 5:35 a.m. UTC | #1
2018-03-24 6:42 GMT+08:00 Jan Ekström <jeebjp@gmail.com>:
> From: Jan Ekström <jan.ekstrom@aminocom.com>
>
> Follows the RFC with floating point durations.
> F.ex., 5.005 => 6
>
> Signed-off-by: Jan Ekström <jan.ekstrom@aminocom.com>
> ---
>  libavformat/hlsenc.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
> index 07569dbff1..ecb581acb9 100644
> --- a/libavformat/hlsenc.c
> +++ b/libavformat/hlsenc.c
> @@ -1386,7 +1386,8 @@ static int hls_window(AVFormatContext *s, int last, VariantStream *vs)
>
>      for (en = vs->segments; en; en = en->next) {
>          if (target_duration <= en->duration)
> -            target_duration = lrint(en->duration);
> +            /* Target duration has to always be exactly or longer than any segment */
> +            target_duration = ceil(en->duration);
This is not correct, at the specification author said, the duration
should set to 5, not 6, reference link
:https://trac.ffmpeg.org/ticket/6915

Thanks

Steven
Jan Ekström March 24, 2018, 1:25 p.m. UTC | #2
On Sat, Mar 24, 2018 at 7:35 AM, Steven Liu <lingjiujianke@gmail.com> wrote:
> This is not correct, at the specification author said, the duration
> should set to 5, not 6, reference link
> :https://trac.ffmpeg.org/ticket/6915
>
> Thanks
>
> Steven

Right, somehow I missed that "when rounded to the nearest integer"
part when reading https://tools.ietf.org/html/rfc8216#page-22 .

Thus, this one can be considered not needed.

Jan
diff mbox

Patch

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index 07569dbff1..ecb581acb9 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -1386,7 +1386,8 @@  static int hls_window(AVFormatContext *s, int last, VariantStream *vs)
 
     for (en = vs->segments; en; en = en->next) {
         if (target_duration <= en->duration)
-            target_duration = lrint(en->duration);
+            /* Target duration has to always be exactly or longer than any segment */
+            target_duration = ceil(en->duration);
     }
 
     vs->discontinuity_set = 0;