61 #define SEGMENT_LIST_FLAG_CACHE 1
62 #define SEGMENT_LIST_FLAG_LIVE 2
107 int needs_quoting = !!str[strcspn(str,
"\",\n\r")];
112 for (; *str; str++) {
219 double max_duration = 0;
229 avio_printf(seg->
list_pb,
"#EXT-X-TARGETDURATION:%"PRId64
"\n", (int64_t)ceil(max_duration));
260 "Error writing list entry '%s' in list file\n", list_entry->
filename);
295 memcpy(entry, &seg->
cur_entry,
sizeof(*entry));
332 static int parse_times(
void *log_ctx, int64_t **times,
int *nb_times,
333 const char *times_str)
338 char *saveptr = NULL;
343 #define FAIL(err) ret = err; goto end
346 for (p = times_str1; *p; p++)
350 *times =
av_malloc(
sizeof(**times) * *nb_times);
357 for (i = 0; i < *nb_times; i++) {
359 char *tstr =
av_strtok(p,
",", &saveptr);
362 if (!tstr || !tstr[0]) {
371 "Invalid time duration specification '%s' in times list %s\n", tstr, times_str);
377 if (i && (*times)[i-1] > (*times)[i]) {
379 "Specified time %f is greater than the following time %f\n",
380 (
float)((*times)[i])/1000000, (
float)((*times)[i-1])/1000000);
391 const char *frames_str)
395 char *frames_str1 =
av_strdup(frames_str);
396 char *saveptr = NULL;
401 #define FAIL(err) ret = err; goto end
404 for (p = frames_str1; *p; p++)
408 *frames =
av_malloc(
sizeof(**frames) * *nb_frames);
415 for (i = 0; i < *nb_frames; i++) {
418 char *fstr =
av_strtok(p,
",", &saveptr);
426 f = strtol(fstr, &tailptr, 10);
427 if (*tailptr || f <= 0 || f >= INT_MAX) {
429 "Invalid argument '%s', must be a positive integer <= INT64_MAX\n",
436 if (i && (*frames)[i-1] > (*frames)[i]) {
438 "Specified frame %d is greater than the following frame %d\n",
439 (*frames)[i], (*frames)[i-1]);
451 int buf_size = 32768;
478 static const enum AVMediaType type_priority_list[] = {
488 type_index_map[i] = -1;
493 if ((
unsigned)type < AVMEDIA_TYPE_NB && type_index_map[type] == -1
496 type_index_map[type] = i;
500 type = type_priority_list[i];
538 "segment_time, segment_times, and segment_frames options "
539 "are mutually exclusive, select just one of them\n");
555 "Invalid time duration specification '%s' for segment_time option\n",
641 int64_t end_pts = INT64_MAX,
offset;
642 int start_frame = INT_MAX;
655 av_dlog(s,
"packet stream:%d pts:%s pts_time:%s is_key:%d frame:%d\n",
683 av_log(s,
AV_LOG_DEBUG,
"segment:'%s' starts with packet stream:%d pts:%s pts_time:%s frame:%d\n",
689 av_log(s,
AV_LOG_DEBUG,
"stream:%d start_pts_time:%s pts:%s pts_time:%s dts:%s dts_time:%s",
757 #define OFFSET(x) offsetof(SegmentContext, x)
758 #define E AV_OPT_FLAG_ENCODING_PARAM
760 {
"reference_stream",
"set reference stream",
OFFSET(reference_stream_specifier),
AV_OPT_TYPE_STRING, {.str =
"auto"}, CHAR_MIN, CHAR_MAX,
E },
761 {
"segment_format",
"set container format used for the segments",
OFFSET(format),
AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0,
E },
768 {
"segment_list_size",
"set the maximum number of playlist entries",
OFFSET(list_size),
AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX,
E },
779 {
"segment_time_delta",
"set approximation value used for the segment times",
OFFSET(time_delta),
AV_OPT_TYPE_DURATION, {.i64 = 0}, 0, 0,
E },
782 {
"segment_wrap",
"set number after which the index wraps",
OFFSET(segment_idx_wrap),
AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX,
E },
783 {
"segment_start_number",
"set the sequence number of the first segment",
OFFSET(segment_idx),
AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX,
E },
785 {
"individual_header_trailer",
"write header/trailer to each segment",
OFFSET(individual_header_trailer),
AV_OPT_TYPE_INT, {.i64 = 1}, 0, 1,
E },
786 {
"write_header_trailer",
"write a header to the first segment and a trailer to the last one",
OFFSET(write_header_trailer),
AV_OPT_TYPE_INT, {.i64 = 1}, 0, 1,
E },
787 {
"reset_timestamps",
"reset timestamps at the begin of each segment",
OFFSET(reset_timestamps),
AV_OPT_TYPE_INT, {.i64 = 0}, 0, 1,
E },
788 {
"initial_offset",
"set initial timestamp offset",
OFFSET(initial_offset),
AV_OPT_TYPE_DURATION, {.i64 = 0}, -INT64_MAX, INT64_MAX,
E },
807 .priv_class = &seg_class,
818 .
name =
"stream_segment,ssegment",
825 .priv_class = &sseg_class,