Re: [FFmpeg-devel] [PATCH] delete the old segment file from hls list

2014-09-01 Thread Anshul


On 8/31/2014 8:28 PM, Steven Liu wrote:

CC  Anshul

The Follow is the result of the parameter with -hls_wrap 7,It in the older
mail of this mail list.

When use the option  -hls_wrap 7
./ffmpeg -i shaolinzuqiu.rm -vcodec libx264 -preset ultrafast -an -f hls
-hls_wrap 7 a.m3u8
it dose not remove the nouse file:
[root@localhost ffmpeg]# ls *.ts;cat a.m3u8
a0.ts  a1.ts  a2.ts  a3.ts  a4.ts  a5.ts  a6.ts

#EXTM3U
#EXT-X-VERSION:3
#EXT-X-TARGETDURATION:11
#EXT-X-MEDIA-SEQUENCE:20
#EXTINF:10.427075,
a6.ts
#EXTINF:10.427075,
a0.ts
#EXTINF:10.427075,
a1.ts
#EXTINF:10.427075,
a2.ts
#EXTINF:10.427075,
a3.ts
If you knew this, and still want to add your patch, then carry on(I wont 
bother you).

Thanks
Anshul
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] delete the old segment file from hls list

2014-08-31 Thread Steven Liu
CC  Anshul

The Follow is the result of the parameter with -hls_wrap 7,It in the older
mail of this mail list.

When use the option  -hls_wrap 7
./ffmpeg -i shaolinzuqiu.rm -vcodec libx264 -preset ultrafast -an -f hls
-hls_wrap 7 a.m3u8
it dose not remove the nouse file:
[root@localhost ffmpeg]# ls *.ts;cat a.m3u8
a0.ts  a1.ts  a2.ts  a3.ts  a4.ts  a5.ts  a6.ts

#EXTM3U
#EXT-X-VERSION:3
#EXT-X-TARGETDURATION:11
#EXT-X-MEDIA-SEQUENCE:20
#EXTINF:10.427075,
a6.ts
#EXTINF:10.427075,
a0.ts
#EXTINF:10.427075,
a1.ts
#EXTINF:10.427075,
a2.ts
#EXTINF:10.427075,
a3.ts


2014-08-30 18:34 GMT+08:00 Anshul :

