From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTPS id D1C064E322 for ; Mon, 10 Mar 2025 19:56:39 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 28E2768E115; Mon, 10 Mar 2025 21:55:56 +0200 (EET) Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B900F68E006 for ; Mon, 10 Mar 2025 21:55:54 +0200 (EET) Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-43cfebc343dso6027955e9.2 for ; Mon, 10 Mar 2025 12:55:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1741636554; x=1742241354; darn=ffmpeg.org; h=thread-index:content-language:content-transfer-encoding :mime-version:message-id:date:subject:to:from:from:to:cc:subject :date:message-id:reply-to; bh=/dP33+Y4zxNFKnZXTeB5JKsNqrX0mENGYx59NiBxIe8=; b=PTI0kXhBps9XAKkaIZl3zYJ1MphtEwQhb3FHg5/1LQJ9nmYxFIEQussbMdP6nOv0C/ 7tSPgTL2Q3jMKhV+g1fXBt5JlS1aX8LDblKuFqdHqXZ5+Hlw17P2FsDDu2QMOROk1IVg VjSyk9Up7TOjE30FqAjrBsTgSakPJVoRMAXax+vAVnybuyYNmFJq7ADbn2a83hWNptvz m0yTJvSaH1WQGkQNklryLBiBxqY65lrgBbfeMZj9LMzFkX/WX7/kEJwFzgjios3KqB+l PkCLPXeJpFuwi+SF1uh8LGrO4K2smTTShwnNsVEr6BHwrvV3DSdx4AjEcGOMTmy7H67r GFWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741636554; x=1742241354; h=thread-index:content-language:content-transfer-encoding :mime-version:message-id:date:subject:to:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=/dP33+Y4zxNFKnZXTeB5JKsNqrX0mENGYx59NiBxIe8=; b=LJc0UF9gUm0hpWO4Jnk785nRW7ait7aTm3fAmnf3zyU1XBcF1C2MVsaCf3BU9PJ9CX cwV6wvX/O2xQguVF2Qao5OWheeEX6Fe0r4wmixpZKTKFL8Bn7ArFGj21bwKVqTiPpapy pr0MBl9ZTlRGREFTr0ixCuMIx40bJqZiYzudk9U1mA8j2lyi4wFK+l6Bsc3cN84X8f2N LEHCFiQbKBKBP4HFVnPUfKhh+6jnLvWSIIfQ6Ua0qEizUcszsIdUA631x1IvgylgMMUn 6JPTtpiCYXGktW3y1Bk0DmyBggSRc4TTPAQbmKWKomBA1DiSBPNlt6okp97TJW55foqu tRFg== X-Gm-Message-State: AOJu0Yy+Lg+Z09crAmzub/4z9xFWy4u0flnznk/2MGho3aLSrwYDkNcD BnQiqDW42XJSJ7D6GU1ZVBKZlMefG+508n7VylbqE077V5Me12W4B9MHag== X-Gm-Gg: ASbGncuwZBgQsQ+JZ3ogMzFgvq6+MIPLFe96CUawx7f5nv1qM5uSvMq9unu3ND4SVxG PlnjIIE+h/4mnxtPq4OB7YQIVCELNmDJbj0Ujy/DHTbzjLguCUdL3GMPgASb7kNjXvPuRGY5QZg Cre/+1TZKKHZtb1k2tYiVJrof3bg0hVfSaj0l8orKxN0fSCz19HaaoWpz4IaaeVOUCxVqGTIyvM jEe3gtnYNyAeauHggcNWp7OI+rmQJEGyTzLWnpCxIoJmRqZV3UCU6yVmMSeXT1m4XhmvA51mfSc yRJUxOJuMSMJI7hh8VJ4hTMFGjMFFw4L/KBfHyRIZ/0upghyUWD0TMvFNVXmeXKFVfXk6GyY1NK sxfMXLR9mglxVLnY4 X-Google-Smtp-Source: AGHT+IHpu6CugUF78lrP9iZ9bEL1ntmE1zpJQCQzXL5kN0uSoyQfUZuKIK45BFPYubbcR28+hB5/xQ== X-Received: by 2002:a05:600c:1c05:b0:43b:b756:f0a9 with SMTP id 5b1f17b1804b1-43d01bdbea9mr15817925e9.11.1741636553452; Mon, 10 Mar 2025 12:55:53 -0700 (PDT) Received: from MK2 (80-108-16-220.cable.dynamic.surfer.at. [80.108.16.220]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3912c01d2cdsm16103235f8f.57.2025.03.10.12.55.52 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 10 Mar 2025 12:55:53 -0700 (PDT) From: To: Date: Mon, 10 Mar 2025 20:55:53 +0100 Message-ID: <004801db91f6$6e430570$4ac91050$@gmail.com> MIME-Version: 1.0 X-Mailer: Microsoft Outlook 16.0 Content-Language: en-at Thread-Index: AduR9myb1yFXHvhQRKKi4khunVXcnA== Subject: [FFmpeg-devel] [PATCH v2 FFmpeg 20/20] doc/filters.texi: avgclass documentation X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: Signed-off-by: MaximilianKaindl --- doc/filters.texi | 64 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/doc/filters.texi b/doc/filters.texi index a7046e0f4e..340ce39e2a 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -30776,6 +30776,70 @@ bench=start,selectivecolor=reds=-.2 .12 -.49,bench=stop @end example @end itemize +@section avgclass + +Average classification probabilities across multiple frames for both audio and video streams. + +This filter analyzes classification data from frame side data (bounding boxes) and calculates average confidence scores for each label. The filter processes classification metadata from the @code{dnn_classify} filter or other sources that generate AVDetectionBBox side data, computing averages over the entire stream. + +At the end of the stream (or when manually triggered), the filter outputs the average probability for each detected class, both to console logs and optionally to a CSV file. + +@table @option +@item output_file +Path to a CSV output file where average classification results will be written. If not specified, results are only printed to log output. + +@item v +Specify the number of video streams (default: 1). + +@item a +Specify the number of audio streams (default: 0). +@end table + +This filter supports the following commands: + +@table @option +@item writeinfo +Immediately write current average classification results to the log and output file (if specified) without waiting for the stream to end. + +@item flush +Force the filter to write results and flush all its internal state. +@end table + +@subsection Examples + +Process a video with object detection and classification, then calculate average classification probabilities: +@example +ffmpeg -i input.mp4 -vf "dnn_detect=model=detection.xml:input=data:output=detection_out:confidence=0.5,dnn_classify=model=classification.pt:dnn_backend=torch:tokenizer=tokenizer.json:labels=labels.txt,avgclass=output_file=results.csv" -f null - +@end example + +Process both audio and video classification: +@example +ffmpeg -i input.mkv -filter_complex "[0:v]dnn_classify[v0]; [0:a]aformat=sample_fmts=fltp,dnn_classify=dnn_backend=torch:model=clap_model.pt:is_audio=1:tokenizer=tokenizer.json:labels=audio_labels.txt[a0]; [v0][a0]avgclass=v=1:a=1:output_file=av_results.csv" -f null - +@end example + +@subsection Output Format + +When the filter completes processing (or when the @code{writeinfo} command is sent), it outputs classification results in this format: + +@example +Classification averages: +Stream #0: + Label: cat: Average probability 0.8765, Appeared 120 times + Label: dog: Average probability 0.3421, Appeared 42 times +Stream #1: + Label: music: Average probability 0.9823, Appeared 315 times + Label: speech: Average probability 0.1245, Appeared 15 times +@end example + +If an output file is specified, the same data is written in CSV format: +@example +stream_id,label,avg_probability,count +0,cat,0.8765,120 +0,dog,0.3421,42 +1,music,0.9823,315 +1,speech,0.1245,15 +@end example + @section concat Concatenate audio and video streams, joining them together one after the -- 2.34.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".