From patchwork Wed Apr 4 08:37:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Dixit, Vishwanath" X-Patchwork-Id: 8312 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.1.70 with SMTP id c67csp4619364jad; Wed, 4 Apr 2018 01:37:55 -0700 (PDT) X-Google-Smtp-Source: AIpwx48u9PWrw0OduNPQAu91BTZucglRdRnsUaeul9KBWqbfaRBs75fzo3iPOLYRJzuK6JduOVi+ X-Received: by 10.28.184.86 with SMTP id i83mr6108608wmf.30.1522831075210; Wed, 04 Apr 2018 01:37:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522831075; cv=none; d=google.com; s=arc-20160816; b=u3IWG3cph7JlyZJ/aY0K3xLHdhYbGn4wHZjnQ4SXvj5XvKWwJ3lBJn8Tqq9fxETuo2 jvmrrVmGMGCXAZtdGahJSFH9PA4+ehQcy/Vwj+1CwFW8pS5PF1nqHvzpyavznBWX8zPE AvW3NGbZCevpDPYETs5zXYDaDaXSzo4V6RWqdgUXEBLYk3HAQKcq0xo4+QExcV9VfuHT D9RXepVj/vJhtdy6oZXPl8KrMhbGSC+7QrrZuBW3js+MmOb87neFMK3J8/46r8diQ+1R 9g093TwPCHyC7WVoHsJQJTPzROUeQCTWBo1+0/AaHlDV5tTBtE7VHLfvTBQS3fOdcnfE so9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:feedback-id:references:in-reply-to :message-id:date:to:from:dkim-signature:delivered-to :arc-authentication-results; bh=/YNWzkYDHBLJEHlvnLNXZzkxYtfU1Mp8AFUK7LSyhaQ=; b=dKuZXOcR639hhI4vc5+TrYNKfU1Vqaa5y+5O4XxOTjMG0sg8a4LyYKY1eTK8qAMgnc xGM+97i2C8vOU4vCMxyeQXTbBKv4C3QwAapMpfSJg2lu7kWFvI8zKT+8Dq5Twk6Jfr06 BUaSfzar7nPJfqN3Qnn5+s+9Q5cy7p2wJ2T8IDkoWno1NnjYJ3X/5El0NizvHLNP2jrZ CtxJS3gNEwxN227wUESwyhuKXvH8mt7i/JQEtyPiE9gnMpWiOPJqz9spTxTp9CnudK/h IAA52iyCtO3Ts//cu7EgEDQh3FIZYmL3FHwa0BnZM4w29DnRibBfa2zf1kP53RUqqXgB KrMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@smtpservice.net header.s=m78bu0.a1-4.dyn header.b=g0KxM7oL; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=QUARANTINE sp=NONE dis=NONE) header.from=akamai.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id e190si1915027wma.105.2018.04.04.01.37.54; Wed, 04 Apr 2018 01:37:55 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@smtpservice.net header.s=m78bu0.a1-4.dyn header.b=g0KxM7oL; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=QUARANTINE sp=NONE dis=NONE) header.from=akamai.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4EE08689B3A; Wed, 4 Apr 2018 11:37:32 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from a1i318.smtp2go.com (a1i318.smtp2go.com [43.228.185.62]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 09F2A6891FC for ; Wed, 4 Apr 2018 11:37:26 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=smtpservice.net; s=m78bu0.a1-4.dyn; x=1522831972; h=Feedback-ID: X-Smtpcorp-Track:Message-Id:Date:Subject:To:From:Reply-To:Sender: List-Unsubscribe; bh=ScZ5hn6beCyvMQ0o6Wp9b3c7nGg3TFFZWeV8S8p7/dY=; b=g0KxM7oL H93NmG/uMmk/oiCmJ2dsrYmRIJ36g8EaHY5Nzqukgez1RNWwAlOq1CUhoFVh3+viKYdvpgBvP2Pis pWWg5nGhAUTtAHDJry3HqBzIiHfWktP7B+st9THU7rXsdtxa7r3YRKZLk0xGHnvXW4Re4wB6bDhZd KCGeHH+v7Io8w1RX083hEhfIpboDiH1KrG4z4UuutGTuL6s/Gd6RAR0bM32Iq+cNYysD+6AZjrzTz WUerSCL5+dj5T1CJUrVhfTA7nPufUlpTUbNYu7gKgOcNYTtBcGJTeHQqd+lE0X8Qi4QMOdh9hyDZD 9L9kb6tMVbL6Ie49PMBudp6nMg==; From: vdixit@akamai.com To: ffmpeg-devel@ffmpeg.org Date: Wed, 4 Apr 2018 14:07:38 +0530 Message-Id: <1522831058-7238-1-git-send-email-vdixit@akamai.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: References: X-Smtpcorp-Track: 1f3dvKRyIK-5QD.xu7b1V_w_ Feedback-ID: 337386m:337386asVRLGB:337386sj1P345lTp:SMTPCORP X-Report-Abuse: Please forward a copy of this message, including all headers, to Subject: [FFmpeg-devel] [PATCH v2 06/11] avformat/dashenc: addition of @availabilityTimeOffset in MPD X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Vishwanath Dixit MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From: Vishwanath Dixit 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. --- libavformat/dashenc.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c index 9e7a374..5921ef7 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 { @@ -344,8 +345,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\tuse_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; @@ -1289,6 +1294,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;