From patchwork Wed Apr 11 07:01:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Dixit, Vishwanath" X-Patchwork-Id: 8393 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.1.70 with SMTP id c67csp369524jad; Wed, 11 Apr 2018 00:02:02 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+gIt+n2bHfKUvvWsOTATFlHQ+jtq/7iWbuQLLSS24KxkJ4EQ8W4g+H+ZihsdV+cm10KOTM X-Received: by 10.28.8.143 with SMTP id 137mr1554435wmi.54.1523430122714; Wed, 11 Apr 2018 00:02:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523430122; cv=none; d=google.com; s=arc-20160816; b=PSaQfcp8ak0zu29zUef1uktOVWBs4NmT9a2Z5taXmtlm8SWiLFZXt2BCXrtaWInQ34 kFaxlCVWd0EdVbr2WdSdS/IXQC0ZwMPf0IwawZTMnir57Kj+plw4G3L3GX6fwoeqxx+U H7vF7p2U95GVIMAl5l3dPpsb+IQbBAe7GHspva2f89H28EuwqrBCYU+P2kkPdgCggXDQ DJGg4CZeVXijbY8JBEAzFxPzWSa3xX+kv2q7gAKJfx05EOUgjlp+zTL+y6sYRbs4MJAl OASwnfxdBRNRK+H9pLPrhWSCBmfc7xECD4KQGmi1PmKwCPRWnqRmWQLHnvgFKStJEuBV zBBA== 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=BV/JPNbEmO+VBi57scG0ldXQUra3fW8BEw1lwznhceM=; b=Vx/TySxqffqIpVQk2GLPZ796Z6AR0j+vOBdPaLvwTL+3J+26/Uug9o6wCThfYNzUxU JE201WmAlM/BqHc79yAO7avvBFZI94Dv4GUQfaMnd16jebAtN33cE70UCwbOiNMXUpGr 3bWfSRs/xmh4aJXZ7r2cTmK/EWiS/W37Jv0GrW/G6BsPNB6kwM0Zjcc1YHUaokZcwaq0 IcbKFS5i57SGQKnbhfZMp7AL8DfekfL6p9pttyUhCGjUap84U92KlXG7BxhyAznGmGR5 B9jdneJfTEXNKIKAjwcXBDXF1DIu2YKc5j+qf5LdCnnDA1Wup53E/0MsUfce2Wop80WJ 0RAA== 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=jSZKChQG; 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 o126si569072wmd.42.2018.04.11.00.02.02; Wed, 11 Apr 2018 00:02:02 -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=jSZKChQG; 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 D926968A25E; Wed, 11 Apr 2018 10:01:36 +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 D274268A1EA for ; Wed, 11 Apr 2018 10:01:29 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=smtpservice.net; s=m78bu0.a1-4.dyn; x=1523431019; h=Feedback-ID: X-Smtpcorp-Track:Message-Id:Date:Subject:To:From:Reply-To:Sender: List-Unsubscribe; bh=HAYLJ8y3qCq104KBSyKAEkYhGevmPdWKoQSw5Bie4Lw=; b=jSZKChQG 4sNDtAnbM9XKBeLqZlIPlCFkmWNj77lbYrOpySitZ3Vly8ja0hCvcgUoLpE7N3Wsi7JfTTCbTpujV BXFTFQ11Vp2fQoG/05XFbJCHDhA3lw11xWVr9rrt75DQj4Zw3B7zucDxbser/Rmvi/mv69Tw4Vf8K J+69Cy4F9nVx0haPojNC1+frZl0L9s1gZfqliH8VllzLMFBhwHWaNx/5uTUEOTpacHAqzeK9kkWxD W4svFjVbTKrgQ/mmQ2CuqNZcUrHy8C07A1Ii24MHzMxSw2dOy1G1inwERz731aW85fpl5gtUda1Q6 dcH4qV1lhcZEN/Xe/7IfL9t6HQ==; From: vdixit@akamai.com To: ffmpeg-devel@ffmpeg.org Date: Wed, 11 Apr 2018 12:31:47 +0530 Message-Id: <1523430107-17265-1-git-send-email-vdixit@akamai.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1522831058-7238-1-git-send-email-vdixit@akamai.com> References: <1522831058-7238-1-git-send-email-vdixit@akamai.com> X-Smtpcorp-Track: 1f69_NNmF5_aKL.zfLcD2KYW Feedback-ID: 337386m:337386asVRLGB:337386s92HS81e_j:SMTPCORP X-Report-Abuse: Please forward a copy of this message, including all headers, to Subject: [FFmpeg-devel] [PATCH v3 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 5d5310d..70409e5 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\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; @@ -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;