93 float playlist_duration = 0.0f;
94 int ret = 0, path_size;
95 char *dirname =
NULL, *p, *path;
99 playlist_duration += segment->
duration;
100 segment = segment->
next;
105 playlist_duration -= segment->
duration;
106 previous_segment = segment;
107 segment = previous_segment->
next;
108 if (playlist_duration <= -previous_segment->
duration) {
131 path_size = strlen(dirname) + strlen(segment->
filename) + 1;
139 if (unlink(path) < 0) {
141 path, strerror(errno));
144 previous_segment = segment;
145 segment = previous_segment->
next;
242 int target_duration = 0;
245 char temp_filename[1024];
249 int use_rename = proto && !strcmp(proto,
"file");
250 static unsigned warned_non_file;
252 if (!use_rename && !warned_non_file++)
253 av_log(s,
AV_LOG_ERROR,
"Cannot use rename on non file protocol, this may lead to races and temporarly partial files\n");
255 snprintf(temp_filename,
sizeof(temp_filename), use_rename ?
"%s.tmp" :
"%s", s->
filename);
262 target_duration = ceil(en->
duration);
270 avio_printf(out,
"#EXT-X-TARGETDURATION:%d\n", target_duration);
271 avio_printf(out,
"#EXT-X-MEDIA-SEQUENCE:%"PRId64
"\n", sequence);
279 avio_printf(out,
"#EXT-X-BYTERANGE:%"PRIi64
"@%"PRIi64
"\n",
291 if (ret >= 0 && use_rename)
328 const char *pattern =
"%d.ts";
350 "More than a single video stream present, "
351 "expect issues decoding it.\n");
370 basename_size = strlen(s->
filename) + strlen(pattern) + 1;
422 int ret, can_split = 1;
435 is_ref_pkt = can_split = 0;
443 int64_t new_start_pos;
501 #define OFFSET(x) offsetof(HLSContext, x)
502 #define E AV_OPT_FLAG_ENCODING_PARAM
506 {
"hls_list_size",
"set maximum number of playlist entries",
OFFSET(max_nb_segments),
AV_OPT_TYPE_INT, {.i64 = 5}, 0, INT_MAX,
E},
507 {
"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},
509 {
"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},
512 {
"hls_flags",
"set flags affecting HLS playlist and media file generation",
OFFSET(
flags),
AV_OPT_TYPE_FLAGS, {.i64 = 0 }, 0, UINT_MAX,
E,
"flags"},
530 .extensions =
"m3u8",
538 .priv_class = &hls_class,