[FFmpeg-devel] [PATCH] fix: the "delete-segment" flag did not work properly

develop at focusware.nl develop at focusware.nl
Mon May 16 11:33:51 CEST 2016


From: Boris Nagels <develop at focusware.nl>

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.
---
 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 (Apple Git-63)



More information about the ffmpeg-devel mailing list