[FFmpeg-cvslog] avfilter/f_sendcmd: export width and height too

Paul B Mahol git at videolan.org
Mon Mar 7 17:59:52 EET 2022


ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Mon Mar  7 16:57:30 2022 +0100| [13a153d801011c4ec82b90af1351e10dcf1754e1] | committer: Paul B Mahol

avfilter/f_sendcmd: export width and height too

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=13a153d801011c4ec82b90af1351e10dcf1754e1
---

 doc/filters.texi        | 6 ++++++
 libavfilter/f_sendcmd.c | 6 ++++++
 2 files changed, 12 insertions(+)

diff --git a/doc/filters.texi b/doc/filters.texi
index 8427b88d3d..26c5b4db48 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -27041,6 +27041,12 @@ The end time in seconds of the current command interval.
 
 @item TI
 The interpolated time of the current command interval, TI = (T - TS) / (TE - TS).
+
+ at item W
+The video frame width.
+
+ at item H
+The video frame height.
 @end table
 
 @end table
diff --git a/libavfilter/f_sendcmd.c b/libavfilter/f_sendcmd.c
index 7261a05aae..04bfc84a06 100644
--- a/libavfilter/f_sendcmd.c
+++ b/libavfilter/f_sendcmd.c
@@ -46,6 +46,8 @@ static const char *const var_names[] = {
     "TS",    /* interval start time in seconds */
     "TE",    /* interval end time in seconds */
     "TI",    /* interval interpolated value: TI = (T - TS) / (TE - TS) */
+    "W",     /* width for video frames */
+    "H",     /* height for video frames */
     NULL
 };
 
@@ -57,6 +59,8 @@ enum var_name {
     VAR_TS,
     VAR_TE,
     VAR_TI,
+    VAR_W,
+    VAR_H,
     VAR_VARS_NB
 };
 
@@ -531,6 +535,8 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *ref)
                         var_values[VAR_TS]  = start;
                         var_values[VAR_TE]  = end;
                         var_values[VAR_TI]  = (current - start) / (end - start);
+                        var_values[VAR_W]   = ref->width;
+                        var_values[VAR_H]   = ref->height;
 
                         if ((ret = av_expr_parse_and_eval(&res, cmd->arg, var_names, var_values,
                                                           NULL, NULL, NULL, NULL, NULL, 0, NULL)) < 0) {



More information about the ffmpeg-cvslog mailing list