From patchwork Thu Apr 16 04:26:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 18993 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id CF52844A808 for ; Thu, 16 Apr 2020 07:28:18 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 5A36068BBB3; Thu, 16 Apr 2020 07:28:18 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-qk1-f172.google.com (mail-qk1-f172.google.com [209.85.222.172]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E817A68BBAC for ; Thu, 16 Apr 2020 07:28:09 +0300 (EEST) Received: by mail-qk1-f172.google.com with SMTP id v7so20112085qkc.0 for ; Wed, 15 Apr 2020 21:28:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=0gcDMUV6hG64gx6V3hkjGDyJPOi1bMP2A++bGO2OOZA=; b=dVDwk+D/lYkEr6aUsJXuN3XvBjQMQ2wKqLv1qXYbDPPoysV1IQ79jFW4nYBRvcNRo5 03/U0MpVIbyHD4wygqz4akaAxcPyld21Dza0DTKypaiYhSNP6aX3DMFP8L0bQQf9vKlN Qx7U6ilO1d14ONzJBj5XBZH1l/g5IxAhJrTs7J02mvKy/L3iYbF3WjMM5oJmIuPUICXI 67U5WCaAFZY+kJbsz8il/oplFnzPPNXfVqgWGu+kgWiGC9SaZD8cVA/99IHi9u2BUEbn ns/BEKfAEKzmH92E9Un11YjjXv9bojCli10Po+ZsLanhv1TYsOVl9U2SfYQBMDHc4cdR OmkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0gcDMUV6hG64gx6V3hkjGDyJPOi1bMP2A++bGO2OOZA=; b=T2kFEb0Mk11Mlps5eUzT/s+HtT6N2ua+cXcknqMvvGjiJwfw+xsmo1g/7JkN5Kwscf zTbvoDPpPUplg1SNmq/zU77QwyfCJnIwIKZZ2f17FOhDqu/vITJ38N+5kj5ecWYkKQy9 LQigP7zfhrSv9lZU7hQE6aN1IBWAbHh+WrS2AszVpCOM/YEkhZ5/GjTSbClE3ggpH1Db KlyT5y4ETunJIVPNIXcCdEPVL42A6GM4IQU0qUuDrD42SWjHgAc9Wjsa3u896QzY41NN GvqJzrERhbtrp12fJ6kUs6y9B8v35ei7eer8Ztrsxmi9HphrD5WqccUduwLVuGfD5zN9 KQSQ== X-Gm-Message-State: AGi0PuYSYBPfo+oL3g/G0l4wusRl9tVJJGKVsC62ao4a6gQjkFZ/YAxJ BhNYuGi45lFCJfcyQDd1II5vhCi4 X-Google-Smtp-Source: APiQypLnIkNE+wEkoUNRfV/8SaXf4d2OnhDeAZWA9KtWa5aCDwgrAI7aarVB4lLISAodn0BI/WhODA== X-Received: by 2002:a37:a9c7:: with SMTP id s190mr15157083qke.435.1587011288222; Wed, 15 Apr 2020 21:28:08 -0700 (PDT) Received: from localhost.localdomain ([191.83.216.57]) by smtp.gmail.com with ESMTPSA id u24sm6198966qkk.84.2020.04.15.21.28.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Apr 2020 21:28:07 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Thu, 16 Apr 2020 01:26:07 -0300 Message-Id: <20200416042608.9587-3-jamrial@gmail.com> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200416042608.9587-1-jamrial@gmail.com> References: <20200416042608.9587-1-jamrial@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 3/4] avformat/dashenc: add a PlaybackRate element 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: James Almer --- doc/muxers.texi | 8 ++++++++ libavformat/dashenc.c | 18 ++++++++++++++++-- libavformat/version.h | 2 +- 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/doc/muxers.texi b/doc/muxers.texi index 856ed74e56..d341827a86 100644 --- a/doc/muxers.texi +++ b/doc/muxers.texi @@ -356,6 +356,14 @@ protocol. Applicable only for HTTP output. Set an intended target latency in seconds (fractional value can be set) for serving. Applicable only when @var{streaming} and @var{write_prft} options are enabled. This is an informative fields clients can use to measure the latency of the service. +@item min_playback_rate @var{min_playback_rate} +Set the minimum playback rate indicated as appropriate for the purposes of automatically +adjusting playback latency and buffer occupancy during normal playback by clients. + +@item max_playback_rate @var{max_playback_rate} +Set the maximum playback rate indicated as appropriate for the purposes of automatically +adjusting playback latency and buffer occupancy during normal playback by clients. + @end table @anchor{framecrc} diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c index ef1bedd18d..86329b7f9a 100644 --- a/libavformat/dashenc.c +++ b/libavformat/dashenc.c @@ -194,6 +194,8 @@ typedef struct DASHContext { int profile; int64_t target_latency; int target_latency_refid; + AVRational min_playback_rate; + AVRational max_playback_rate; } DASHContext; static struct codec_string { @@ -1203,14 +1205,19 @@ static int write_manifest(AVFormatContext *s, int final) av_free(escaped); } avio_printf(out, "\t\n"); + + avio_printf(out, "\t\n"); if (!final && c->target_latency && c->target_latency_refid >= 0) { - avio_printf(out, "\t\n"); avio_printf(out, "\t\ttarget_latency / 1000); if (s->nb_streams > 1) avio_printf(out, " referenceId=\"%d\"", c->target_latency_refid); avio_printf(out, "/>\n"); - avio_printf(out, "\t\n"); } + if (av_cmp_q(c->min_playback_rate, (AVRational) {1, 1}) || + av_cmp_q(c->max_playback_rate, (AVRational) {1, 1})) + avio_printf(out, "\t\t\n", + av_q2d(c->min_playback_rate), av_q2d(c->max_playback_rate)); + avio_printf(out, "\t\n"); if (c->window_size && s->nb_streams > 0 && c->streams[0].nb_segments > 0 && !c->use_template) { OutputStream *os = &c->streams[0]; @@ -1423,6 +1430,11 @@ static int dash_init(AVFormatContext *s) c->target_latency = 0; } + if (av_cmp_q(c->max_playback_rate, c->min_playback_rate) < 0) { + av_log(s, AV_LOG_WARNING, "Minimum playback rate value is higer than the Maximum. Both will be ignored\n"); + c->min_playback_rate = c->max_playback_rate = (AVRational) {1, 1}; + } + av_strlcpy(c->dirname, s->url, sizeof(c->dirname)); ptr = strrchr(c->dirname, '/'); if (ptr) { @@ -2370,6 +2382,8 @@ static const AVOption options[] = { { "dvb_dash", "DVB-DASH profile", 0, AV_OPT_TYPE_CONST, {.i64 = MPD_PROFILE_DVB }, 0, UINT_MAX, E, "mpd_profile"}, { "http_opts", "HTTP protocol options", OFFSET(http_opts), AV_OPT_TYPE_DICT, { .str = NULL }, 0, 0, E }, { "target_latency", "Set desired target latency for Low-latency dash", OFFSET(target_latency), AV_OPT_TYPE_DURATION, { .i64 = 0 }, 0, INT_MAX, E }, + { "min_playback_rate", "Set desired minimum playback rate", OFFSET(min_playback_rate), AV_OPT_TYPE_RATIONAL, { .dbl = 1.0 }, 0.5, 1.5, E }, + { "max_playback_rate", "Set desired maximum playback rate", OFFSET(max_playback_rate), AV_OPT_TYPE_RATIONAL, { .dbl = 1.0 }, 0.5, 1.5, E }, { NULL }, }; diff --git a/libavformat/version.h b/libavformat/version.h index 18c2f5fec2..719cda6b98 100644 --- a/libavformat/version.h +++ b/libavformat/version.h @@ -33,7 +33,7 @@ // Also please add any ticket numbers that you believe might be affected here #define LIBAVFORMAT_VERSION_MAJOR 58 #define LIBAVFORMAT_VERSION_MINOR 42 -#define LIBAVFORMAT_VERSION_MICRO 100 +#define LIBAVFORMAT_VERSION_MICRO 101 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ LIBAVFORMAT_VERSION_MINOR, \