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
442escaped.442escaped.
443 443
444@item hls_wrap @var{wrap}444@item hls_wrap @var{wrap}
445Set the number after which the segment filename number (the number445This is a deprecated option, you can use @code {hls_list_size}
446specified in each segment file) wraps. If set to 0 the number will be446and @code{hls_flags delete_segments} instead it
447never wrapped. Default value is 0.
448 447
449This option is useful to avoid to fill the disk with many segment448This option is useful to avoid to fill the disk with many segment
450files, and limits the maximum number of segment files written to disk449files, 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
101 float time; // Set by a private option.101 float time; // Set by a private option.
102 float init_time; // Set by a private option.102 float init_time; // Set by a private option.
103 int max_nb_segments; // Set by a private option.103 int max_nb_segments; // Set by a private option.
104#if FF_API_HLS_WRAP
104 int wrap; // Set by a private option.105 int wrap; // Set by a private option.
106#endif
105 uint32_t flags; // enum HLSFlags107 uint32_t flags; // enum HLSFlags
106 uint32_t pl_type; // enum PlaylistType108 uint32_t pl_type; // enum PlaylistType
107 char *segment_filename;109 char *segment_filename;
@@ -566,7 +568,11 @@ static int hls_append_segment(struct AVFormatContext *s, HLSContext *hls, double · 458 unmodified lines
566 hls->initial_prog_date_time += en->duration;568 hls->initial_prog_date_time += en->duration;
567 hls->segments = en->next;569 hls->segments = en->next;
568 if (en && hls->flags & HLS_DELETE_SEGMENTS &&570 if (en && hls->flags & HLS_DELETE_SEGMENTS &&
571#if FF_API_HLS_WRAP
569 !(hls->flags & HLS_SINGLE_FILE || hls->wrap)) {572 !(hls->flags & HLS_SINGLE_FILE || hls->wrap)) {
573#else
574 !(hls->flags & HLS_SINGLE_FILE)) {
575#endif
570 en->next = hls->old_segments;576 en->next = hls->old_segments;
571 hls->old_segments = en;577 hls->old_segments = en;
572 if ((ret = hls_delete_old_segments(hls)) < 0)578 if ((ret = hls_delete_old_segments(hls)) < 0)
@@ -834,7 +840,11 @@ static int hls_start(AVFormatContext *s) · 261 unmodified lines
834 sizeof(vtt_oc->filename));840 sizeof(vtt_oc->filename));
835 } else if (c->max_seg_size > 0) {841 } else if (c->max_seg_size > 0) {
836 if (replace_int_data_in_filename(oc->filename, sizeof(oc->filename),842 if (replace_int_data_in_filename(oc->filename, sizeof(oc->filename),
843#if FF_API_HLS_WRAP
837 c->basename, 'd', c->wrap ? c->sequence % c->wrap : c->sequence) < 1) {844 c->basename, 'd', c->wrap ? c->sequence % c->wrap : c->sequence) < 1) {
845#else
846 c->basename, 'd', c->sequence) < 1) {
847#endif
838 av_log(oc, AV_LOG_ERROR, "Invalid segment filename template '%s', you can try to use -use_localtime 1 with it\n", c->basename);848 av_log(oc, AV_LOG_ERROR, "Invalid segment filename template '%s', you can try to use -use_localtime 1 with it\n", c->basename);
839 return AVERROR(EINVAL);849 return AVERROR(EINVAL);
840 }850 }
@@ -853,7 +863,11 @@ static int hls_start(AVFormatContext *s) · 12 unmodified lines
853 if (!filename)863 if (!filename)
854 return AVERROR(ENOMEM);864 return AVERROR(ENOMEM);
855 if (replace_int_data_in_filename(oc->filename, sizeof(oc->filename),865 if (replace_int_data_in_filename(oc->filename, sizeof(oc->filename),
866#if FF_API_HLS_WRAP
856 filename, 'd', c->wrap ? c->sequence % c->wrap : c->sequence) < 1) {867 filename, 'd', c->wrap ? c->sequence % c->wrap : c->sequence) < 1) {
868#else
869 filename, 'd', c->sequence) < 1) {
870#endif
857 av_log(c, AV_LOG_ERROR,871 av_log(c, AV_LOG_ERROR,
858 "Invalid second level segment filename template '%s', "872 "Invalid second level segment filename template '%s', "
859 "you can try to remove second_level_segment_index flag\n",873 "you can try to remove second_level_segment_index flag\n",
@@ -910,13 +924,21 @@ static int hls_start(AVFormatContext *s) · 50 unmodified lines
910 av_free(fn_copy);924 av_free(fn_copy);
911 }925 }
912 } else if (replace_int_data_in_filename(oc->filename, sizeof(oc->filename),926 } else if (replace_int_data_in_filename(oc->filename, sizeof(oc->filename),
927#if FF_API_HLS_WRAP
913 c->basename, 'd', c->wrap ? c->sequence % c->wrap : c->sequence) < 1) {928 c->basename, 'd', c->wrap ? c->sequence % c->wrap : c->sequence) < 1) {
929#else
930 c->basename, 'd', c->sequence) < 1) {
931#endif
914 av_log(oc, AV_LOG_ERROR, "Invalid segment filename template '%s' you can try to use -use_localtime 1 with it\n", c->basename);932 av_log(oc, AV_LOG_ERROR, "Invalid segment filename template '%s' you can try to use -use_localtime 1 with it\n", c->basename);
915 return AVERROR(EINVAL);933 return AVERROR(EINVAL);
916 }934 }
917 if( c->vtt_basename) {935 if( c->vtt_basename) {
918 if (replace_int_data_in_filename(vtt_oc->filename, sizeof(vtt_oc->filename),936 if (replace_int_data_in_filename(vtt_oc->filename, sizeof(vtt_oc->filename),
937#if FF_API_HLS_WRAP
919 c->vtt_basename, 'd', c->wrap ? c->sequence % c->wrap : c->sequence) < 1) {938 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
920 av_log(vtt_oc, AV_LOG_ERROR, "Invalid segment filename template '%s'\n", c->vtt_basename);942 av_log(vtt_oc, AV_LOG_ERROR, "Invalid segment filename template '%s'\n", c->vtt_basename);
921 return AVERROR(EINVAL);943 return AVERROR(EINVAL);
922 }944 }
@@ -1421,7 +1443,9 @@ static const AVOption options[] = { · 498 unmodified lines
1421 {"hls_list_size", "set maximum number of playlist entries", OFFSET(max_nb_segments), AV_OPT_TYPE_INT, {.i64 = 5}, 0, INT_MAX, E},1443 {"hls_list_size", "set maximum number of playlist entries", OFFSET(max_nb_segments), AV_OPT_TYPE_INT, {.i64 = 5}, 0, INT_MAX, E},
1422 {"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},1444 {"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},
1423 {"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},1445 {"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
1425 {"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},1449 {"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},
1426 {"hls_base_url", "url to prepend to each playlist entry", OFFSET(baseurl), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, E},1450 {"hls_base_url", "url to prepend to each playlist entry", OFFSET(baseurl), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, E},
1427 {"hls_segment_filename", "filename template for segment files", OFFSET(segment_filename), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, E},1451 {"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
85#ifndef FF_API_HTTP_USER_AGENT85#ifndef FF_API_HTTP_USER_AGENT
86#define FF_API_HTTP_USER_AGENT (LIBAVFORMAT_VERSION_MAJOR < 58)86#define FF_API_HTTP_USER_AGENT (LIBAVFORMAT_VERSION_MAJOR < 58)
87#endif87#endif
88#ifndef FF_API_HLS_WRAP
89#define FF_API_HLS_WRAP (LIBAVFORMAT_VERSION_MAJOR < 58)
90#endif
91
88 92
89#ifndef FF_API_R_FRAME_RATE93#ifndef FF_API_R_FRAME_RATE
90#define FF_API_R_FRAME_RATE 194#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