Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Devin Heitmueller <devin.heitmueller@ltnglobal.com>
To: ffmpeg-devel@ffmpeg.org
Cc: Devin Heitmueller <dheitmueller@ltnglobal.com>
Subject: [FFmpeg-devel] [PATCH 2/7] vf_drawtext: Add ability to show AFD value
Date: Wed,  7 Jun 2023 16:22:22 -0400
Message-ID: <1686169347-28987-3-git-send-email-dheitmueller@ltnglobal.com> (raw)
In-Reply-To: <1686169347-28987-1-git-send-email-dheitmueller@ltnglobal.com>

Add an "afd" variable which shows the current AFD side data for
the given frame.  This is to assist in debugging as it allows us
to burn the current AFD right into the video.

Example usage:

./ffmpeg -y -i afd.ts -vf drawtext=fontfile=/Library/Fonts/Verdana.ttf:text="AFD=%{afd}":fontsize=32:x=10:y=50:fontcolor=blue burnin.ts

Signed-off-by: Devin Heitmueller <dheitmueller@ltnglobal.com>
---
 doc/filters.texi          |  5 +++++
 libavfilter/vf_drawtext.c | 19 +++++++++++++++++++
 2 files changed, 24 insertions(+)

diff --git a/doc/filters.texi b/doc/filters.texi
index a46357b..9179c20 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -12601,6 +12601,11 @@ The following functions are available:
 
 @table @command
 
+@item afd
+The Active Format Descriptor value of the current frame (as specified in the
+frame's side data).  This can be useful for debugging aspect ratio issues.
+See standards ETSI TS 101 154 or SMPTE ST2016-1 for more details on its meaning.
+
 @item expr, e
 The expression evaluation result.
 
diff --git a/libavfilter/vf_drawtext.c b/libavfilter/vf_drawtext.c
index 71ab851..32accfb 100644
--- a/libavfilter/vf_drawtext.c
+++ b/libavfilter/vf_drawtext.c
@@ -221,6 +221,7 @@ typedef struct DrawTextContext {
     int text_shaping;               ///< 1 to shape the text before drawing it
 #endif
     AVDictionary *metadata;
+    AVFrame *frame;
 } DrawTextContext;
 
 #define OFFSET(x) offsetof(DrawTextContext, x)
@@ -1056,6 +1057,22 @@ static int func_metadata(AVFilterContext *ctx, AVBPrint *bp,
     return 0;
 }
 
+static int func_afd(AVFilterContext *ctx, AVBPrint *bp,
+                    char *fct, unsigned argc, char **argv, int tag)
+{
+    DrawTextContext *s = ctx->priv;
+    AVFrameSideData *side_data;
+
+    side_data = av_frame_get_side_data(s->frame, AV_FRAME_DATA_AFD);
+    if (side_data) {
+        av_bprintf(bp, "0x%02x", side_data->data[0]);
+    } else {
+        av_bprintf(bp, "none");
+    }
+
+    return 0;
+}
+
 static int func_strftime(AVFilterContext *ctx, AVBPrint *bp,
                          char *fct, unsigned argc, char **argv, int tag)
 {
@@ -1234,6 +1251,7 @@ static const struct drawtext_function {
     { "frame_num", 0, 0, 0,   func_frame_num },
     { "n",         0, 0, 0,   func_frame_num },
     { "metadata",  1, 2, 0,   func_metadata },
+    { "afd",       0, 0, 0,   func_afd },
 };
 
 static int eval_function(AVFilterContext *ctx, AVBPrint *bp, char *fct,
@@ -1680,6 +1698,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
     s->var_values[VAR_DURATION] = frame->duration * av_q2d(inlink->time_base);
 
     s->metadata = frame->metadata;
+    s->frame = frame;
 
     for (int i = 0; i < loop; i++) {
         if (header) {
-- 
1.8.3.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".

  parent reply	other threads:[~2023-06-07 19:25 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-07 20:22 [FFmpeg-devel] [PATCH 0/7] Misc AFD improvements and support for Bar Data Devin Heitmueller
2023-06-07 20:22 ` [FFmpeg-devel] [PATCH 1/7] Preserve AFD side data when going from AVPacket to AVFrame Devin Heitmueller
2023-06-07 20:22 ` Devin Heitmueller [this message]
2023-06-07 20:22 ` [FFmpeg-devel] [PATCH 3/7] avcodec/avframe: add new side data types for Bar Data Devin Heitmueller
2023-06-07 20:22 ` [FFmpeg-devel] [PATCH 4/7] libavfilter: Add filter to insert AFD/bar data Devin Heitmueller
2023-06-07 20:22 ` [FFmpeg-devel] [PATCH 5/7] Provide a side data description for newly introduced bar data Devin Heitmueller
2023-06-07 20:22 ` [FFmpeg-devel] [PATCH 6/7] avcodec/v210enc: Pass through " Devin Heitmueller
2023-06-07 20:22 ` [FFmpeg-devel] [PATCH 7/7] avdevice/decklink_enc: Add support for output of bar data as VANC Devin Heitmueller
2023-06-15 14:54 ` [FFmpeg-devel] [PATCH 0/7] Misc AFD improvements and support for Bar Data Devin Heitmueller
2023-06-15 14:57   ` Paul B Mahol
2023-06-15 15:21     ` Devin Heitmueller
2023-06-22 11:52       ` Devin Heitmueller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1686169347-28987-3-git-send-email-dheitmueller@ltnglobal.com \
    --to=devin.heitmueller@ltnglobal.com \
    --cc=dheitmueller@ltnglobal.com \
    --cc=ffmpeg-devel@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git