History

avformat/hlsenc: deprecate hls_wrap option

When user use the hls_wrap, there have many problem: 1. some platform refersh the old but usefull segment 2. CDN(Content Delivery Network) Deliver HLS not friendly The hls_wrap is used to wrap segments for use little space, now user can use hls_list_size and hls_flags delete_segments instead it.

Steven Liu committed 9 years ago

Commit d96ebc51 parent 96ee6da3 files · +31 −4Browse files

Unified · Split

3 files
  1. doc/muxers.texi +2 −3
  2. libavformat/hlsenc.c +25 −1
  3. libavformat/version.h +4 −0
doc/muxers.texi+2−3
@@ -442,9 +442,8 @@ parameters. Values containing @code{:} special characters must be · 441 unmodified lines
442442 escaped.
443443
444444 @item hls_wrap @var{wrap}
445−Set the number after which the segment filename number (the number
446−specified in each segment file) wraps. If set to 0 the number will be
447−never wrapped. Default value is 0.
445+This is a deprecated option, you can use @code {hls_list_size}
446+and @code{hls_flags delete_segments} instead it
448447
449448 This option is useful to avoid to fill the disk with many segment
450449 files, and limits the maximum number of segment files written to disk
libavformat/hlsenc.c+25−1
@@ -101,7 +101,9 @@ typedef struct HLSContext { · 100 unmodified lines
101101 float time; // Set by a private option.
102102 float init_time; // Set by a private option.
103103 int max_nb_segments; // Set by a private option.
104+#if FF_API_HLS_WRAP
104105 int wrap; // Set by a private option.
106+#endif
105107 uint32_t flags; // enum HLSFlags
106108 uint32_t pl_type; // enum PlaylistType
107109 char *segment_filename;
@@ -566,7 +568,11 @@ static int hls_append_segment(struct AVFormatContext *s, HLSContext *hls, double · 458 unmodified lines
566568 hls->initial_prog_date_time += en->duration;
567569 hls->segments = en->next;
568570 if (en && hls->flags & HLS_DELETE_SEGMENTS &&
571+#if FF_API_HLS_WRAP
569572 !(hls->flags & HLS_SINGLE_FILE || hls->wrap)) {
573+#else
574+ !(hls->flags & HLS_SINGLE_FILE)) {
575+#endif
570576 en->next = hls->old_segments;
571577 hls->old_segments = en;
572578 if ((ret = hls_delete_old_segments(hls)) < 0)
@@ -834,7 +840,11 @@ static int hls_start(AVFormatContext *s) · 261 unmodified lines
834840 sizeof(vtt_oc->filename));
835841 } else if (c->max_seg_size > 0) {
836842 if (replace_int_data_in_filename(oc->filename, sizeof(oc->filename),
843+#if FF_API_HLS_WRAP
837844 c->basename, 'd', c->wrap ? c->sequence % c->wrap : c->sequence) < 1) {
845+#else
846+ c->basename, 'd', c->sequence) < 1) {
847+#endif
838848 av_log(oc, AV_LOG_ERROR, "Invalid segment filename template '%s', you can try to use -use_localtime 1 with it\n", c->basename);
839849 return AVERROR(EINVAL);
840850 }
@@ -853,7 +863,11 @@ static int hls_start(AVFormatContext *s) · 12 unmodified lines
853863 if (!filename)
854864 return AVERROR(ENOMEM);
855865 if (replace_int_data_in_filename(oc->filename, sizeof(oc->filename),
866+#if FF_API_HLS_WRAP
856867 filename, 'd', c->wrap ? c->sequence % c->wrap : c->sequence) < 1) {
868+#else
869+ filename, 'd', c->sequence) < 1) {
870+#endif
857871 av_log(c, AV_LOG_ERROR,
858872 "Invalid second level segment filename template '%s', "
859873 "you can try to remove second_level_segment_index flag\n",
@@ -910,13 +924,21 @@ static int hls_start(AVFormatContext *s) · 50 unmodified lines
910924 av_free(fn_copy);
911925 }
912926 } else if (replace_int_data_in_filename(oc->filename, sizeof(oc->filename),
927+#if FF_API_HLS_WRAP
913928 c->basename, 'd', c->wrap ? c->sequence % c->wrap : c->sequence) < 1) {
929+#else
930+ c->basename, 'd', c->sequence) < 1) {
931+#endif
914932 av_log(oc, AV_LOG_ERROR, "Invalid segment filename template '%s' you can try to use -use_localtime 1 with it\n", c->basename);
915933 return AVERROR(EINVAL);
916934 }
917935 if( c->vtt_basename) {
918936 if (replace_int_data_in_filename(vtt_oc->filename, sizeof(vtt_oc->filename),
937+#if FF_API_HLS_WRAP
919938 c->vtt_basename, 'd', c->wrap ? c->sequence % c->wrap : c->sequence) < 1) {
939+#else
940+ c->vtt_basename, 'd', c->sequence) < 1) {
941+#endif
920942 av_log(vtt_oc, AV_LOG_ERROR, "Invalid segment filename template '%s'\n", c->vtt_basename);
921943 return AVERROR(EINVAL);
922944 }
@@ -1421,7 +1443,9 @@ static const AVOption options[] = { · 498 unmodified lines
14211443 {"hls_list_size", "set maximum number of playlist entries", OFFSET(max_nb_segments), AV_OPT_TYPE_INT, {.i64 = 5}, 0, INT_MAX, E},
14221444 {"hls_ts_options","set hls mpegts list of options for the container format used for hls", OFFSET(format_options_str), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, E},
14231445 {"hls_vtt_options","set hls vtt list of options for the container format used for hls", OFFSET(vtt_format_options_str), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, E},
1424− {"hls_wrap", "set number after which the index wraps", OFFSET(wrap), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, E},
1446+#if FF_API_HLS_WRAP
1447+ {"hls_wrap", "set number after which the index wraps (will be deprecated)", OFFSET(wrap), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, E},
1448+#endif
14251449 {"hls_allow_cache", "explicitly set whether the client MAY (1) or MUST NOT (0) cache media segments", OFFSET(allowcache), AV_OPT_TYPE_INT, {.i64 = -1}, INT_MIN, INT_MAX, E},
14261450 {"hls_base_url", "url to prepend to each playlist entry", OFFSET(baseurl), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, E},
14271451 {"hls_segment_filename", "filename template for segment files", OFFSET(segment_filename), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, E},
libavformat/version.h+4−0
@@ -85,6 +85,10 @@ · 84 unmodified lines
8585 #ifndef FF_API_HTTP_USER_AGENT
8686 #define FF_API_HTTP_USER_AGENT (LIBAVFORMAT_VERSION_MAJOR < 58)
8787 #endif
88+#ifndef FF_API_HLS_WRAP
89+#define FF_API_HLS_WRAP (LIBAVFORMAT_VERSION_MAJOR < 58)
90+#endif
91+
8892
8993 #ifndef FF_API_R_FRAME_RATE
9094 #define FF_API_R_FRAME_RATE 1

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t