[FFmpeg-cvslog] avformat/dashenc: addition of @availabilityTimeOffset in MPD

Vishwanath Dixit git at videolan.org
Tue Apr 17 12:48:54 EEST 2018


ffmpeg | branch: master | Vishwanath Dixit <vdixit at akamai.com> | Wed Apr 11 12:49:47 2018 +0530| [990380367b071212675813be25c2a93054c1d3d2] | committer: Karthick Jeyapal

avformat/dashenc: addition of @availabilityTimeOffset in MPD

availability time of Nth segment = availabilityStartTime + (N*segment duration) - availabilityTimeOffset.
This field helps to reduce the latency by about a segment duration in streaming mode.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=990380367b071212675813be25c2a93054c1d3d2
---

 libavformat/dashenc.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index 5d5310d004..70409e5699 100644
--- a/libavformat/dashenc.c
+++ b/libavformat/dashenc.c
@@ -85,6 +85,7 @@ typedef struct OutputStream {
     char filename[1024];
     char full_path[1024];
     char temp_path[1024];
+    double availability_time_offset;
 } OutputStream;
 
 typedef struct DASHContext {
@@ -346,8 +347,12 @@ static void output_segment_list(OutputStream *os, AVIOContext *out, AVFormatCont
     if (c->use_template) {
         int timescale = c->use_timeline ? os->ctx->streams[0]->time_base.den : AV_TIME_BASE;
         avio_printf(out, "\t\t\t\t<SegmentTemplate timescale=\"%d\" ", timescale);
-        if (!c->use_timeline)
+        if (!c->use_timeline) {
             avio_printf(out, "duration=\"%"PRId64"\" ", c->seg_duration);
+            if (c->streaming && os->availability_time_offset)
+                avio_printf(out, "availabilityTimeOffset=\"%.3f\" ",
+                            os->availability_time_offset);
+        }
         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;
@@ -1293,6 +1298,13 @@ static int dash_write_packet(AVFormatContext *s, AVPacket *pkt)
         format_date_now(c->availability_start_time,
                         sizeof(c->availability_start_time));
 
+    if (!os->availability_time_offset && pkt->duration) {
+        int64_t frame_duration = av_rescale_q(pkt->duration, st->time_base,
+                                              AV_TIME_BASE_Q);
+         os->availability_time_offset = ((double) c->seg_duration -
+                                         frame_duration) / AV_TIME_BASE;
+    }
+
     if (c->use_template && !c->use_timeline) {
         elapsed_duration = pkt->pts - os->first_pts;
         seg_end_duration = (int64_t) os->segment_index * c->seg_duration;



More information about the ffmpeg-cvslog mailing list