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

Submitted by kjeyapal@akamai.com on Dec. 21, 2017, 3:41 p.m.

Details

Message ID 1513870872-21179-1-git-send-email-kjeyapal@akamai.com
State New
Headers show

Commit Message

kjeyapal@akamai.com Dec. 21, 2017, 3:41 p.m.
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(-)

Patch hide | download patch | download mbox

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,