Hi Guys,

     The FFmpeg hls module can make m3u8 and ts, but it dosen't delete the
old ts segment file.
      If always run this module, the disk will full, so this patch can fix
the problem.
      When update the segment list m3u8 file, it will delete the ts segment
out range from the list file.

     before use this patch:
[root@localhost ffmpeg]# ls *.ts *.m3u8
a0.ts  a10.ts  a11.ts  a12.ts  a13.ts  a14.ts  a15.ts  a16.ts  a17.ts
a18.ts  a19.ts  a1.ts  a20.ts  a2.ts  a3.ts  a4.ts  a5.ts  a6.ts  a7.ts
a8.ts  a9.ts  a.m3u8
[root@localhost ffmpeg]# cat a.m3u8
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-TARGETDURATION:11
#EXT-X-MEDIA-SEQUENCE:16
#EXTINF:10.427075,
a16.ts
#EXTINF:10.427075,
a17.ts
#EXTINF:10.427075,
a18.ts
#EXTINF:10.427075,
a19.ts
#EXTINF:3.670330,
a20.ts
#EXT-X-ENDLIST
[root@localhost ffmpeg]#

after use this patch:
[root@localhost ffmpeg]# ls *.ts *.m3u8
a10.ts  a11.ts  a12.ts  a13.ts  a9.ts  a.m3u8
[root@localhost ffmpeg]# cat a.m3u8
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-TARGETDURATION:11
#EXT-X-MEDIA-SEQUENCE:9
#EXTINF:10.427075,
a9.ts
#EXTINF:10.427075,
a10.ts
#EXTINF:10.427075,
a11.ts
#EXTINF:10.427075,
a12.ts
#EXTINF:2.335665,
a13.ts
#EXT-X-ENDLIST
[root@localhost ffmpeg]#

-------------------------------------------
The patch context:

when update the hls m3u8 list, the old file is not unlinked
this patch can do this operation

Signed-off-by: Steven Liu <qi....@chinacache.com>
---
 libavformat/hlsenc.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index 11f1e5b..2ee0970 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -30,6 +30,10 @@

 #include "avformat.h"
 #include "internal.h"
+#if HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+

 typedef struct HLSSegment {
     char filename[1024];
@@ -115,6 +119,7 @@ static int hls_append_segment(HLSContext *hls, double
duration)
     if (hls->max_nb_segments && hls->nb_entries >= hls->max_nb_segments) {
         en = hls->segments;
         hls->segments = en->next;
+        unlink(en->filename);
         av_free(en);
     } else
         hls->nb_entries++;
--
1.7.1
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

Reply via email to