From patchwork Thu Sep 8 13:49:12 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ligverd Haer X-Patchwork-Id: 478 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.140.134 with SMTP id o128csp841117vsd; Thu, 8 Sep 2016 06:52:29 -0700 (PDT) X-Received: by 10.28.41.131 with SMTP id p125mr8958682wmp.15.1473342749183; Thu, 08 Sep 2016 06:52:29 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id x67si8812473wmg.113.2016.09.08.06.52.23; Thu, 08 Sep 2016 06:52:29 -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; 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 91FD9689B63; Thu, 8 Sep 2016 16:52:11 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail.kursktelecom.ru (mail.kursktelecom.ru [77.241.16.8]) by ffbox0-bg.mplayerhq.hu (Postfix) with SMTP id CF2976800D2 for ; Thu, 8 Sep 2016 16:52:04 +0300 (EEST) Received: (qmail 31235 invoked by uid 89); 8 Sep 2016 16:49:13 +0300 Received: by simscan 1.1.0 ppid: 31228, pid: 31230, t: 1.5844s scanners: regex: 1.1.0 attach: 1.1.0 clamav: 0.88.2/m:38/d:1452 spam: 3.1.1 X-Spam-Checker-Version: SpamAssassin 3.1.1 (2006-03-10) on mail.kursktelecom.ru X-Spam-Level: X-Spam-Status: No, score=-0.2 required=5.0 tests=ALL_TRUSTED, WEIRD_QUOTING autolearn=disabled version=3.1.1 Received: from ligverd.kursktelecom.ru (HELO kid.localnet) (hidra@kursktelecom.ru@77.241.16.66) by smtp.kursktelecom.ru with ESMTPA; 8 Sep 2016 16:49:12 +0300 From: Ligverd Haer To: FFmpeg development discussions and patches Date: Thu, 08 Sep 2016 16:49:12 +0300 Message-ID: <3350228.10vRjjMd7z@kid> User-Agent: KMail/5.2.3 (Linux/4.1.13-smp; KDE/5.24.0; i686; ; ) In-Reply-To: References: <2105862.8yzaTEHBEC@kid> <1611932.3eRvJ2Ql1C@kid> MIME-Version: 1.0 Subject: Re: [FFmpeg-devel] dash encoder. Correct generated manifest for MPEG-DASH MPD Validator and calculate current bandwidth for eath chunk. Now works correctly with dash.sj 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" > Please send your updated patch as attachment to a > reply in this mailing list thread, > > Please tell us if documentation pointed you to github or trac to > post patches, we try hard to have patch submission (only) on > this mailing list. > > Carl Eugen diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c index 519f9c4..ea96f71 100644 --- a/libavformat/dashenc.c +++ b/libavformat/dashenc.c @@ -498,17 +498,15 @@ static int write_manifest(AVFormatContext *s, int final) OutputStream *os = &c->streams[0]; int start_index = FFMAX(os->nb_segments - c->window_size, 0); int64_t start_time = av_rescale_q(os->segments[start_index]->time, s->streams[0]->time_base, AV_TIME_BASE_Q); - avio_printf(out, "\t\n"); } else { - avio_printf(out, "\t\n"); + avio_printf(out, "\t\n",final?"":" id=\"0\""); } if (c->has_video) { avio_printf(out, "\t\tmax_frame_rate.num && !c->ambiguous_frame_rate) - avio_printf(out, " %s=\"%d/%d\"", (av_cmp_q(c->min_frame_rate, c->max_frame_rate) < 0) ? "maxFrameRate" : "frameRate", c->max_frame_rate.num, c->max_frame_rate.den); avio_printf(out, ">\n"); for (i = 0; i < s->nb_streams; i++) { @@ -598,11 +596,15 @@ static int dash_write_header(AVFormatContext *s) AVDictionary *opts = NULL; char filename[1024]; - os->bit_rate = s->streams[i]->codecpar->bit_rate; + os->bit_rate = s->streams[i]->codecpar->bit_rate ? s->streams[i]->codecpar->bit_rate : s->bit_rate; + if (os->bit_rate) { snprintf(os->bandwidth_str, sizeof(os->bandwidth_str), " bandwidth=\"%d\"", os->bit_rate); } else { + snprintf(os->bandwidth_str, sizeof(os->bandwidth_str), + " bandwidth=\"%d\"", 0); + int level = s->strict_std_compliance >= FF_COMPLIANCE_STRICT ? AV_LOG_ERROR : AV_LOG_WARNING; av_log(s, level, "No bit rate set for stream %d\n", i); @@ -654,7 +656,7 @@ static int dash_write_header(AVFormatContext *s) goto fail; os->init_start_pos = 0; - av_dict_set(&opts, "movflags", "frag_custom+dash+delay_moov", 0); + av_dict_set(&opts, "movflags", "dash+frag_keyframe+empty_moov+separate_moof+delay_moov", 0); if ((ret = avformat_write_header(ctx, &opts)) < 0) { goto fail; } @@ -858,6 +860,10 @@ static int dash_flush(AVFormatContext *s, int final, int stream) if (ret < 0) break; } + + os->bit_rate = (int)( (float)range_length*8 / ((float)(os->max_pts - os->start_pts) / 10000) ); + snprintf(os->bandwidth_str, sizeof(os->bandwidth_str)," bandwidth=\"%i\"", os->bit_rate); + add_segment(os, filename, os->start_pts, os->max_pts - os->start_pts, start_pos, range_length, index_length); av_log(s, AV_LOG_VERBOSE, "Representation %d media segment %d written to: %s\n", i, os->segment_index, full_path); }