46 if (!strncmp(ptr,
"WEBVTT", 6) &&
47 (!ptr[6] || strchr(
"\n\r\t ", ptr[6])))
55 if (sscanf(s,
"%u:%u:%u.%u", &hh, &mm, &ss, &ms) == 4)
return (hh*3600LL + mm*60LL + ss) * 1000LL + ms;
56 if (sscanf(s,
"%u:%u.%u", &mm, &ss, &ms) == 3)
return ( mm*60LL + ss) * 1000LL + ms;
81 const char *p, *identifier, *settings;
82 int identifier_len, settings_len;
83 int64_t ts_start, ts_end;
90 p = identifier = cue.str;
94 if (!strncmp(p,
"\xEF\xBB\xBFWEBVTT", 9) ||
95 !strncmp(p,
"WEBVTT", 6))
100 for (i = 0; p[i] && p[i] !=
'\n' && p[i] !=
'\r'; i++) {
101 if (!strncmp(p + i,
"-->", 3)) {
109 identifier_len = strcspn(p,
"\r\n");
120 if (!(p = strstr(p,
"-->")))
123 do p++;
while (*p ==
' ' || *p ==
'\t');
128 p += strcspn(p,
"\n\t ");
129 while (*p ==
'\t' || *p ==
' ')
132 settings_len = strcspn(p,
"\r\n");
149 #define SET_SIDE_DATA(name, type) do { \
151 uint8_t *buf = av_packet_new_side_data(sub, type, name##_len); \
153 res = AVERROR(ENOMEM); \
156 memcpy(buf, name, name##_len); \
179 int64_t min_ts, int64_t ts, int64_t max_ts,
int flags)
183 min_ts, ts, max_ts, flags);
193 #define OFFSET(x) offsetof(WebVTTContext, x)
194 #define KIND_FLAGS AV_OPT_FLAG_SUBTITLE_PARAM
198 {
"subtitles",
"WebVTT subtitles kind", 0,
AV_OPT_TYPE_CONST, { .i64 = 0 }, INT_MIN, INT_MAX, 0,
"webvtt_kind" },
222 .priv_class = &webvtt_demuxer_class,