> On August 30, 2014 8:57:12 AM IST, Steven Liu 
> wrote:
> >
> >On Aug 28, 2014, at 4:52 AM, Anshul  wrote:
> >
> >> On August 22, 2014 8:01:20 AM IST, Steven Liu
> > wrote:
> >>> repost new patch:
> >>>
> >>> when update the hls m3u8 list, the old file is not unlinked
> >>> this patch can do this operation
> >>> delete the old ts segment which not show in m3u8,
> >>> use hls_sync_list.
> >>>
> >>> Signed-off-by: Steven Liu 
> >>> ---
> >>> libavformat/hlsenc.c |   15 ++-
> >>> 1 files changed, 14 insertions(+), 1 deletions(-)
> >>>
> >>> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
> >>> index 11f1e5b..fc1063e 100644
> >>> --- a/libavformat/hlsenc.c
> >>> +++ b/libavformat/hlsenc.c
> >>> @@ -30,6 +30,10 @@
> >>>
> >>> #include "avformat.h"
> >>> #include "internal.h"
> >>> +#if HAVE_UNISTD_H
> >>> +#include 
> >>> +#endif
> >>> +
> >>>
> >>> typedef struct HLSSegment {
> >>>char filename[1024];
> >>> @@ -50,6 +54,7 @@ typedef struct HLSContext {
> >>>float time;// Set by a private option.
> >>>int max_nb_segments;   // Set by a private option.
> >>>int  wrap; // Set by a private option.
> >>> +int  sync_list;
> >>>
> >>>int64_t recording_time;
> >>>int has_video;
> >>> @@ -96,6 +101,7 @@ static int hls_mux_init(AVFormatContext *s)
> >>> static int hls_append_segment(HLSContext *hls, double duration)
> >>> {
> >>>HLSSegment *en = av_malloc(sizeof(*en));
> >>> +int ret = 0;
> >>>
> >>>if (!en)
> >>>return AVERROR(ENOMEM);
> >>> @@ -115,7 +121,13 @@ 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;
> >>> -av_free(en);
> >>> +if (hls->sync_list) {
> >>> +ret = unlink(en->filename);
> >>> +if (ret < 0) {
> >>> +av_log(hls->avf, AV_LOG_WARNING, "remove %s
> >failed\n",
> >>> en->filename);
> >>> +}
> >>> +}
> >>> +av_free(en);
> >>>} else
> >>>hls->nb_entries++;
> >>>
> >>> @@ -340,6 +352,7 @@ static const AVOption options[] = {
> >>>{"hls_list_size", "set maximum number of playlist entries",
> >>> OFFSET(max_nb_segments),AV_OPT_TYPE_INT,{.i64 = 5}, 0,
> >>> INT_MAX,
> >>> E},
> >>>{"hls_wrap",  "set number after which the index wraps",
> >>> OFFSET(wrap),AV_OPT_TYPE_INT,{.i64 = 0}, 0, INT_MAX, E},
> >>>{"hls_base_url",  "url to prepend to each playlist entry",
> >>> OFFSET(baseurl), AV_OPT_TYPE_STRING, {.str = NULL},  0, 0,   E},
> >>> +{"hls_sync_list", "remove old ts segment for sync the file with
> >>> the
> >>> m3u8 list",  OFFSET(sync_list),AV_OPT_TYPE_INT,{.i64 = 0},
> >
> >>> 0,
> >>> INT_MAX, E},
> >>>{ NULL },
> >>> };
> >>>
> >>> --
> >>> 1.7.1
> >>>
> >>>
> >>>
> >>> 2014-08-21 16:51 GMT+08:00 Steven Liu :
> >>>
>  Hi Stefano,
>  if unistd is not available under Linux,
>  it will output error message when compile the source code.
> 
>   [root@testrtmp ffmpeg]# make
>  CC  libavformat/hlsenc.o
>  libavformat/hlsenc.c: In function ‘hls_append_segment’:
>  libavformat/hlsenc.c:125: error: implicit declaration of function
> >>> ‘unlink’
>  make: *** [libavformat/hlsenc.o] Error 1
>  [root@testrtmp ffmpeg]#
> 
> 
> 
>  the follow is the new patch:
> 
>  diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
>  index 11f1e5b..fc1063e 100644
> 
>  --- a/libavformat/hlsenc.c
>  +++ b/libavformat/hlsenc.c
>  @@ -30,6 +30,10 @@
> 
>  #include "avformat.h"
>  #include "internal.h"
>  +#if HAVE_UNISTD_H
>  +#include 
>  +#endif
>  +
> 
>  typedef struct HLSSegment {
>  char filename[1024];
>  @@ -50,6 +54,7 @@ typedef struct HLSContext {
>  float time;// Set by a private option.
>  int max_nb_segments;   // Set by a private option.
>  int  wrap; // Set by a private option.
>  +int  sync_list;// Set by a private option.
> 
>  int64_t recording_time;
>  int has_video;
>  @@ -96,6 +101,7 @@ static int hls_mux_init(AVFormatContext *s)
> 
>  static int hls_append_segm

Re: [FFmpeg-devel] [PATCH] delete the old segment file from hls list

2014-08-30 Thread Anshul
On August 30, 2014 8:57:12 AM IST, Steven Liu  wrote:
>
>On Aug 28, 2014, at 4:52 AM, Anshul  wrote:
>
>> On August 22, 2014 8:01:20 AM IST, Steven Liu
> wrote:
>>> repost new patch:
>>> 
>>> when update the hls m3u8 list, the old file is not unlinked
>>> this patch can do this operation
>>> delete the old ts segment which not show in m3u8,
>>> use hls_sync_list.
>>> 
>>> Signed-off-by: Steven Liu 
>>> ---
>>> libavformat/hlsenc.c |   15 ++-
>>> 1 files changed, 14 insertions(+), 1 deletions(-)
>>> 
>>> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
>>> index 11f1e5b..fc1063e 100644
>>> --- a/libavformat/hlsenc.c
>>> +++ b/libavformat/hlsenc.c
>>> @@ -30,6 +30,10 @@
>>> 
>>> #include "avformat.h"
>>> #include "internal.h"
>>> +#if HAVE_UNISTD_H
>>> +#include 
>>> +#endif
>>> +
>>> 
>>> typedef struct HLSSegment {
>>>char filename[1024];
>>> @@ -50,6 +54,7 @@ typedef struct HLSContext {
>>>float time;// Set by a private option.
>>>int max_nb_segments;   // Set by a private option.
>>>int  wrap; // Set by a private option.
>>> +int  sync_list;
>>> 
>>>int64_t recording_time;
>>>int has_video;
>>> @@ -96,6 +101,7 @@ static int hls_mux_init(AVFormatContext *s)
>>> static int hls_append_segment(HLSContext *hls, double duration)
>>> {
>>>HLSSegment *en = av_malloc(sizeof(*en));
>>> +int ret = 0;
>>> 
>>>if (!en)
>>>return AVERROR(ENOMEM);
>>> @@ -115,7 +121,13 @@ 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;
>>> -av_free(en);
>>> +if (hls->sync_list) {
>>> +ret = unlink(en->filename);
>>> +if (ret < 0) {
>>> +av_log(hls->avf, AV_LOG_WARNING, "remove %s
>failed\n",
>>> en->filename);
>>> +}
>>> +}
>>> +av_free(en);
>>>} else
>>>hls->nb_entries++;
>>> 
>>> @@ -340,6 +352,7 @@ static const AVOption options[] = {
>>>{"hls_list_size", "set maximum number of playlist entries",
>>> OFFSET(max_nb_segments),AV_OPT_TYPE_INT,{.i64 = 5}, 0,
>>> INT_MAX,
>>> E},
>>>{"hls_wrap",  "set number after which the index wraps",
>>> OFFSET(wrap),AV_OPT_TYPE_INT,{.i64 = 0}, 0, INT_MAX, E},
>>>{"hls_base_url",  "url to prepend to each playlist entry",
>>> OFFSET(baseurl), AV_OPT_TYPE_STRING, {.str = NULL},  0, 0,   E},
>>> +{"hls_sync_list", "remove old ts segment for sync the file with
>>> the
>>> m3u8 list",  OFFSET(sync_list),AV_OPT_TYPE_INT,{.i64 = 0},  
> 
>>> 0,
>>> INT_MAX, E},
>>>{ NULL },
>>> };
>>> 
>>> --
>>> 1.7.1
>>> 
>>> 
>>> 
>>> 2014-08-21 16:51 GMT+08:00 Steven Liu :
>>> 
 Hi Stefano,
 if unistd is not available under Linux,
 it will output error message when compile the source code.
 
  [root@testrtmp ffmpeg]# make
 CC  libavformat/hlsenc.o
 libavformat/hlsenc.c: In function ‘hls_append_segment’:
 libavformat/hlsenc.c:125: error: implicit declaration of function
>>> ‘unlink’
 make: *** [libavformat/hlsenc.o] Error 1
 [root@testrtmp ffmpeg]#
 
 
 
 the follow is the new patch:
 
 diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
 index 11f1e5b..fc1063e 100644
 
 --- a/libavformat/hlsenc.c
 +++ b/libavformat/hlsenc.c
 @@ -30,6 +30,10 @@
 
 #include "avformat.h"
 #include "internal.h"
 +#if HAVE_UNISTD_H
 +#include 
 +#endif
 +
 
 typedef struct HLSSegment {
 char filename[1024];
 @@ -50,6 +54,7 @@ typedef struct HLSContext {
 float time;// Set by a private option.
 int max_nb_segments;   // Set by a private option.
 int  wrap; // Set by a private option.
 +int  sync_list;// Set by a private option.
 
 int64_t recording_time;
 int has_video;
 @@ -96,6 +101,7 @@ static int hls_mux_init(AVFormatContext *s)
 
 static int hls_append_segment(HLSContext *hls, double duration)
 {
 HLSSegment *en = av_malloc(sizeof(*en));
 +   int ret = 0;
 
 if (!en)
 return AVERROR(ENOMEM);
 @@ -115,7 +121,13 @@ 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;
 -av_free(en);
 +if (hls->sync_list) {
 +ret = unlink(en->filename);
 +if (ret < 0) {
 +av_log(hls->avf, AV_LOG_WARNING, "remove %s
>>> failed\n",
 en->filename);
 +}
 +}
 +   av_free(en);
 } else
 hls->nb_entries++;
 
 @@ -340,6 +352,7 @@ static const AVOption o

Re: [FFmpeg-devel] [PATCH] delete the old segment file from hls list

2014-08-29 Thread Steven Liu

On Aug 28, 2014, at 4:52 AM, Anshul  wrote:

> On August 22, 2014 8:01:20 AM IST, Steven Liu  wrote:
>> repost new patch:
>> 
>> when update the hls m3u8 list, the old file is not unlinked
>> this patch can do this operation
>> delete the old ts segment which not show in m3u8,
>> use hls_sync_list.
>> 
>> Signed-off-by: Steven Liu 
>> ---
>> libavformat/hlsenc.c |   15 ++-
>> 1 files changed, 14 insertions(+), 1 deletions(-)
>> 
>> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
>> index 11f1e5b..fc1063e 100644
>> --- a/libavformat/hlsenc.c
>> +++ b/libavformat/hlsenc.c
>> @@ -30,6 +30,10 @@
>> 
>> #include "avformat.h"
>> #include "internal.h"
>> +#if HAVE_UNISTD_H
>> +#include 
>> +#endif
>> +
>> 
>> typedef struct HLSSegment {
>>char filename[1024];
>> @@ -50,6 +54,7 @@ typedef struct HLSContext {
>>float time;// Set by a private option.
>>int max_nb_segments;   // Set by a private option.
>>int  wrap; // Set by a private option.
>> +int  sync_list;
>> 
>>int64_t recording_time;
>>int has_video;
>> @@ -96,6 +101,7 @@ static int hls_mux_init(AVFormatContext *s)
>> static int hls_append_segment(HLSContext *hls, double duration)
>> {
>>HLSSegment *en = av_malloc(sizeof(*en));
>> +int ret = 0;
>> 
>>if (!en)
>>return AVERROR(ENOMEM);
>> @@ -115,7 +121,13 @@ 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;
>> -av_free(en);
>> +if (hls->sync_list) {
>> +ret = unlink(en->filename);
>> +if (ret < 0) {
>> +av_log(hls->avf, AV_LOG_WARNING, "remove %s failed\n",
>> en->filename);
>> +}
>> +}
>> +av_free(en);
>>} else
>>hls->nb_entries++;
>> 
>> @@ -340,6 +352,7 @@ static const AVOption options[] = {
>>{"hls_list_size", "set maximum number of playlist entries",
>> OFFSET(max_nb_segments),AV_OPT_TYPE_INT,{.i64 = 5}, 0,
>> INT_MAX,
>> E},
>>{"hls_wrap",  "set number after which the index wraps",
>> OFFSET(wrap),AV_OPT_TYPE_INT,{.i64 = 0}, 0, INT_MAX, E},
>>{"hls_base_url",  "url to prepend to each playlist entry",
>> OFFSET(baseurl), AV_OPT_TYPE_STRING, {.str = NULL},  0, 0,   E},
>> +{"hls_sync_list", "remove old ts segment for sync the file with
>> the
>> m3u8 list",  OFFSET(sync_list),AV_OPT_TYPE_INT,{.i64 = 0},
>> 0,
>> INT_MAX, E},
>>{ NULL },
>> };
>> 
>> --
>> 1.7.1
>> 
>> 
>> 
>> 2014-08-21 16:51 GMT+08:00 Steven Liu :
>> 
>>> Hi Stefano,
>>> if unistd is not available under Linux,
>>> it will output error message when compile the source code.
>>> 
>>>  [root@testrtmp ffmpeg]# make
>>> CC  libavformat/hlsenc.o
>>> libavformat/hlsenc.c: In function ‘hls_append_segment’:
>>> libavformat/hlsenc.c:125: error: implicit declaration of function
>> ‘unlink’
>>> make: *** [libavformat/hlsenc.o] Error 1
>>> [root@testrtmp ffmpeg]#
>>> 
>>> 
>>> 
>>> the follow is the new patch:
>>> 
>>> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
>>> index 11f1e5b..fc1063e 100644
>>> 
>>> --- a/libavformat/hlsenc.c
>>> +++ b/libavformat/hlsenc.c
>>> @@ -30,6 +30,10 @@
>>> 
>>> #include "avformat.h"
>>> #include "internal.h"
>>> +#if HAVE_UNISTD_H
>>> +#include 
>>> +#endif
>>> +
>>> 
>>> typedef struct HLSSegment {
>>> char filename[1024];
>>> @@ -50,6 +54,7 @@ typedef struct HLSContext {
>>> float time;// Set by a private option.
>>> int max_nb_segments;   // Set by a private option.
>>> int  wrap; // Set by a private option.
>>> +int  sync_list;// Set by a private option.
>>> 
>>> int64_t recording_time;
>>> int has_video;
>>> @@ -96,6 +101,7 @@ static int hls_mux_init(AVFormatContext *s)
>>> 
>>> static int hls_append_segment(HLSContext *hls, double duration)
>>> {
>>> HLSSegment *en = av_malloc(sizeof(*en));
>>> +   int ret = 0;
>>> 
>>> if (!en)
>>> return AVERROR(ENOMEM);
>>> @@ -115,7 +121,13 @@ 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;
>>> -av_free(en);
>>> +if (hls->sync_list) {
>>> +ret = unlink(en->filename);
>>> +if (ret < 0) {
>>> +av_log(hls->avf, AV_LOG_WARNING, "remove %s
>> failed\n",
>>> en->filename);
>>> +}
>>> +}
>>> +   av_free(en);
>>> } else
>>> hls->nb_entries++;
>>> 
>>> @@ -340,6 +352,7 @@ static const AVOption options[] = {
>>> {"hls_list_size", "set maximum number of playlist entries",
>>> OFFSET(max_nb_segments),AV_OPT_TYPE_INT,{.i64 = 5}, 0,
>> INT_MAX,
>>> E},
>>> {"hls_wrap",  "set number after wh

Re: [FFmpeg-devel] [PATCH] delete the old segment file from hls list

2014-08-27 Thread Anshul
On August 22, 2014 8:01:20 AM IST, Steven Liu  wrote:
>repost new patch:
>
>when update the hls m3u8 list, the old file is not unlinked
>this patch can do this operation
>delete the old ts segment which not show in m3u8,
>use hls_sync_list.
>
>Signed-off-by: Steven Liu 
>---
> libavformat/hlsenc.c |   15 ++-
> 1 files changed, 14 insertions(+), 1 deletions(-)
>
>diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
>index 11f1e5b..fc1063e 100644
>--- a/libavformat/hlsenc.c
>+++ b/libavformat/hlsenc.c
>@@ -30,6 +30,10 @@
>
> #include "avformat.h"
> #include "internal.h"
>+#if HAVE_UNISTD_H
>+#include 
>+#endif
>+
>
> typedef struct HLSSegment {
> char filename[1024];
>@@ -50,6 +54,7 @@ typedef struct HLSContext {
> float time;// Set by a private option.
> int max_nb_segments;   // Set by a private option.
> int  wrap; // Set by a private option.
>+int  sync_list;
>
> int64_t recording_time;
> int has_video;
>@@ -96,6 +101,7 @@ static int hls_mux_init(AVFormatContext *s)
> static int hls_append_segment(HLSContext *hls, double duration)
> {
> HLSSegment *en = av_malloc(sizeof(*en));
>+int ret = 0;
>
> if (!en)
> return AVERROR(ENOMEM);
>@@ -115,7 +121,13 @@ 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;
>-av_free(en);
>+if (hls->sync_list) {
>+ret = unlink(en->filename);
>+if (ret < 0) {
>+av_log(hls->avf, AV_LOG_WARNING, "remove %s failed\n",
>en->filename);
>+}
>+}
>+av_free(en);
> } else
> hls->nb_entries++;
>
>@@ -340,6 +352,7 @@ static const AVOption options[] = {
> {"hls_list_size", "set maximum number of playlist entries",
>OFFSET(max_nb_segments),AV_OPT_TYPE_INT,{.i64 = 5}, 0,
>INT_MAX,
>E},
> {"hls_wrap",  "set number after which the index wraps",
>OFFSET(wrap),AV_OPT_TYPE_INT,{.i64 = 0}, 0, INT_MAX, E},
> {"hls_base_url",  "url to prepend to each playlist entry",
>OFFSET(baseurl), AV_OPT_TYPE_STRING, {.str = NULL},  0, 0,   E},
>+{"hls_sync_list", "remove old ts segment for sync the file with
>the
>m3u8 list",  OFFSET(sync_list),AV_OPT_TYPE_INT,{.i64 = 0},
>0,
>INT_MAX, E},
> { NULL },
> };
>
>--
>1.7.1
>
>
>
>2014-08-21 16:51 GMT+08:00 Steven Liu :
>
>> Hi Stefano,
>> if unistd is not available under Linux,
>> it will output error message when compile the source code.
>>
>>   [root@testrtmp ffmpeg]# make
>> CC  libavformat/hlsenc.o
>> libavformat/hlsenc.c: In function ‘hls_append_segment’:
>> libavformat/hlsenc.c:125: error: implicit declaration of function
>‘unlink’
>> make: *** [libavformat/hlsenc.o] Error 1
>> [root@testrtmp ffmpeg]#
>>
>>
>>
>> the follow is the new patch:
>>
>> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
>> index 11f1e5b..fc1063e 100644
>>
>> --- a/libavformat/hlsenc.c
>> +++ b/libavformat/hlsenc.c
>> @@ -30,6 +30,10 @@
>>
>>  #include "avformat.h"
>>  #include "internal.h"
>> +#if HAVE_UNISTD_H
>> +#include 
>> +#endif
>> +
>>
>>  typedef struct HLSSegment {
>>  char filename[1024];
>> @@ -50,6 +54,7 @@ typedef struct HLSContext {
>>  float time;// Set by a private option.
>>  int max_nb_segments;   // Set by a private option.
>>  int  wrap; // Set by a private option.
>> +int  sync_list;// Set by a private option.
>>
>>  int64_t recording_time;
>>  int has_video;
>> @@ -96,6 +101,7 @@ static int hls_mux_init(AVFormatContext *s)
>>
>>  static int hls_append_segment(HLSContext *hls, double duration)
>>  {
>>  HLSSegment *en = av_malloc(sizeof(*en));
>> +   int ret = 0;
>>
>>  if (!en)
>>  return AVERROR(ENOMEM);
>> @@ -115,7 +121,13 @@ 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;
>> -av_free(en);
>> +if (hls->sync_list) {
>> +ret = unlink(en->filename);
>> +if (ret < 0) {
>> +av_log(hls->avf, AV_LOG_WARNING, "remove %s
>failed\n",
>> en->filename);
>> +}
>> +}
>> +   av_free(en);
>>  } else
>>  hls->nb_entries++;
>>
>> @@ -340,6 +352,7 @@ static const AVOption options[] = {
>>  {"hls_list_size", "set maximum number of playlist entries",
>> OFFSET(max_nb_segments),AV_OPT_TYPE_INT,{.i64 = 5}, 0,
>INT_MAX,
>> E},
>>  {"hls_wrap",  "set number after which the index wraps",
>> OFFSET(wrap),AV_OPT_TYPE_INT,{.i64 = 0}, 0, INT_MAX, E},
>>  {"hls_base_url",  "url to prepend to each playlist entry",
>> OFFSET(baseurl), AV_OPT_TYPE_STRING, {.str = NULL},  0, 0,   E},
>> +{"hls_

Re: [FFmpeg-devel] [PATCH] delete the old segment file from hls list

2014-08-21 Thread Steven Liu
repost new patch:

when update the hls m3u8 list, the old file is not unlinked
this patch can do this operation
delete the old ts segment which not show in m3u8,
use hls_sync_list.

Signed-off-by: Steven Liu 
---
 libavformat/hlsenc.c |   15 ++-
 1 files changed, 14 insertions(+), 1 deletions(-)

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

 #include "avformat.h"
 #include "internal.h"
+#if HAVE_UNISTD_H
+#include 
+#endif
+

 typedef struct HLSSegment {
 char filename[1024];
@@ -50,6 +54,7 @@ typedef struct HLSContext {
 float time;// Set by a private option.
 int max_nb_segments;   // Set by a private option.
 int  wrap; // Set by a private option.
+int  sync_list;

 int64_t recording_time;
 int has_video;
@@ -96,6 +101,7 @@ static int hls_mux_init(AVFormatContext *s)
 static int hls_append_segment(HLSContext *hls, double duration)
 {
 HLSSegment *en = av_malloc(sizeof(*en));
+int ret = 0;

 if (!en)
 return AVERROR(ENOMEM);
@@ -115,7 +121,13 @@ 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;
-av_free(en);
+if (hls->sync_list) {
+ret = unlink(en->filename);
+if (ret < 0) {
+av_log(hls->avf, AV_LOG_WARNING, "remove %s failed\n",
en->filename);
+}
+}
+av_free(en);
 } else
 hls->nb_entries++;

@@ -340,6 +352,7 @@ static const AVOption options[] = {
 {"hls_list_size", "set maximum number of playlist entries",
OFFSET(max_nb_segments),AV_OPT_TYPE_INT,{.i64 = 5}, 0, INT_MAX,
E},
 {"hls_wrap",  "set number after which the index wraps",
OFFSET(wrap),AV_OPT_TYPE_INT,{.i64 = 0}, 0, INT_MAX, E},
 {"hls_base_url",  "url to prepend to each playlist entry",
OFFSET(baseurl), AV_OPT_TYPE_STRING, {.str = NULL},  0, 0,   E},
+{"hls_sync_list", "remove old ts segment for sync the file with the
m3u8 list",  OFFSET(sync_list),AV_OPT_TYPE_INT,{.i64 = 0}, 0,
INT_MAX, E},
 { NULL },
 };

--
1.7.1



2014-08-21 16:51 GMT+08:00 Steven Liu :

> Hi Stefano,
> if unistd is not available under Linux,
> it will output error message when compile the source code.
>
>   [root@testrtmp ffmpeg]# make
> CC  libavformat/hlsenc.o
> libavformat/hlsenc.c: In function ‘hls_append_segment’:
> libavformat/hlsenc.c:125: error: implicit declaration of function ‘unlink’
> make: *** [libavformat/hlsenc.o] Error 1
> [root@testrtmp ffmpeg]#
>
>
>
> the follow is the new patch:
>
> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
> index 11f1e5b..fc1063e 100644
>
> --- a/libavformat/hlsenc.c
> +++ b/libavformat/hlsenc.c
> @@ -30,6 +30,10 @@
>
>  #include "avformat.h"
>  #include "internal.h"
> +#if HAVE_UNISTD_H
> +#include 
> +#endif
> +
>
>  typedef struct HLSSegment {
>  char filename[1024];
> @@ -50,6 +54,7 @@ typedef struct HLSContext {
>  float time;// Set by a private option.
>  int max_nb_segments;   // Set by a private option.
>  int  wrap; // Set by a private option.
> +int  sync_list;// Set by a private option.
>
>  int64_t recording_time;
>  int has_video;
> @@ -96,6 +101,7 @@ static int hls_mux_init(AVFormatContext *s)
>
>  static int hls_append_segment(HLSContext *hls, double duration)
>  {
>  HLSSegment *en = av_malloc(sizeof(*en));
> +   int ret = 0;
>
>  if (!en)
>  return AVERROR(ENOMEM);
> @@ -115,7 +121,13 @@ 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;
> -av_free(en);
> +if (hls->sync_list) {
> +ret = unlink(en->filename);
> +if (ret < 0) {
> +av_log(hls->avf, AV_LOG_WARNING, "remove %s failed\n",
> en->filename);
> +}
> +}
> +   av_free(en);
>  } else
>  hls->nb_entries++;
>
> @@ -340,6 +352,7 @@ static const AVOption options[] = {
>  {"hls_list_size", "set maximum number of playlist entries",
> OFFSET(max_nb_segments),AV_OPT_TYPE_INT,{.i64 = 5}, 0, INT_MAX,
> E},
>  {"hls_wrap",  "set number after which the index wraps",
> OFFSET(wrap),AV_OPT_TYPE_INT,{.i64 = 0}, 0, INT_MAX, E},
>  {"hls_base_url",  "url to prepend to each playlist entry",
> OFFSET(baseurl), AV_OPT_TYPE_STRING, {.str = NULL},  0, 0,   E},
> +{"hls_sync_list", "remove old ts segment for sync the file with the
> m3u8 list",  OFFSET(sync_list),AV_OPT_TYPE_INT,{.i64 = 0}, 0,
> INT_MAX, E},
>  { NULL },
>  };
>
> If you want sync the file with the 

Re: [FFmpeg-devel] [PATCH] delete the old segment file from hls list

2014-08-21 Thread Steven Liu
Hi Stefano,
if unistd is not available under Linux,
it will output error message when compile the source code.

  [root@testrtmp ffmpeg]# make
CC  libavformat/hlsenc.o
libavformat/hlsenc.c: In function ‘hls_append_segment’:
libavformat/hlsenc.c:125: error: implicit declaration of function ‘unlink’
make: *** [libavformat/hlsenc.o] Error 1
[root@testrtmp ffmpeg]#



the follow is the new patch:

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

 #include "avformat.h"
 #include "internal.h"
+#if HAVE_UNISTD_H
+#include 
+#endif
+

 typedef struct HLSSegment {
 char filename[1024];
@@ -50,6 +54,7 @@ typedef struct HLSContext {
 float time;// Set by a private option.
 int max_nb_segments;   // Set by a private option.
 int  wrap; // Set by a private option.
+int  sync_list;// Set by a private option.

 int64_t recording_time;
 int has_video;
@@ -96,6 +101,7 @@ static int hls_mux_init(AVFormatContext *s)
 static int hls_append_segment(HLSContext *hls, double duration)
 {
 HLSSegment *en = av_malloc(sizeof(*en));
+   int ret = 0;

 if (!en)
 return AVERROR(ENOMEM);
@@ -115,7 +121,13 @@ 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;
-av_free(en);
+if (hls->sync_list) {
+ret = unlink(en->filename);
+if (ret < 0) {
+av_log(hls->avf, AV_LOG_WARNING, "remove %s failed\n",
en->filename);
+}
+}
+   av_free(en);
 } else
 hls->nb_entries++;

@@ -340,6 +352,7 @@ static const AVOption options[] = {
 {"hls_list_size", "set maximum number of playlist entries",
OFFSET(max_nb_segments),AV_OPT_TYPE_INT,{.i64 = 5}, 0, INT_MAX,
E},
 {"hls_wrap",  "set number after which the index wraps",
OFFSET(wrap),AV_OPT_TYPE_INT,{.i64 = 0}, 0, INT_MAX, E},
 {"hls_base_url",  "url to prepend to each playlist entry",
OFFSET(baseurl), AV_OPT_TYPE_STRING, {.str = NULL},  0, 0,   E},
+{"hls_sync_list", "remove old ts segment for sync the file with the
m3u8 list",  OFFSET(sync_list),AV_OPT_TYPE_INT,{.i64 = 0}, 0,
INT_MAX, E},
 { NULL },
 };

If you want sync the file with the m3u8 list, please use the hls_sync_list
parameter, default it is 0, and !0 is enable the sync operation.

Thanks,



2014-08-14 18:25 GMT+08:00 Stefano Sabatini :

> On date Monday 2014-08-11 17:39:37 +0800, Steven Liu encoded:
> > 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 
> > ---
> >  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 
> > +#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->

Re: [FFmpeg-devel] [PATCH] delete the old segment file from hls list

2014-08-14 Thread Stefano Sabatini
On date Monday 2014-08-11 17:39:37 +0800, Steven Liu encoded:
> 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 
> ---
>  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 
> +#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);

Check for the return value, and log an explicit error message in case
of failure.

>  av_free(en);
>  } else
>  hls->nb_entries++;

Also, in order not to alter the standard behavior, I think it might be
safer to add an option to enable this behavior. Also, what happens if
unistd.h is not available?
-- 
FFmpeg = Frightening and Forgiving Monstrous Proud Elastic Gadget
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] delete the old segment file from hls list

2014-08-12 Thread Steven Liu

On Aug 12, 2014, at 8:37 PM, Simon Thelen  wrote:

> On 12/08/14 at 10:36, Steven Liu wrote:
>> 2014-08-12 7:26 GMT+08:00 Simon Thelen :
>>> On 11/08/14 at 17:39, Steven Liu wrote:
> [..]
 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.
>>> [..]
>>> I'm pretty sure this is why the hls muxer has the `-hls_wrap wrap' option.
> [..]
>> hls_list_size and hls_wrap option two can fix the problem, but this
>> patch can fix the problem of the default parameter, because the ts file on
>> disk , one to one correspondence with the m3u8 file will better, isn't it?
> IMO, the problem is that you're modifying the default behavior even
> though an option already exists to let you specify the amount of segment
> files to keep around. This might be suitable in your use-case, but what
> if I (or someone else) wanted to keep all the segment files for archival
> purposes, but not list them in the m3u8; with your patch this no longer
> becomes possible.
> 
> If you were to write a new patch that made hls_wrap default to
> hls_list_size instead of the default 0, it would no longer impose
> artificial limits on users. At that point, the inclusion of the patch
> would depend on the opinion of the hls maintainer and the other FFmpeg
> maintainers with opinions on the matter.
Hi Simon Thelen,

Maybe you’re right.
I think the '-f segment' can save all of the segment ts file, so hls is 
used for living stream,
so it not save segment ts be better;  
Maybe i’m wrong. but this patch just used for remove the segment ts not 
list in m3u8. :D
> 
> -- 
> Simon Thelen
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] delete the old segment file from hls list

2014-08-12 Thread Simon Thelen
On 12/08/14 at 10:36, Steven Liu wrote:
> 2014-08-12 7:26 GMT+08:00 Simon Thelen :
> > On 11/08/14 at 17:39, Steven Liu wrote:
[..]
> > > 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.
> > [..]
> > I'm pretty sure this is why the hls muxer has the `-hls_wrap wrap' option.
[..]
>  hls_list_size and hls_wrap option two can fix the problem, but this
> patch can fix the problem of the default parameter, because the ts file on
> disk , one to one correspondence with the m3u8 file will better, isn't it?
IMO, the problem is that you're modifying the default behavior even
though an option already exists to let you specify the amount of segment
files to keep around. This might be suitable in your use-case, but what
if I (or someone else) wanted to keep all the segment files for archival
purposes, but not list them in the m3u8; with your patch this no longer
becomes possible.

If you were to write a new patch that made hls_wrap default to
hls_list_size instead of the default 0, it would no longer impose
artificial limits on users. At that point, the inclusion of the patch
would depend on the opinion of the hls maintainer and the other FFmpeg
maintainers with opinions on the matter.

-- 
Simon Thelen
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] delete the old segment file from hls list

2014-08-11 Thread Steven Liu
2014-08-12 7:26 GMT+08:00 Simon Thelen :

> On 11/08/14 at 17:39, Steven Liu wrote:
> > Hi Guys,
> Hello,
> >
> > 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.
> [..]
> I'm pretty sure this is why the hls muxer has the `-hls_wrap wrap' option.
>
Hi Simon,

 hls_list_size and hls_wrap option two can fix the problem, but this
patch can fix the problem of the default parameter, because the ts file on
disk , one to one correspondence with the m3u8 file will better, isn't it?


Thanks
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] delete the old segment file from hls list

2014-08-11 Thread Steven Liu
2014-08-12 7:26 GMT+08:00 Simon Thelen :

> On 11/08/14 at 17:39, Steven Liu wrote:
> > Hi Guys,
> Hello,
> >
> > 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.
> [..]
> I'm pretty sure this is why the hls muxer has the `-hls_wrap wrap' option.
> Hello,
>
> When use the option  -hls_wrap 7
> ./ffmpeg -i shaolinzuqiu.rm -vcodec libx264 -preset ultrafast -an -f hls
> -hls_wrap 7 a.m3u8
> it dose not remove the nouse file:
> [root@localhost ffmpeg]# ls *.ts;cat a.m3u8
> a0.ts  a1.ts  a2.ts  a3.ts  a4.ts  a5.ts  a6.ts
> #EXTM3U
> #EXT-X-VERSION:3
> #EXT-X-TARGETDURATION:11
> #EXT-X-MEDIA-SEQUENCE:20
> #EXTINF:10.427075,
> a6.ts
> #EXTINF:10.427075,
> a0.ts
> #EXTINF:10.427075,
> a1.ts
> #EXTINF:10.427075,
> a2.ts
> #EXTINF:10.427075,
> a3.ts
>
> the list file just have a0.ts,a1.ts,a2.ts,a3.ts,a6.ts but no a4.ts,a5.ts,
> and there have a4.ts,a5.ts on the disk.
> perhaps this patch can fix this problem.
>
> Thanks
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] delete the old segment file from hls list

2014-08-11 Thread Simon Thelen
On 11/08/14 at 17:39, Steven Liu wrote:
> Hi Guys,
Hello,
> 
> 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.
[..]
I'm pretty sure this is why the hls muxer has the `-hls_wrap wrap' option.

-- 
Simon Thelen
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] delete the old segment file from hls list

2014-08-11 Thread Steven Liu
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 
---
 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 
+#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