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 233724D3FE for ; Fri, 21 Feb 2025 11:27:57 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 07CD068C795; Fri, 21 Feb 2025 13:27:30 +0200 (EET) Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.175]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E0ACA68C625 for ; Fri, 21 Feb 2025 13:27:15 +0200 (EET) Received: by mail-pl1-f175.google.com with SMTP id d9443c01a7336-220dc3831e3so47467345ad.0; Fri, 21 Feb 2025 03:27:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1740137234; x=1740742034; darn=ffmpeg.org; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc:subject:date :message-id:reply-to; bh=NpjsfHJjD6WDOHm77D6PLxKmBIisjJF4C09cFQeT0HI=; b=ma6VN3OJOdIPNvfXe64kIP5hc97ur4SKTMaKCAKVBGM3wbpknvSRTTc3H6Rl9UqO1e OzTegsGsoV1Qc4iZfcMAo+I4wzjuLy4dvMko2EJwnbPaAv3NVdSFu/uaAU4/kknd841q uznDDN5EI1KFzKFpbid4cgHEMwZnyHLf5+OVi6AGfBD/G+I7OR57KGRqf5LqrOw4NxC6 uMfl8rnCsdC5lvoHOvQvtibeAjc6RPl9g1rwRzMQr+FF2qaUbpzKPYAQKqK+V1r0+Y0C U6tlU2xUrABud7W6JZGdNopW5QyjJs0OTjE3UYueTvcM+TdK+SKCAsGZUBHd3tKpX7kv Cc1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1740137234; x=1740742034; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=NpjsfHJjD6WDOHm77D6PLxKmBIisjJF4C09cFQeT0HI=; b=nd9433GrEeaOF4rxKVsiRMDru7YiCMzIA87S+yAuTN2JXvJ3fBckKvrZB4r8T4fOsJ m0PdoONmyQBC/05A4qTcd3Vd+v5U+o5LU516koTlgz3f0VQWQzP2eXV/0NzVaQhKk6GM CthI0N4wU14g/WyFu/Pnu7txc6rybviaPNVs+xoVjZiaOYlwueHJLT6GvAsLZjOETpl3 ePfgylPPQC5jEtqZ00lYdj5DUb3fc0ifEbTeREYuyT9yN4jMF6SW5R2uj/3dlB+yd7TB cnaVmHHIqdjPkf0Otn2GbviaGwgM16cuspesI+JcAjhcL1XdqRt7OTeJBvauWGLjyU2U fo+w== X-Forwarded-Encrypted: i=1; AJvYcCW99zS3j5kK8v56lS14uvdyE4+0g05hiyQ7IRh8mXjCx93AAQ2OJy/vkdWd+6828TCIWhJEoQDH2ejifZzxLnp05xLzGRi3w+0=@ffmpeg.org X-Gm-Message-State: AOJu0Yw+3wJhHyG7Zl18B9Z+0ksgAgiIng8oaOPClhkN+qMKQ8G2EP0M 7kSIfEZ80hkheb1g5uPXwIJsQtjFP0RqQj574RWs21ryQLWtKU1Qt+Y32Q== X-Gm-Gg: ASbGncuIujcQl7lpWlpjF+fXNaYefafzbrO7DMd410n8Rc/q6Rjqygxo3/lN0cQ6og2 ITozXwKM6/uQp2PC2UUtLlHYN9/jErsQhyxCJR6TlwsVtsLCPm9vk/Aj3ABNMrl60u8wlRevEux kCQd30HmtOH7KlkzSxKlc93BEXcy2dyUteTIp5bDb6Si5qiWpyHaBphHBxoWsOCZCppMr9dSSqw CfLBesMeRPZC+zFrH+hAX+9/chXJwbK5mojfL0K2rTCJjkxz7tbv9IP0F6nbFT4wcGZAsvAiON2 X1zk5DuY49nGp9vn5iNkGVe/KiVl3tV7fUMKp7UDcrQo X-Google-Smtp-Source: AGHT+IGBXtyDlLpvAdpYxXJgPFNRUaU9H+0NSyb+0U14GF7r9OW1LqyiFBR40adSUsSIVUeTaeKf2w== X-Received: by 2002:a05:6a00:2fd7:b0:725:f1e9:5334 with SMTP id d2e1a72fcca58-7341410b39amr10293836b3a.8.1740137233182; Fri, 21 Feb 2025 03:27:13 -0800 (PST) Received: from [127.0.0.1] (master.gitmailbox.com. [34.83.118.50]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7324276121bsm15466250b3a.126.2025.02.21.03.27.12 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 21 Feb 2025 03:27:12 -0800 (PST) Message-Id: In-Reply-To: References: From: ffmpegagent Date: Fri, 21 Feb 2025 11:27:08 +0000 Fcc: Sent MIME-Version: 1.0 To: ffmpeg-devel@ffmpeg.org Subject: [FFmpeg-devel] [PATCH v2 0/4] print_graphs: Complete Filtergraph Printing 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 Cc: Soft Works , softworkz , Andreas Rheinhardt 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: The key benefits are: * Different to other graph printing methods, this is outputting: * all graphs with runtime state (including auto-inserted filters) * each graph with its inputs and outputs * all filters with their in- and output pads * all connections between all input- and output pads * for each connection: * the runtime-negotiated format and media type * the hw context * if video hw context, both: hw pixfmt + sw pixfmt * Output can either be printed to stdout or written to specified file * Output is machine-readable * Use the same output implementation as ffprobe, supporting multiple formats (this commit includes only the default and JSON writers) Right after filtergraph configuration, the connection details are often not complete yet. On the other side, when waiting too long or if an error occurs somewhere, the graph info might never be printed. Experience has shown, that the most suitable and realiable point in time for printing graph information is right before cleanup. Due to the changes for multi-threading, this is no longer doable as easy as before, so the following method is used: Each filtergraph initiates its own graph printing short before cleanup into a buffer. Before final cleanup in ffmpeg.c, the outputs from the individual graphs are pieced together for the actual output to file or console. (the structure according to the output format remains valid) Example output: https://gist.github.com/softworkz/2a9e8699b288f5d40fa381c2a496e165 Update V2 * Change NULL checks to match common code style * Add Add avfilter_link_get_hw_frames_ctx() function to avoid importing filters.h * Do the same without including avfilter/filters.h (as per note from Andreas Reinhardt) softworkz (4): fftools/ffmpeg_filter: Move some declaration to new header file avfilter/avfilter Add avfilter_link_get_hw_frames_ctx() fftools/ffmpeg_graphprint: Add options for filtergraph printing fftools: Enable filtergraph printing and update docs doc/APIchanges | 3 + doc/ffmpeg.texi | 10 + fftools/Makefile | 1 + fftools/ffmpeg.c | 4 + fftools/ffmpeg.h | 3 + fftools/ffmpeg_filter.c | 193 +----- fftools/ffmpeg_filter.h | 232 +++++++ fftools/ffmpeg_graphprint.c | 1141 +++++++++++++++++++++++++++++++++++ fftools/ffmpeg_graphprint.h | 224 +++++++ fftools/ffmpeg_opt.c | 12 + libavfilter/avfilter.c | 9 + libavfilter/avfilter.h | 12 + libavfilter/version.h | 2 +- 13 files changed, 1658 insertions(+), 188 deletions(-) create mode 100644 fftools/ffmpeg_filter.h create mode 100644 fftools/ffmpeg_graphprint.c create mode 100644 fftools/ffmpeg_graphprint.h base-commit: e18f87ed9f9f61c980420b315dc8ecb308831bc5 Published-As: https://github.com/ffstaging/FFmpeg/releases/tag/pr-ffstaging-52%2Fsoftworkz%2Fsubmit_print_graphs5-v2 Fetch-It-Via: git fetch https://github.com/ffstaging/FFmpeg pr-ffstaging-52/softworkz/submit_print_graphs5-v2 Pull-Request: https://github.com/ffstaging/FFmpeg/pull/52 Range-diff vs v1: 1: c843eb0741 = 1: c843eb0741 fftools/ffmpeg_filter: Move some declaration to new header file -: ---------- > 2: 5a7b45ab09 avfilter/avfilter Add avfilter_link_get_hw_frames_ctx() 2: 0750b971f9 ! 3: 1f87cfae77 fftools/ffmpeg_graphprint: Add options for filtergraph printing @@ fftools/ffmpeg_graphprint.c (new) +#include "libavutil/intreadwrite.h" +#include "libavutil/common.h" +#include "libavfilter/avfilter.h" -+#include "libavfilter/filters.h" +#include "libavutil/buffer.h" +#include "libavutil/hwcontext.h" + @@ fftools/ffmpeg_graphprint.c (new) + .priv_class = &json_class, +}; + -+static void print_hwdevicecontext(WriterContext *w, AVHWDeviceContext *hw_device_context) ++static void print_hwdevicecontext(WriterContext *w, const AVHWDeviceContext *hw_device_context) +{ + writer_print_section_header(w, SECTION_ID_HWDEViCECONTEXT); + @@ fftools/ffmpeg_graphprint.c (new) + writer_print_section_footer(w); // SECTION_ID_HWDEViCECONTEXT +} + -+static void print_hwframescontext(WriterContext *w, AVHWFramesContext *hw_frames_context) ++static void print_hwframescontext(WriterContext *w, const AVHWFramesContext *hw_frames_context) +{ + const AVPixFmtDescriptor* pixdescHw; + const AVPixFmtDescriptor* pixdescSw; @@ fftools/ffmpeg_graphprint.c (new) + print_int("HasHwFramesContext", 1); + + pixdescHw = av_pix_fmt_desc_get(hw_frames_context->format); -+ if (pixdescHw != NULL) { ++ if (pixdescHw) { + print_str("HwPixelFormat", pixdescHw->name); + print_str("HwPixelFormatAlias", pixdescHw->alias); + } + + pixdescSw = av_pix_fmt_desc_get(hw_frames_context->sw_format); -+ if (pixdescSw != NULL) { ++ if (pixdescSw) { + print_str("SwPixelFormat", pixdescSw->name); + print_str("SwPixelFormatAlias", pixdescSw->alias); + } @@ fftools/ffmpeg_graphprint.c (new) + break; + } + -+ FilterLink* plink = ff_filter_link(link); ++ AVBufferRef *hw_frames_ctx = avfilter_link_get_hw_frames_ctx(link); + -+ if (plink->hw_frames_ctx != NULL && plink->hw_frames_ctx->buffer != NULL) -+ print_hwframescontext(w, (AVHWFramesContext*)plink->hw_frames_ctx->data); ++ if (hw_frames_ctx && hw_frames_ctx->buffer) { ++ print_hwframescontext(w, (AVHWFramesContext *)hw_frames_ctx->data); ++ } +} + -+static void print_filter(WriterContext *w, AVFilterContext* filter) ++static void print_filter(WriterContext *w, const AVFilterContext* filter) +{ + writer_print_section_header(w, SECTION_ID_FILTER); + + print_str("Name", filter->name); + -+ if (filter->filter != NULL) { ++ if (filter->filter) { + print_str("Name2", filter->filter->name); + print_str("Description", filter->filter->description); + } + -+ if (filter->hw_device_ctx != NULL) { ++ if (filter->hw_device_ctx) { + AVHWDeviceContext* decCtx = (AVHWDeviceContext*)filter->hw_device_ctx->data; + print_hwdevicecontext(w, decCtx); + } @@ fftools/ffmpeg_graphprint.c (new) + writer_print_section_header(w, SECTION_ID_INPUT); + + print_str("SourceName", link->src->name); -+ print_str("SourcePadName", link->srcpad->name); -+ print_str("DestPadName", link->dstpad->name); ++ print_str("SourcePadName", avfilter_pad_get_name(link->srcpad, 0)); ++ print_str("DestPadName", avfilter_pad_get_name(link->dstpad, 0)); + + print_link(w, link); + @@ fftools/ffmpeg_graphprint.c (new) + writer_print_section_header(w, SECTION_ID_OUTPUT); + + print_str("DestName", link->dst->name); -+ print_str("DestPadName", link->dstpad->name); ++ print_str("DestPadName", avfilter_pad_get_name(link->dstpad, 0)); + print_str("SourceName", link->src->name); + + print_link(w, link); @@ fftools/ffmpeg_graphprint.c (new) + writer_print_section_footer(w); // SECTION_ID_FILTER +} + -+static void print_filtergraph_single(WriterContext *w, FilterGraph* fg) ++static void print_filtergraph_single(WriterContext *w, FilterGraph* fg, AVFilterGraph *graph) +{ + char layoutString[64]; + FilterGraphPriv *fgp = fgp_from_fg(fg); -+ AVFilterGraph* graph = NULL; + + print_int("GraphIndex", fg->index); + print_str("Description", fgp->graph_desc); @@ fftools/ffmpeg_graphprint.c (new) + + print_str("Name1", (char*)ifilter->ifilter.name); + -+ if (ifilter->filter != NULL) { ++ if (ifilter->filter) { + print_str("Name2", ifilter->filter->name); + print_str("Name3", ifilter->filter->filter->name); + print_str("Description", ifilter->filter->filter->description); @@ fftools/ffmpeg_graphprint.c (new) + break; + } + -+ if (ifilter->hw_frames_ctx != NULL) ++ if (ifilter->hw_frames_ctx) + print_hwframescontext(w, (AVHWFramesContext*)ifilter->hw_frames_ctx->data); -+ else if (ifilter->filter != NULL && ifilter->filter->hw_device_ctx != NULL) { ++ else if (ifilter->filter && ifilter->filter->hw_device_ctx) { + AVHWDeviceContext* devCtx = (AVHWDeviceContext*)ifilter->filter->hw_device_ctx->data; + print_hwdevicecontext(w, devCtx); + } + + writer_print_section_footer(w); // SECTION_ID_INPUT -+ -+ if (!graph && ifilter->filter != NULL && ifilter->filter->nb_outputs > 0) { -+ FilterLink* link = ff_filter_link(ifilter->filter->outputs[0]); -+ graph = link->graph; -+ } + } + + writer_print_section_footer(w); // SECTION_ID_INPUTS @@ fftools/ffmpeg_graphprint.c (new) + writer_print_section_header(w, SECTION_ID_OUTPUT); + print_str("Name1", ofilter->name); + -+ if (ofilter->filter != NULL) { ++ if (ofilter->filter) { + print_str("Name2", ofilter->filter->name); + print_str("Name3", ofilter->filter->filter->name); + print_str("Description", ofilter->filter->filter->description); @@ fftools/ffmpeg_graphprint.c (new) + break; + } + -+ if (ofilter->filter != NULL && ofilter->filter->hw_device_ctx != NULL) { ++ if (ofilter->filter && ofilter->filter->hw_device_ctx) { + AVHWDeviceContext* devCtx = (AVHWDeviceContext*)ofilter->filter->hw_device_ctx->data; + print_hwdevicecontext(w, devCtx); + } + + writer_print_section_footer(w); // SECTION_ID_OUTPUT -+ -+ if (!graph && ofilter->filter != NULL && ofilter->filter->nb_inputs > 0) { -+ FilterLink* link = ff_filter_link(ofilter->filter->inputs[0]); -+ graph = link->graph; -+ } + } + + writer_print_section_footer(w); // SECTION_ID_OUTPUTS @@ fftools/ffmpeg_graphprint.c (new) + + writer_print_section_header(w, SECTION_ID_FILTERS); + -+ if (graph != NULL) { ++ if (graph) { + for (unsigned i = 0; i < graph->nb_filters; i++) { + AVFilterContext *filter = graph->filters[i]; + writer_print_section_header(w, SECTION_ID_FILTER); @@ fftools/ffmpeg_graphprint.c (new) + + av_bprint_clear(&w->bpBuf); + -+ print_filtergraph_single(w, fg); ++ print_filtergraph_single(w, fg, graph); + + av_bprint_finalize(&w->bpBuf, &targetBuf->str); + targetBuf->len = w->bpBuf.len; 3: 7eea20993c = 4: 1bf975fa0e fftools: Enable filtergraph printing and update docs -- ffmpeg-codebot _______________________________________________ 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".