summaryrefslogtreecommitdiff
path: root/libavformat/dashenc.c
diff options
context:
space:
mode:
authorMartin Storsjö <martin@martin.st>2014-11-28 10:40:05 +0200
committerMartin Storsjö <martin@martin.st>2014-12-17 09:42:30 +0200
commit2f628d5943c12389c07d652d23d3916997f9f0f6 (patch)
treeb6218737cf2bb76e3c28f58489d03bf6c7aaeb33 /libavformat/dashenc.c
parent6f4364aba9d70dc5fd9f1c88b9c03bf9ea893d40 (diff)
dashenc: Write segment timelines properly if the timeline has gaps
Write a new start time if the duration of the previous segment didn't match the start of the next one. Check that segments actually are continuous before writing a repeat count. This makes sure timestamps deduced from the timeline actually match the real start timestamp as written in filenames (if using a template containing $Time$). Signed-off-by: Martin Storsjö <martin@martin.st>
Diffstat (limited to 'libavformat/dashenc.c')
-rw-r--r--libavformat/dashenc.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index 3308c055e8..a55cd67cc0 100644
--- a/libavformat/dashenc.c
+++ b/libavformat/dashenc.c
@@ -208,20 +208,24 @@ static void output_segment_list(OutputStream *os, AVIOContext *out, DASHContext
avio_printf(out, "duration=\"%"PRId64"\" ", c->last_duration);
avio_printf(out, "initialization=\"%s\" media=\"%s\" startNumber=\"%d\">\n", c->init_seg_name, c->media_seg_name, c->use_timeline ? start_number : 1);
if (c->use_timeline) {
+ int64_t cur_time = 0;
avio_printf(out, "\t\t\t\t\t<SegmentTimeline>\n");
for (i = start_index; i < os->nb_segments; ) {
Segment *seg = os->segments[i];
int repeat = 0;
avio_printf(out, "\t\t\t\t\t\t<S ");
- if (i == start_index)
+ if (i == start_index || seg->time != cur_time)
avio_printf(out, "t=\"%"PRId64"\" ", seg->time);
avio_printf(out, "d=\"%d\" ", seg->duration);
- while (i + repeat + 1 < os->nb_segments && os->segments[i + repeat + 1]->duration == seg->duration)
+ while (i + repeat + 1 < os->nb_segments &&
+ os->segments[i + repeat + 1]->duration == seg->duration &&
+ os->segments[i + repeat + 1]->time == os->segments[i + repeat]->time + os->segments[i + repeat]->duration)
repeat++;
if (repeat > 0)
avio_printf(out, "r=\"%d\" ", repeat);
avio_printf(out, "/>\n");
i += 1 + repeat;
+ cur_time += (1 + repeat) * seg->duration;
}
avio_printf(out, "\t\t\t\t\t</SegmentTimeline>\n");
}