From patchwork Sat Dec 9 18:28:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: jb X-Patchwork-Id: 6650 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.161.94 with SMTP id m30csp953132jah; Sat, 9 Dec 2017 10:28:57 -0800 (PST) X-Google-Smtp-Source: AGs4zMZRMwCRlRpMrd06UF/hbQyq7b9COQ7l9usIIXPP/RIdulzbqCdxLiC2r9KGDfAv0NVDmy+C X-Received: by 10.28.134.133 with SMTP id i127mr7143808wmd.79.1512844137735; Sat, 09 Dec 2017 10:28:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512844137; cv=none; d=google.com; s=arc-20160816; b=QGPSeGryqPsG1c8ZblXMjQTfemlGTnhLLz30Co45QkHfUdXf5RQxBslLeyuJa35GXi u0A15zBwm9GBfxByNCoVKED5InEcTCvVRH1a+ZQDyUB6LprJ+N7OoR/AUZ4b44llUYzM EDv0wS1AQR6ENlJzawfd61iS35GBlAqc60N3hMEgye5jyrKZGk2+VGmJ3dfUPFsJUutt jgsyMNIoo5/7LoRr5+kWC+TfmhoTdC7w+KBz+pQLerOFBP2GTE8U4W595zihm2waN5Ko YwJ4hx5aDrRgjJErAwbHhBGBMx0W61KYcN75aom4xRREJi20ACBRr47TipPfR4XGAoGz 9JAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:subject :content-language:mime-version:user-agent:date:message-id:from:to :dkim-signature:delivered-to:arc-authentication-results; bh=XIlGlq+1rIoNUvD1NiJeeJbwXOwUw8p0wUGacbnvEUI=; b=l4Y6dP4HWpihsPLyXuy2CJmyg7BqHCR+Dhc2FUh4JI40PlpSmiuD+stbbBhiz3DwO7 BB9PPneomaogiI2MGZibgV2XDn2eW7CzOq+12wbx+s2BZQEXa17El6R/c1M+Y4W7+zqj 5bq/hNajN6VBgNM3+KP3pRsJz+r4P9ZYsVnFZip7Xodh1n2mC2oyzRHXXMPXTf/GePlV 9UAYqYNquuDRpxiHzXerrqr8J0KPxBmCeiO41PmuloFlusjmB8yNPwxWletGouxDfJAR YzFkiRkiJVJhw8+/Oc1M03QwVeK16wuwt+/53KY26AbjRFoOmTEb94I5iPvsX97hA8pe uaPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=HQ0Uf2SG; 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=NONE sp=NONE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id h25si8291429wrf.107.2017.12.09.10.28.57; Sat, 09 Dec 2017 10:28:57 -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; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=HQ0Uf2SG; 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=NONE sp=NONE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 670A168A4D1; Sat, 9 Dec 2017 20:28:49 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr0-f174.google.com (mail-wr0-f174.google.com [209.85.128.174]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 888EF680154 for ; Sat, 9 Dec 2017 20:28:43 +0200 (EET) Received: by mail-wr0-f174.google.com with SMTP id z34so13653597wrz.10 for ; Sat, 09 Dec 2017 10:28:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=to:from:subject:message-id:date:user-agent:mime-version :content-language; bh=W7Plg04W9RK2M7QkWOPqrPm8jUHtThC2jrftcMDTTCA=; b=HQ0Uf2SG1iG6j88Kg0tUQVvvVG64dQl6D2is3CTo73ViBSEZYll3EI9QxrOmDXJZ32 eiY5eXDbvJ6qMMjjdjC6hbqAtX3rnjLpxqrNfnHret7odXAQJUWKyT23cfywE8Vm/6Hz AiwpBDzdDwpCAYzCN86z+r3i6MDAQCBJ8drrF06YjWaTZeJVWU0a+BNSjujT93HsgMt5 fCY2HfcTBZk0+S25b7sqI2ZDAvkSbmnrcDxI/3sI2sLty5fqtUE3nSwGk1X5ZryD2cKP vSh5Gip7+YS91QXIcHXfBsouduq5ahwZZRDx/4ll9jQGuCldjLOsakCh/Gqrl1tI7aed 72ZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:from:subject:message-id:date:user-agent :mime-version:content-language; bh=W7Plg04W9RK2M7QkWOPqrPm8jUHtThC2jrftcMDTTCA=; b=PFwszEpIgj+HhjebG5SuZM55OfOj0kesRNbRjnfKpVoPtsmnV5QMOUI8X8nRhLACuV WFq/e1Xjtoxp92cB9LzNNFhqXfEaISSJUL/V6jUkOD0RpVRV2yWe/YLq1vuqYZmHfVLz NltKdS+87Itz7VppGgy2Gu2HDr2UOio22zHpps932PH2C5/IBTF+5QC/GnG4KfQsSywh yTIy3K/fcfD3k0yKrnUl+rFX8vJZ7/6mQtiIIG31XWmQb/g4MHt+ArXEirX7MoUYliws G5pF+bR8zOI06oePoreTEGE3IjXqri1H9q24udJVvJoOxHx0U0viOv2vryhWv5x1c8w8 uQPA== X-Gm-Message-State: AJaThX5JWcTPSunVctsAuSotI5pRAYZhuE1X1PZQyLWwthO3ywofG6hF 90NERx5gsnG/iUypPoKR/mULyQ== X-Received: by 10.223.195.22 with SMTP id n22mr33422915wrf.212.1512844129667; Sat, 09 Dec 2017 10:28:49 -0800 (PST) Received: from [192.168.2.106] (p5B1468E9.dip0.t-ipconnect.de. [91.20.104.233]) by smtp.gmail.com with ESMTPSA id 56sm13466055wrx.73.2017.12.09.10.28.48 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 09 Dec 2017 10:28:49 -0800 (PST) To: ffmpeg-devel@ffmpeg.org From: Jonathan Baecker Message-ID: <9e2b12db-81f6-d80d-5ed7-8c07e308f9b8@gmail.com> Date: Sat, 9 Dec 2017 19:28:51 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 Content-Language: en-US X-Content-Filtered-By: Mailman/MimeDel 2.1.20 Subject: [FFmpeg-devel] [PATCH v2] libavfilter/vf_blackdetect.c 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" Hello! I wanted to apologize for the mess! Last Monday I already sended this patch, but the first was not correct, and on top the email format was not right to. So I hope now everything is ok. Here is again the description: This patch unify vf_blackdetect with af_silencedetect. Now the logging prints *black_start* and *black_end* in separate lines. This is the same behavior like af_silencedetect and it is also more useful for monitoring stream. It works in that way, that when the black duration passes the duration limit the log massage is: *black_start: 7.56 *and when the last black frame comes, the massage: *black_end: 25 | black_duration: 17.44 *pop up. I did compiling tests on MacOS/Windows and Ubuntu, all works fine. I also make a fate test, it runs to, but I was not able to run this command: tests/fate.sh fate-suite/ It always says something with path not fund... Is it really necessary to run a fate test, even with a little change like this? Regards Jonathan From b6b6e4ab885f9b35a6696492286e504a4b3d6d92 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Mon, 4 Dec 2017 16:05:48 +0100 Subject: [PATCH] unify blackdetect with af_silencedetect. Is more useful for monitoring streams. --- libavfilter/vf_blackdetect.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) -- 2.15.1 diff --git a/libavfilter/vf_blackdetect.c b/libavfilter/vf_blackdetect.c index 06ef9988d..92ea39b33 100644 --- a/libavfilter/vf_blackdetect.c +++ b/libavfilter/vf_blackdetect.c @@ -38,6 +38,7 @@ typedef struct BlackDetectContext { int64_t black_end; ///< pts end time of the last black picture int64_t last_picref_pts; ///< pts of the last input picture int black_started; + int black_match; double picture_black_ratio_th; double pixel_black_th; @@ -107,15 +108,20 @@ static int config_input(AVFilterLink *inlink) return 0; } -static void check_black_end(AVFilterContext *ctx) +static void check_black(AVFilterContext *ctx) { BlackDetectContext *blackdetect = ctx->priv; AVFilterLink *inlink = ctx->inputs[0]; - if ((blackdetect->black_end - blackdetect->black_start) >= blackdetect->black_min_duration) { + if ((blackdetect->last_picref_pts - blackdetect->black_start) >= blackdetect->black_min_duration && blackdetect->black_match == 0) { av_log(blackdetect, AV_LOG_INFO, - "black_start:%s black_end:%s black_duration:%s\n", - av_ts2timestr(blackdetect->black_start, &inlink->time_base), + "black_start: %s \n", + av_ts2timestr(blackdetect->black_start, &inlink->time_base)); + blackdetect->black_match = 1; + } + if ((blackdetect->black_end - blackdetect->black_start) >= blackdetect->black_min_duration && blackdetect->black_started == 1) { + av_log(blackdetect, AV_LOG_INFO, + "black_end: %s | black_duration: %s \n", av_ts2timestr(blackdetect->black_end, &inlink->time_base), av_ts2timestr(blackdetect->black_end - blackdetect->black_start, &inlink->time_base)); } @@ -131,7 +137,7 @@ static int request_frame(AVFilterLink *outlink) if (ret == AVERROR_EOF && blackdetect->black_started) { // FIXME: black_end should be set to last_picref_pts + last_picref_duration blackdetect->black_end = blackdetect->last_picref_pts; - check_black_end(ctx); + check_black(ctx); } return ret; } @@ -163,15 +169,17 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *picref) if (!blackdetect->black_started) { /* black starts here */ blackdetect->black_started = 1; + blackdetect->black_match = 0; blackdetect->black_start = picref->pts; av_dict_set(&picref->metadata, "lavfi.black_start", av_ts2timestr(blackdetect->black_start, &inlink->time_base), 0); } + check_black(ctx); } else if (blackdetect->black_started) { /* black ends here */ - blackdetect->black_started = 0; blackdetect->black_end = picref->pts; - check_black_end(ctx); + check_black(ctx); + blackdetect->black_started = 0; av_dict_set(&picref->metadata, "lavfi.black_end", av_ts2timestr(blackdetect->black_end, &inlink->time_base), 0); }