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-30 Thread Anshul
On August 30, 2014 8:57:12 AM IST, Steven Liu lingjiujia...@gmail.com wrote:

On Aug 28, 2014, at 4:52 AM, Anshul anshul.ffm...@gmail.com wrote:

 On August 22, 2014 8:01:20 AM IST, Steven Liu
lingjiujia...@gmail.com 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 qi@chinacache.com
 ---
 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 unistd.h
 +#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 lingjiujia...@gmail.com:
 
 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 unistd.h
 +#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 

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 anshul.ffm...@gmail.com wrote:

 On August 22, 2014 8:01:20 AM IST, Steven Liu lingjiujia...@gmail.com 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 qi@chinacache.com
 ---
 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 unistd.h
 +#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 lingjiujia...@gmail.com:
 
 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 unistd.h
 +#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,

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 qi@chinacache.com
---
 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 unistd.h
+#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 lingjiujia...@gmail.com:

 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 unistd.h
 +#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 

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 ffmpeg-...@c-14.de:
  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 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


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 ffmpeg-...@c-14.de:

 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 Steven Liu
2014-08-12 7:26 GMT+08:00 Simon Thelen ffmpeg-...@c-14.de:

 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