[FFmpeg-devel] [PATCH] fix: the "delete-segment" flag did not work properly (implementation in commit 97b65f6). The set length of the list was populated twice (e.g. setting the list-size to 10, creates a list of approx. 20 files). Now calculation works on the theoretical playlist length compensated for the segment lengths that are currently in the playlist.

develop at focusware.nl develop at focusware.nl
Mon Mar 14 17:43:29 CET 2016


From: Boris Nagels <develop at focusware.nl>

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

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index 7ab7cbb..c6ab7c5 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -126,12 +126,17 @@ static int hls_delete_old_segments(HLSContext *hls) {
     char *dirname = NULL, *p, *sub_path;
     char *path = NULL;
 
+	// Calculate the maximum playlist duration.
+	playlist_duration = hls->max_nb_segments * hls->time;
+
+	// Compensate for the segments that are currently in the playlist.
     segment = hls->segments;
     while (segment) {
-        playlist_duration += segment->duration;
+        playlist_duration -= segment->duration;
         segment = segment->next;
     }
 
+	// Check the old-segments.
     segment = hls->old_segments;
     while (segment) {
         playlist_duration -= segment->duration;
-- 
2.6.4



More information about the ffmpeg-devel mailing list