diff mbox

[FFmpeg-devel] avformat/dashenc: Fix the EXT-X-TARGETDURATION as per the hls specification

Message ID 1513850991-851-1-git-send-email-kjeyapal@akamai.com
State Accepted
Commit e3b2c8502b33c180e0f053ac2ef32ee782224c2e
Headers show

Commit Message

Jeyapal, Karthick Dec. 21, 2017, 10:09 a.m. UTC
From: Karthick Jeyapal <kjeyapal@akamai.com>

The HLS specification states the following about EXT-X-TARGETDURATION

4.3.3.1.  EXT-X-TARGETDURATION

   The EXT-X-TARGETDURATION tag specifies the maximum Media Segment
   duration.  The EXTINF duration of each Media Segment in the Playlist
   file, when rounded to the nearest integer, MUST be less than or equal
   to the target duration; longer segments can trigger playback stalls
   or other errors.  It applies to the entire Playlist file.  Its format
   is:

   #EXT-X-TARGETDURATION:<s>

   where s is a decimal-integer indicating the target duration in
   seconds.  The EXT-X-TARGETDURATION tag is REQUIRED.

Currently the dashenc rounds the duration to the next integer,
rather than rounding the duration to the nearest integer.
---
 libavformat/dashenc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Carl Eugen Hoyos Dec. 21, 2017, 2:15 p.m. UTC | #1
2017-12-21 11:09 GMT+01:00 Karthick J <kjeyapal@akamai.com>:

>              if (target_duration <= duration)
> -                target_duration = hls_get_int_from_double(duration);
> +                target_duration = lrint(duration);

If this patch gets committed, please move the function
into dashenc.c.

Carl Eugen
Jeyapal, Karthick Dec. 21, 2017, 2:45 p.m. UTC | #2
On 12/21/17 7:45 PM, Carl Eugen Hoyos wrote:
> 2017-12-21 11:09 GMT+01:00 Karthick J <kjeyapal@akamai.com>:
>
>>               if (target_duration <= duration)
>> -                target_duration = hls_get_int_from_double(duration);
>> +                target_duration = lrint(duration);
> If this patch gets committed, please move the function
> into dashenc.c.
I am confused. Which function? Could you please clarify? Did you mean 
lrint() function?
>
> Carl Eugen
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Steven Liu Dec. 21, 2017, 11:37 p.m. UTC | #3
2017-12-21 18:09 GMT+08:00 Karthick J <kjeyapal@akamai.com>:
> From: Karthick Jeyapal <kjeyapal@akamai.com>
>
> The HLS specification states the following about EXT-X-TARGETDURATION
>
> 4.3.3.1.  EXT-X-TARGETDURATION
>
>    The EXT-X-TARGETDURATION tag specifies the maximum Media Segment
>    duration.  The EXTINF duration of each Media Segment in the Playlist
>    file, when rounded to the nearest integer, MUST be less than or equal
>    to the target duration; longer segments can trigger playback stalls
>    or other errors.  It applies to the entire Playlist file.  Its format
>    is:
>
>    #EXT-X-TARGETDURATION:<s>
>
>    where s is a decimal-integer indicating the target duration in
>    seconds.  The EXT-X-TARGETDURATION tag is REQUIRED.
>
> Currently the dashenc rounds the duration to the next integer,
> rather than rounding the duration to the nearest integer.
> ---
>  libavformat/dashenc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
> index 5687530..5368a23 100644
> --- a/libavformat/dashenc.c
> +++ b/libavformat/dashenc.c
> @@ -358,7 +358,7 @@ static void output_segment_list(OutputStream *os, AVIOContext *out, DASHContext
>              Segment *seg = os->segments[i];
>              double duration = (double) seg->duration / timescale;
>              if (target_duration <= duration)
> -                target_duration = hls_get_int_from_double(duration);
> +                target_duration = lrint(duration);
>          }
>
>          ff_hls_write_playlist_header(out_hls, 6, -1, target_duration,
> --
> 1.9.1
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


LGTM, I have checked from HLS Team, Set the EXT-X-TARGETDURATION by
print(EXTINF).


Thanks
Steven Liu Dec. 21, 2017, 11:40 p.m. UTC | #4
2017-12-22 7:37 GMT+08:00 Steven Liu <lingjiujianke@gmail.com>:
> 2017-12-21 18:09 GMT+08:00 Karthick J <kjeyapal@akamai.com>:
>> From: Karthick Jeyapal <kjeyapal@akamai.com>
>>
>> The HLS specification states the following about EXT-X-TARGETDURATION
>>
>> 4.3.3.1.  EXT-X-TARGETDURATION
>>
>>    The EXT-X-TARGETDURATION tag specifies the maximum Media Segment
>>    duration.  The EXTINF duration of each Media Segment in the Playlist
>>    file, when rounded to the nearest integer, MUST be less than or equal
>>    to the target duration; longer segments can trigger playback stalls
>>    or other errors.  It applies to the entire Playlist file.  Its format
>>    is:
>>
>>    #EXT-X-TARGETDURATION:<s>
>>
>>    where s is a decimal-integer indicating the target duration in
>>    seconds.  The EXT-X-TARGETDURATION tag is REQUIRED.
>>
>> Currently the dashenc rounds the duration to the next integer,
>> rather than rounding the duration to the nearest integer.
>> ---
>>  libavformat/dashenc.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
>> index 5687530..5368a23 100644
>> --- a/libavformat/dashenc.c
>> +++ b/libavformat/dashenc.c
>> @@ -358,7 +358,7 @@ static void output_segment_list(OutputStream *os, AVIOContext *out, DASHContext
>>              Segment *seg = os->segments[i];
>>              double duration = (double) seg->duration / timescale;
>>              if (target_duration <= duration)
>> -                target_duration = hls_get_int_from_double(duration);
>> +                target_duration = lrint(duration);
>>          }
>>
>>          ff_hls_write_playlist_header(out_hls, 6, -1, target_duration,
>> --
>> 1.9.1
>>
>> _______________________________________________
>> ffmpeg-devel mailing list
>> ffmpeg-devel@ffmpeg.org
>> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
>
> LGTM, I have checked from HLS Team, Set the EXT-X-TARGETDURATION by
> print(EXTINF).

And will apply the old version modify hlsenc patch,


Thanks
>
>
> Thanks
Jeyapal, Karthick Dec. 22, 2017, 5:30 a.m. UTC | #5
On 12/22/17, 5:08 AM, "Steven Liu" <lingjiujianke@gmail.com> wrote:
>

>2017-12-21 18:09 GMT+08:00 Karthick J <kjeyapal@akamai.com>:

>> From: Karthick Jeyapal <kjeyapal@akamai.com>

>>

>> The HLS specification states the following about EXT-X-TARGETDURATION

>> […]

>

>LGTM, I have checked from HLS Team, Set the EXT-X-TARGETDURATION by

>print(EXTINF).

Oh, I am glad we are finally in agreement! 
I appreciate you for following it up with Apple’s HLS author for the confirmation.

Thanks and regards,
Karthick
>

>

>Thanks
diff mbox

Patch

diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index 5687530..5368a23 100644
--- a/libavformat/dashenc.c
+++ b/libavformat/dashenc.c
@@ -358,7 +358,7 @@  static void output_segment_list(OutputStream *os, AVIOContext *out, DASHContext
             Segment *seg = os->segments[i];
             double duration = (double) seg->duration / timescale;
             if (target_duration <= duration)
-                target_duration = hls_get_int_from_double(duration);
+                target_duration = lrint(duration);
         }
 
         ff_hls_write_playlist_header(out_hls, 6, -1, target_duration,