[FFmpeg-cvslog] hlsenc: correctly report target duration

Luca Barbato git at videolan.org
Mon Dec 24 14:52:53 CET 2012


ffmpeg | branch: master | Luca Barbato <lu_zero at gentoo.org> | Fri Dec 21 12:05:46 2012 +0100| [7e98956e721ac87c68cd45a8b18ba74e29e1535b] | committer: Luca Barbato

hlsenc: correctly report target duration

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=7e98956e721ac87c68cd45a8b18ba74e29e1535b
---

 libavformat/hlsenc.c |    8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index 9d3b466..e269358 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -122,15 +122,21 @@ static int hls_window(AVFormatContext *s, int last)
 {
     HLSContext *hls = s->priv_data;
     ListEntry *en;
+    int target_duration = 0;
     int ret = 0;
 
     if ((ret = avio_open2(&hls->pb, s->filename, AVIO_FLAG_WRITE,
                           &s->interrupt_callback, NULL)) < 0)
         goto fail;
 
+    for (en = hls->list; en; en = en->next) {
+        if (target_duration < en->duration)
+            target_duration = en->duration;
+    }
+
     avio_printf(hls->pb, "#EXTM3U\n");
     avio_printf(hls->pb, "#EXT-X-VERSION:3\n");
-    avio_printf(hls->pb, "#EXT-X-TARGETDURATION:%d\n", (int)hls->time);
+    avio_printf(hls->pb, "#EXT-X-TARGETDURATION:%d\n", target_duration);
     avio_printf(hls->pb, "#EXT-X-MEDIA-SEQUENCE:%d\n",
                 FFMAX(0, hls->number - hls->size));
 



More information about the ffmpeg-cvslog mailing list