50 #define SEGMENT_LIST_FLAG_CACHE 1
51 #define SEGMENT_LIST_FLAG_LIVE 2
95 int needs_quoting = !!str[strcspn(str,
"\",\n\r")];
100 for (; *str; str++) {
213 "#EXT-X-TARGETDURATION:%"PRId64
"\n", seg->
time / 1000000);
273 static int parse_times(
void *log_ctx, int64_t **times,
int *nb_times,
274 const char *times_str)
279 char *saveptr =
NULL;
284 #define FAIL(err) ret = err; goto end
287 for (p = times_str1; *p; p++)
291 *times =
av_malloc(
sizeof(**times) * *nb_times);
298 for (i = 0; i < *nb_times; i++) {
300 char *tstr =
av_strtok(p,
",", &saveptr);
303 if (!tstr || !tstr[0]) {
312 "Invalid time duration specification '%s' in times list %s\n", tstr, times_str);
318 if (i && (*times)[i-1] > (*times)[i]) {
320 "Specified time %f is greater than the following time %f\n",
321 (
float)((*times)[i])/1000000, (
float)((*times)[i-1])/1000000);
332 const char *frames_str)
336 char *frames_str1 =
av_strdup(frames_str);
337 char *saveptr =
NULL;
342 #define FAIL(err) ret = err; goto end
345 for (p = frames_str1; *p; p++)
349 *frames =
av_malloc(
sizeof(**frames) * *nb_frames);
356 for (i = 0; i < *nb_frames; i++) {
359 char *fstr =
av_strtok(p,
",", &saveptr);
367 f = strtol(fstr, &tailptr, 10);
368 if (*tailptr || f <= 0 || f >= INT_MAX) {
370 "Invalid argument '%s', must be a positive integer <= INT64_MAX\n",
377 if (i && (*frames)[i-1] > (*frames)[i]) {
379 "Specified frame %d is greater than the following frame %d\n",
380 (*frames)[i], (*frames)[i-1]);
392 int buf_size = 32768;
422 "segment_time, segment_times, and segment_frames options "
423 "are mutually exclusive, select just one of them\n");
429 "segment_flags +live and segment_times or segment_frames options are mutually exclusive: "
430 "specify segment_time option if you want a live-friendly list\n");
446 "Invalid time duration specification '%s' for segment_time option\n",
455 "Invalid time duration specification '%s' for delta option\n",
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)
494 type_index_map[type] = i;
498 type = type_priority_list[i];
587 int64_t end_pts = INT64_MAX;
601 av_dlog(s,
"packet stream:%d pts:%s pts_time:%s is_key:%d frame:%d\n",
632 av_log(s,
AV_LOG_DEBUG,
"segment:'%s' starts with packet stream:%d pts:%s pts_time:%s frame:%d\n",
694 #define OFFSET(x) offsetof(SegmentContext, x)
695 #define E AV_OPT_FLAG_ENCODING_PARAM
697 {
"reference_stream",
"set reference stream",
OFFSET(reference_stream_specifier),
AV_OPT_TYPE_STRING, {.str =
"auto"}, CHAR_MIN, CHAR_MAX,
E },
705 {
"segment_list_size",
"set the maximum number of playlist entries",
OFFSET(list_size),
AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX,
E },
715 {
"segment_time_delta",
"set approximation value used for the segment times",
OFFSET(time_delta_str),
AV_OPT_TYPE_STRING, {.str =
"0"}, 0, 0,
E },
718 {
"segment_wrap",
"set number after which the index wraps",
OFFSET(segment_idx_wrap),
AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX,
E },
719 {
"segment_start_number",
"set the sequence number of the first segment",
OFFSET(segment_idx),
AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX,
E },
721 {
"individual_header_trailer",
"write header/trailer to each segment",
OFFSET(individual_header_trailer),
AV_OPT_TYPE_INT, {.i64 = 1}, 0, 1,
E },
722 {
"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 },
723 {
"reset_timestamps",
"reset timestamps at the begin of each segment",
OFFSET(reset_timestamps),
AV_OPT_TYPE_INT, {.i64 = 0}, 0, 1,
E },
742 .priv_class = &seg_class,
753 .
name =
"stream_segment,ssegment",
760 .priv_class = &sseg_class,