From patchwork Sat Jan 21 14:39:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Peter_Gro=C3=9Fe?= X-Patchwork-Id: 2276 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.89.21 with SMTP id n21csp529241vsb; Sat, 21 Jan 2017 06:40:42 -0800 (PST) X-Received: by 10.223.131.99 with SMTP id 90mr16286695wrd.146.1485009642719; Sat, 21 Jan 2017 06:40:42 -0800 (PST) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id r123si7296156wmd.141.2017.01.21.06.40.42; Sat, 21 Jan 2017 06:40:42 -0800 (PST) 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; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id BDE0D68A82D; Sat, 21 Jan 2017 16:39:22 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from james.theweblords.de (james.theweblords.de [217.11.55.87]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B0BEB68A7E5 for ; Sat, 21 Jan 2017 16:39:14 +0200 (EET) Received: (qmail 28173 invoked by uid 210); 21 Jan 2017 14:39:26 -0000 X-Qmail-Scanner-Diagnostics: from x5d808bdc.dyn.telefonica.de (petronios@theweblords.de@x5d808bdc.dyn.telefonica.de) by james (envelope-from , uid 201) with qmail-scanner-2.10st (mhr: 1.0. spamassassin: 3.4.1. perlscan: 2.10st. Clear:RC:1(93.128.139.220):. Processed in 0.046362 secs); 21 Jan 2017 14:39:26 -0000 Received: from x5d808bdc.dyn.telefonica.de (HELO montepegro.fem.tu-ilmenau.de) (petronios@theweblords.de@93.128.139.220) by james.theweblords.de with ESMTPA; 21 Jan 2017 14:39:26 -0000 From: =?UTF-8?q?Peter=20Gro=C3=9Fe?= To: ffmpeg-devel@ffmpeg.org Date: Sat, 21 Jan 2017 15:39:08 +0100 Message-Id: <20170121143909.29028-8-pegro@friiks.de> X-Mailer: git-send-email 2.10.2 In-Reply-To: <20170121143909.29028-1-pegro@friiks.de> References: <20170121143909.29028-1-pegro@friiks.de> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 7/8] libavformat/dashenc: support for hinting stream bandwidth using metadata option 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: ischluff@mailbox.org, pegro@friiks.de Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Bandwidth information is required in the manifest, but not always provided by the demuxer. So enable hinting the stream bandwidth via a metadata field, supports same values as codec bitrate setting. Example: -metadata:s:v:0 bitrate=3500k Signed-off-by: Peter Große --- libavformat/dashenc.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c index 0c0248f..522a0eb 100644 --- a/libavformat/dashenc.c +++ b/libavformat/dashenc.c @@ -607,6 +607,17 @@ static int dash_init(AVFormatContext *s) char filename[1024]; os->bit_rate = s->streams[i]->codecpar->bit_rate; + // if no bit rate detected, try whether bitrates are provided via metadata + if(!os->bit_rate) { + AVDictionaryEntry *bitrate; + bitrate = av_dict_get(s->streams[i]->metadata, "bitrate", NULL, 0); + if(bitrate) { + char *tail; + os->bit_rate = av_strtod(bitrate->value, &tail); + if (*tail) + os->bit_rate = 0; + } + } if (os->bit_rate) { snprintf(os->bandwidth_str, sizeof(os->bandwidth_str), " bandwidth=\"%d\"", os->bit_rate);