const char *media_seg_name;
AVRational min_frame_rate, max_frame_rate;
int ambiguous_frame_rate;
+ const char *utc_timing_url;
} DASHContext;
static int dash_write(void *opaque, uint8_t *buf, int buf_size)
struct tm *ptm, tmbuf;
ptm = gmtime_r(&t, &tmbuf);
if (ptm) {
- if (!strftime(buf, size, "%Y-%m-%dT%H:%M:%S", ptm))
+ if (!strftime(buf, size, "%Y-%m-%dT%H:%M:%SZ", ptm))
buf[0] = '\0';
}
}
DASHContext *c = s->priv_data;
AVIOContext *out;
char temp_filename[1024];
- int ret, i;
+ int ret, i, as_id = 0;
const char *proto = avio_find_protocol_name(s->filename);
int use_rename = proto && !strcmp(proto, "file");
static unsigned int warned_non_file = 0;
}
}
avio_printf(out, "\tminBufferTime=\"");
- write_time(out, c->last_duration);
+ write_time(out, c->last_duration * 2);
avio_printf(out, "\">\n");
avio_printf(out, "\t<ProgramInformation>\n");
if (title) {
av_free(escaped);
}
avio_printf(out, "\t</ProgramInformation>\n");
+ if (c->utc_timing_url)
+ avio_printf(out, "\t<UTCTiming schemeIdUri=\"urn:mpeg:dash:utc:http-xsdate:2014\" value=\"%s\"/>\n", c->utc_timing_url);
+
if (c->window_size && s->nb_streams > 0 && c->streams[0].nb_segments > 0 && !c->use_template) {
OutputStream *os = &c->streams[0];
int start_index = FFMAX(os->nb_segments - c->window_size, 0);
int64_t start_time = av_rescale_q(os->segments[start_index]->time, s->streams[0]->time_base, AV_TIME_BASE_Q);
- avio_printf(out, "\t<Period start=\"");
+ avio_printf(out, "\t<Period id=\"0\" start=\"");
write_time(out, start_time);
avio_printf(out, "\">\n");
} else {
- avio_printf(out, "\t<Period start=\"PT0.0S\">\n");
+ avio_printf(out, "\t<Period id=\"0\" start=\"PT0.0S\">\n");
}
if (c->has_video) {
- avio_printf(out, "\t\t<AdaptationSet contentType=\"video\" segmentAlignment=\"true\" bitstreamSwitching=\"true\"");
+ avio_printf(out, "\t\t<AdaptationSet id=\"%d\" contentType=\"video\" segmentAlignment=\"true\" bitstreamSwitching=\"true\"", as_id++);
if (c->max_frame_rate.num && !c->ambiguous_frame_rate)
avio_printf(out, " %s=\"%d/%d\"", (av_cmp_q(c->min_frame_rate, c->max_frame_rate) < 0) ? "maxFrameRate" : "frameRate", c->max_frame_rate.num, c->max_frame_rate.den);
avio_printf(out, ">\n");
avio_printf(out, "\t\t</AdaptationSet>\n");
}
if (c->has_audio) {
- avio_printf(out, "\t\t<AdaptationSet contentType=\"audio\" segmentAlignment=\"true\" bitstreamSwitching=\"true\">\n");
+ avio_printf(out, "\t\t<AdaptationSet id=\"%d\" contentType=\"audio\" segmentAlignment=\"true\" bitstreamSwitching=\"true\">\n", as_id++);
for (i = 0; i < s->nb_streams; i++) {
AVStream *st = s->streams[i];
OutputStream *os = &c->streams[i];
DASHContext *c = s->priv_data;
AVStream *st = s->streams[pkt->stream_index];
OutputStream *os = &c->streams[pkt->stream_index];
- int64_t seg_end_duration = (os->segment_index) * (int64_t) c->min_seg_duration;
int ret;
ret = update_stream_extradata(s, os, st->codecpar);
if ((!c->has_video || st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) &&
pkt->flags & AV_PKT_FLAG_KEY && os->packets_written &&
- av_compare_ts(pkt->pts - os->first_pts, st->time_base,
- seg_end_duration, AV_TIME_BASE_Q) >= 0) {
+ av_compare_ts(pkt->pts - os->start_pts, st->time_base,
+ c->min_seg_duration, AV_TIME_BASE_Q) >= 0) {
int64_t prev_duration = c->last_duration;
c->last_duration = av_rescale_q(pkt->pts - os->start_pts,
{ "single_file_name", "DASH-templated name to be used for baseURL. Implies storing all segments in one file, accessed using byte ranges", OFFSET(single_file_name), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, E },
{ "init_seg_name", "DASH-templated name to used for the initialization segment", OFFSET(init_seg_name), AV_OPT_TYPE_STRING, {.str = "init-stream$RepresentationID$.m4s"}, 0, 0, E },
{ "media_seg_name", "DASH-templated name to used for the media segments", OFFSET(media_seg_name), AV_OPT_TYPE_STRING, {.str = "chunk-stream$RepresentationID$-$Number%05d$.m4s"}, 0, 0, E },
+ { "utc_timing_url", "URL of the page that will return the UTC timestamp in ISO format", OFFSET(utc_timing_url), AV_OPT_TYPE_STRING, { 0 }, 0, 0, E },
{ NULL },
};