FFmpeg
f_metadata.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016 Paul B Mahol
3  *
4  * This file is part of FFmpeg.
5  *
6  * FFmpeg is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * FFmpeg is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with FFmpeg; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 /**
22  * @file
23  * filter for manipulating frame metadata
24  */
25 
26 #include <float.h>
27 
28 #include "libavutil/avassert.h"
29 #include "libavutil/avstring.h"
30 #include "libavutil/eval.h"
31 #include "libavutil/internal.h"
32 #include "libavutil/opt.h"
33 #include "libavutil/timestamp.h"
34 #include "libavformat/avio.h"
35 #include "avfilter.h"
36 #include "audio.h"
37 #include "formats.h"
38 #include "internal.h"
39 #include "video.h"
40 
48 };
49 
59 };
60 
61 static const char *const var_names[] = {
62  "VALUE1",
63  "VALUE2",
64  "FRAMEVAL",
65  "USERVAL",
66  NULL
67 };
68 
69 enum var_name {
75 };
76 
77 typedef struct MetadataContext {
78  const AVClass *class;
79 
80  int mode;
81  char *key;
82  char *value;
83  int function;
84 
85  char *expr_str;
88 
90  char *file_str;
91 
93  const char *value1, const char *value2);
94  void (*print)(AVFilterContext *ctx, const char *msg, ...) av_printf_format(2, 3);
95 
96  int direct; // reduces buffering when printing to user-supplied URL
98 
99 #define OFFSET(x) offsetof(MetadataContext, x)
100 #define DEFINE_OPTIONS(filt_name, FLAGS) \
101 static const AVOption filt_name##_options[] = { \
102  { "mode", "set a mode of operation", OFFSET(mode), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, METADATA_NB-1, FLAGS, "mode" }, \
103  { "select", "select frame", 0, AV_OPT_TYPE_CONST, {.i64 = METADATA_SELECT }, 0, 0, FLAGS, "mode" }, \
104  { "add", "add new metadata", 0, AV_OPT_TYPE_CONST, {.i64 = METADATA_ADD }, 0, 0, FLAGS, "mode" }, \
105  { "modify", "modify metadata", 0, AV_OPT_TYPE_CONST, {.i64 = METADATA_MODIFY }, 0, 0, FLAGS, "mode" }, \
106  { "delete", "delete metadata", 0, AV_OPT_TYPE_CONST, {.i64 = METADATA_DELETE }, 0, 0, FLAGS, "mode" }, \
107  { "print", "print metadata", 0, AV_OPT_TYPE_CONST, {.i64 = METADATA_PRINT }, 0, 0, FLAGS, "mode" }, \
108  { "key", "set metadata key", OFFSET(key), AV_OPT_TYPE_STRING, {.str = NULL }, 0, 0, FLAGS }, \
109  { "value", "set metadata value", OFFSET(value), AV_OPT_TYPE_STRING, {.str = NULL }, 0, 0, FLAGS }, \
110  { "function", "function for comparing values", OFFSET(function), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, METADATAF_NB-1, FLAGS, "function" }, \
111  { "same_str", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = METADATAF_SAME_STR }, 0, 3, FLAGS, "function" }, \
112  { "starts_with", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = METADATAF_STARTS_WITH }, 0, 0, FLAGS, "function" }, \
113  { "less", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = METADATAF_LESS }, 0, 3, FLAGS, "function" }, \
114  { "equal", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = METADATAF_EQUAL }, 0, 3, FLAGS, "function" }, \
115  { "greater", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = METADATAF_GREATER }, 0, 3, FLAGS, "function" }, \
116  { "expr", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = METADATAF_EXPR }, 0, 3, FLAGS, "function" }, \
117  { "ends_with", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = METADATAF_ENDS_WITH }, 0, 0, FLAGS, "function" }, \
118  { "expr", "set expression for expr function", OFFSET(expr_str), AV_OPT_TYPE_STRING, {.str = NULL }, 0, 0, FLAGS }, \
119  { "file", "set file where to print metadata information", OFFSET(file_str), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, FLAGS }, \
120  { "direct", "reduce buffering when printing to user-set file or pipe", OFFSET(direct), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, FLAGS }, \
121  { NULL } \
122 }
123 
124 static int same_str(MetadataContext *s, const char *value1, const char *value2)
125 {
126  return !strcmp(value1, value2);
127 }
128 
129 static int starts_with(MetadataContext *s, const char *value1, const char *value2)
130 {
131  return !strncmp(value1, value2, strlen(value2));
132 }
133 
134 static int ends_with(MetadataContext *s, const char *value1, const char *value2)
135 {
136  const int len1 = strlen(value1);
137  const int len2 = strlen(value2);
138 
139  return !strncmp(value1 + FFMAX(len1 - len2, 0), value2, len2);
140 }
141 
142 static int equal(MetadataContext *s, const char *value1, const char *value2)
143 {
144  float f1, f2;
145 
146  if (sscanf(value1, "%f", &f1) + sscanf(value2, "%f", &f2) != 2)
147  return 0;
148 
149  return fabsf(f1 - f2) < FLT_EPSILON;
150 }
151 
152 static int less(MetadataContext *s, const char *value1, const char *value2)
153 {
154  float f1, f2;
155 
156  if (sscanf(value1, "%f", &f1) + sscanf(value2, "%f", &f2) != 2)
157  return 0;
158 
159  return (f1 - f2) < FLT_EPSILON;
160 }
161 
162 static int greater(MetadataContext *s, const char *value1, const char *value2)
163 {
164  float f1, f2;
165 
166  if (sscanf(value1, "%f", &f1) + sscanf(value2, "%f", &f2) != 2)
167  return 0;
168 
169  return (f2 - f1) < FLT_EPSILON;
170 }
171 
172 static int parse_expr(MetadataContext *s, const char *value1, const char *value2)
173 {
174  double f1, f2;
175 
176  if (sscanf(value1, "%lf", &f1) + sscanf(value2, "%lf", &f2) != 2)
177  return 0;
178 
179  s->var_values[VAR_VALUE1] = s->var_values[VAR_FRAMEVAL] = f1;
180  s->var_values[VAR_VALUE2] = s->var_values[VAR_USERVAL] = f2;
181 
182  return av_expr_eval(s->expr, s->var_values, NULL);
183 }
184 
185 static void print_log(AVFilterContext *ctx, const char *msg, ...)
186 {
187  va_list argument_list;
188 
189  va_start(argument_list, msg);
190  if (msg)
191  av_vlog(ctx, AV_LOG_INFO, msg, argument_list);
192  va_end(argument_list);
193 }
194 
195 static void print_file(AVFilterContext *ctx, const char *msg, ...)
196 {
197  MetadataContext *s = ctx->priv;
198  va_list argument_list;
199 
200  va_start(argument_list, msg);
201  if (msg) {
202  char buf[128];
203  vsnprintf(buf, sizeof(buf), msg, argument_list);
204  avio_write(s->avio_context, buf, av_strnlen(buf, sizeof(buf)));
205  }
206  va_end(argument_list);
207 }
208 
210 {
211  MetadataContext *s = ctx->priv;
212  int ret;
213 
214  if (!s->key && s->mode != METADATA_PRINT && s->mode != METADATA_DELETE) {
215  av_log(ctx, AV_LOG_WARNING, "Metadata key must be set\n");
216  return AVERROR(EINVAL);
217  }
218 
219  if ((s->mode == METADATA_MODIFY ||
220  s->mode == METADATA_ADD) && !s->value) {
221  av_log(ctx, AV_LOG_WARNING, "Missing metadata value\n");
222  return AVERROR(EINVAL);
223  }
224 
225  switch (s->function) {
226  case METADATAF_SAME_STR:
227  s->compare = same_str;
228  break;
230  s->compare = starts_with;
231  break;
232  case METADATAF_ENDS_WITH:
233  s->compare = ends_with;
234  break;
235  case METADATAF_LESS:
236  s->compare = less;
237  break;
238  case METADATAF_EQUAL:
239  s->compare = equal;
240  break;
241  case METADATAF_GREATER:
242  s->compare = greater;
243  break;
244  case METADATAF_EXPR:
245  s->compare = parse_expr;
246  break;
247  default:
248  av_assert0(0);
249  };
250 
251  if (s->function == METADATAF_EXPR) {
252  if (!s->expr_str) {
253  av_log(ctx, AV_LOG_WARNING, "expr option not set\n");
254  return AVERROR(EINVAL);
255  }
256  if ((ret = av_expr_parse(&s->expr, s->expr_str,
257  var_names, NULL, NULL, NULL, NULL, 0, ctx)) < 0) {
258  av_log(ctx, AV_LOG_ERROR, "Error while parsing expression '%s'\n", s->expr_str);
259  return ret;
260  }
261  }
262 
263  if (s->mode == METADATA_PRINT && s->file_str) {
264  s->print = print_file;
265  } else {
266  s->print = print_log;
267  }
268 
269  s->avio_context = NULL;
270  if (s->file_str) {
271  if (!strcmp("-", s->file_str)) {
272  ret = avio_open(&s->avio_context, "pipe:1", AVIO_FLAG_WRITE);
273  } else {
274  ret = avio_open(&s->avio_context, s->file_str, AVIO_FLAG_WRITE);
275  }
276 
277  if (ret < 0) {
278  char buf[128];
279  av_strerror(ret, buf, sizeof(buf));
280  av_log(ctx, AV_LOG_ERROR, "Could not open %s: %s\n",
281  s->file_str, buf);
282  return ret;
283  }
284 
285  if (s->direct)
286  s->avio_context->direct = AVIO_FLAG_DIRECT;
287  }
288 
289  return 0;
290 }
291 
293 {
294  MetadataContext *s = ctx->priv;
295 
296  av_expr_free(s->expr);
297  s->expr = NULL;
298  if (s->avio_context) {
299  avio_closep(&s->avio_context);
300  }
301 }
302 
304 {
305  AVFilterContext *ctx = inlink->dst;
306  AVFilterLink *outlink = ctx->outputs[0];
307  MetadataContext *s = ctx->priv;
308  AVDictionary **metadata = &frame->metadata;
310 
311  e = av_dict_get(*metadata, !s->key ? "" : s->key, NULL,
312  !s->key ? AV_DICT_IGNORE_SUFFIX: 0);
313 
314  switch (s->mode) {
315  case METADATA_SELECT:
316  if (!s->value && e && e->value) {
317  return ff_filter_frame(outlink, frame);
318  } else if (s->value && e && e->value &&
319  s->compare(s, e->value, s->value)) {
320  return ff_filter_frame(outlink, frame);
321  }
322  break;
323  case METADATA_ADD:
324  if (e && e->value) {
325  ;
326  } else {
327  av_dict_set(metadata, s->key, s->value, 0);
328  }
329  return ff_filter_frame(outlink, frame);
330  case METADATA_MODIFY:
331  if (e && e->value) {
332  av_dict_set(metadata, s->key, s->value, 0);
333  }
334  return ff_filter_frame(outlink, frame);
335  case METADATA_PRINT:
336  if (!s->key && e) {
337  s->print(ctx, "frame:%-4"PRId64" pts:%-7s pts_time:%s\n",
338  inlink->frame_count_out, av_ts2str(frame->pts), av_ts2timestr(frame->pts, &inlink->time_base));
339  s->print(ctx, "%s=%s\n", e->key, e->value);
340  while ((e = av_dict_get(*metadata, "", e, AV_DICT_IGNORE_SUFFIX)) != NULL) {
341  s->print(ctx, "%s=%s\n", e->key, e->value);
342  }
343  } else if (e && e->value && (!s->value || (e->value && s->compare(s, e->value, s->value)))) {
344  s->print(ctx, "frame:%-4"PRId64" pts:%-7s pts_time:%s\n",
345  inlink->frame_count_out, av_ts2str(frame->pts), av_ts2timestr(frame->pts, &inlink->time_base));
346  s->print(ctx, "%s=%s\n", s->key, e->value);
347  }
348  return ff_filter_frame(outlink, frame);
349  case METADATA_DELETE:
350  if (!s->key) {
351  av_dict_free(metadata);
352  } else if (e && e->value && (!s->value || s->compare(s, e->value, s->value))) {
353  av_dict_set(metadata, s->key, NULL, 0);
354  }
355  return ff_filter_frame(outlink, frame);
356  default:
357  av_assert0(0);
358  };
359 
361 
362  return 0;
363 }
364 
365 #if CONFIG_AMETADATA_FILTER
366 
368 AVFILTER_DEFINE_CLASS(ametadata);
369 
370 static const AVFilterPad ainputs[] = {
371  {
372  .name = "default",
373  .type = AVMEDIA_TYPE_AUDIO,
374  .filter_frame = filter_frame,
375  },
376 };
377 
378 static const AVFilterPad aoutputs[] = {
379  {
380  .name = "default",
381  .type = AVMEDIA_TYPE_AUDIO,
382  },
383 };
384 
385 const AVFilter ff_af_ametadata = {
386  .name = "ametadata",
387  .description = NULL_IF_CONFIG_SMALL("Manipulate audio frame metadata."),
388  .priv_size = sizeof(MetadataContext),
389  .priv_class = &ametadata_class,
390  .init = init,
391  .uninit = uninit,
392  FILTER_INPUTS(ainputs),
393  FILTER_OUTPUTS(aoutputs),
396 };
397 #endif /* CONFIG_AMETADATA_FILTER */
398 
399 #if CONFIG_METADATA_FILTER
400 
402 AVFILTER_DEFINE_CLASS(metadata);
403 
404 static const AVFilterPad inputs[] = {
405  {
406  .name = "default",
407  .type = AVMEDIA_TYPE_VIDEO,
408  .filter_frame = filter_frame,
409  },
410 };
411 
412 static const AVFilterPad outputs[] = {
413  {
414  .name = "default",
415  .type = AVMEDIA_TYPE_VIDEO,
416  },
417 };
418 
419 const AVFilter ff_vf_metadata = {
420  .name = "metadata",
421  .description = NULL_IF_CONFIG_SMALL("Manipulate video frame metadata."),
422  .priv_size = sizeof(MetadataContext),
423  .priv_class = &metadata_class,
424  .init = init,
425  .uninit = uninit,
430 };
431 #endif /* CONFIG_METADATA_FILTER */
av_vlog
void av_vlog(void *avcl, int level, const char *fmt, va_list vl)
Send the specified message to the log if the level is less than or equal to the current av_log_level.
Definition: log.c:424
DEFINE_OPTIONS
#define DEFINE_OPTIONS(filt_name, FLAGS)
Definition: f_metadata.c:100
AV_LOG_WARNING
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:186
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: f_metadata.c:292
AVERROR
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
opt.h
AV_OPT_FLAG_VIDEO_PARAM
#define AV_OPT_FLAG_VIDEO_PARAM
Definition: opt.h:280
ff_filter_frame
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:1018
METADATAF_GREATER
@ METADATAF_GREATER
Definition: f_metadata.c:55
METADATAF_SAME_STR
@ METADATAF_SAME_STR
Definition: f_metadata.c:51
inlink
The exact code depends on how similar the blocks are and how related they are to the and needs to apply these operations to the correct inlink or outlink if there are several Macros are available to factor that when no extra processing is inlink
Definition: filter_design.txt:212
av_frame_free
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:109
starts_with
static int starts_with(MetadataContext *s, const char *value1, const char *value2)
Definition: f_metadata.c:129
VAR_VALUE1
@ VAR_VALUE1
Definition: f_metadata.c:70
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:317
AV_DICT_IGNORE_SUFFIX
#define AV_DICT_IGNORE_SUFFIX
Return first entry in a dictionary whose first part corresponds to the search key,...
Definition: dict.h:68
METADATAF_STARTS_WITH
@ METADATAF_STARTS_WITH
Definition: f_metadata.c:52
float.h
METADATA_SELECT
@ METADATA_SELECT
Definition: f_metadata.c:42
AVDictionary
Definition: dict.c:30
FFMAX
#define FFMAX(a, b)
Definition: macros.h:47
AVFilter::name
const char * name
Filter name.
Definition: avfilter.h:169
video.h
AV_OPT_FLAG_FILTERING_PARAM
#define AV_OPT_FLAG_FILTERING_PARAM
a generic parameter which can be set by the user for filtering
Definition: opt.h:293
same_str
static int same_str(MetadataContext *s, const char *value1, const char *value2)
Definition: f_metadata.c:124
formats.h
av_expr_parse
int av_expr_parse(AVExpr **expr, const char *s, const char *const *const_names, const char *const *func1_names, double(*const *funcs1)(void *, double), const char *const *func2_names, double(*const *funcs2)(void *, double, double), int log_offset, void *log_ctx)
Parse an expression.
Definition: eval.c:685
init
static av_cold int init(AVFilterContext *ctx)
Definition: f_metadata.c:209
av_strerror
int av_strerror(int errnum, char *errbuf, size_t errbuf_size)
Put a description of the AVERROR code errnum in errbuf.
Definition: error.c:105
MetadataMode
MetadataMode
Definition: f_metadata.c:41
METADATAF_LESS
@ METADATAF_LESS
Definition: f_metadata.c:53
fabsf
static __device__ float fabsf(float a)
Definition: cuda_runtime.h:181
av_expr_free
void av_expr_free(AVExpr *e)
Free a parsed expression previously created with av_expr_parse().
Definition: eval.c:336
AVFilterPad
A filter pad used for either input or output.
Definition: internal.h:50
avassert.h
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:180
MetadataContext::expr
AVExpr * expr
Definition: f_metadata.c:86
av_cold
#define av_cold
Definition: attributes.h:90
av_dict_get
AVDictionaryEntry * av_dict_get(const AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
Definition: dict.c:40
METADATAF_ENDS_WITH
@ METADATAF_ENDS_WITH
Definition: f_metadata.c:57
s
#define s(width, name)
Definition: cbs_vp9.c:257
AVDictionaryEntry::key
char * key
Definition: dict.h:80
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
av_assert0
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:37
outputs
static const AVFilterPad outputs[]
Definition: af_acontrast.c:172
AVIO_FLAG_WRITE
#define AVIO_FLAG_WRITE
write-only
Definition: avio.h:622
var_name
var_name
Definition: noise_bsf.c:47
ff_af_ametadata
const AVFilter ff_af_ametadata
ctx
AVFormatContext * ctx
Definition: movenc.c:48
av_expr_eval
double av_expr_eval(AVExpr *e, const double *const_values, void *opaque)
Evaluate a previously parsed expression.
Definition: eval.c:766
AVExpr
Definition: eval.c:157
METADATAF_EQUAL
@ METADATAF_EQUAL
Definition: f_metadata.c:54
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: internal.h:191
MetadataFunction
MetadataFunction
Definition: f_metadata.c:50
AV_OPT_FLAG_AUDIO_PARAM
#define AV_OPT_FLAG_AUDIO_PARAM
Definition: opt.h:279
METADATA_ADD
@ METADATA_ADD
Definition: f_metadata.c:43
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:66
VAR_VARS_NB
@ VAR_VARS_NB
Definition: f_metadata.c:74
NULL
#define NULL
Definition: coverity.c:32
var_names
static const char *const var_names[]
Definition: f_metadata.c:61
av_strnlen
size_t static size_t av_strnlen(const char *s, size_t len)
Get the count of continuous non zero chars starting from the beginning.
Definition: avstring.h:141
greater
static int greater(MetadataContext *s, const char *value1, const char *value2)
Definition: f_metadata.c:162
av_printf_format
#define av_printf_format(fmtpos, attrpos)
Definition: attributes.h:161
MetadataContext::print
void(* print)(AVFilterContext *ctx, const char *msg,...) av_printf_format(2
Definition: f_metadata.c:94
inputs
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several inputs
Definition: filter_design.txt:243
METADATA_DELETE
@ METADATA_DELETE
Definition: f_metadata.c:45
MetadataContext::key
char * key
Definition: f_metadata.c:81
eval.h
AVIOContext
Bytestream IO Context.
Definition: avio.h:161
parse_expr
static int parse_expr(MetadataContext *s, const char *value1, const char *value2)
Definition: f_metadata.c:172
av_ts2timestr
#define av_ts2timestr(ts, tb)
Convenience macro, the return value should be used only directly in function arguments but never stan...
Definition: timestamp.h:76
NULL_IF_CONFIG_SMALL
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:117
VAR_USERVAL
@ VAR_USERVAL
Definition: f_metadata.c:73
MetadataContext::direct
void(*) in direct)
Definition: f_metadata.c:94
avio.h
METADATAF_EXPR
@ METADATAF_EXPR
Definition: f_metadata.c:56
avio_write
void avio_write(AVIOContext *s, const unsigned char *buf, int size)
Definition: aviobuf.c:232
ends_with
static int ends_with(MetadataContext *s, const char *value1, const char *value2)
Definition: f_metadata.c:134
av_dict_free
void av_dict_free(AVDictionary **pm)
Free all the memory allocated for an AVDictionary struct and all keys and values.
Definition: dict.c:203
AV_LOG_INFO
#define AV_LOG_INFO
Standard information.
Definition: log.h:191
internal.h
AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC
#define AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC
Some filters support a generic "enable" expression option that can be used to enable or disable a fil...
Definition: avfilter.h:146
AVFILTER_DEFINE_CLASS
#define AVFILTER_DEFINE_CLASS(fname)
Definition: internal.h:326
avio_closep
int avio_closep(AVIOContext **s)
Close the resource accessed by the AVIOContext *s, free it and set the pointer pointing to it to NULL...
Definition: aviobuf.c:1285
less
static int less(MetadataContext *s, const char *value1, const char *value2)
Definition: f_metadata.c:152
ff_vf_metadata
const AVFilter ff_vf_metadata
print_file
static void print_file(AVFilterContext *ctx, const char *msg,...)
Definition: f_metadata.c:195
internal.h
MetadataContext::compare
int(* compare)(struct MetadataContext *s, const char *value1, const char *value2)
Definition: f_metadata.c:92
MetadataContext::value
char * value
Definition: f_metadata.c:82
vsnprintf
#define vsnprintf
Definition: snprintf.h:36
AVFilterPad::name
const char * name
Pad name.
Definition: internal.h:56
METADATA_NB
@ METADATA_NB
Definition: f_metadata.c:47
MetadataContext::mode
int mode
Definition: f_metadata.c:80
AVFilter
Filter definition.
Definition: avfilter.h:165
ret
ret
Definition: filter_design.txt:187
frame
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
Definition: filter_design.txt:264
VAR_VALUE2
@ VAR_VALUE2
Definition: f_metadata.c:71
VAR_FRAMEVAL
@ VAR_FRAMEVAL
Definition: f_metadata.c:72
MetadataContext::file_str
char * file_str
Definition: f_metadata.c:90
avfilter.h
AVFILTER_FLAG_METADATA_ONLY
#define AVFILTER_FLAG_METADATA_ONLY
The filter is a "metadata" filter - it does not modify the frame data in any way.
Definition: avfilter.h:137
METADATA_MODIFY
@ METADATA_MODIFY
Definition: f_metadata.c:44
avio_open
int avio_open(AVIOContext **s, const char *url, int flags)
Create and initialize a AVIOContext for accessing the resource indicated by url.
Definition: aviobuf.c:1220
AVFilterContext
An instance of a filter.
Definition: avfilter.h:402
AVIO_FLAG_DIRECT
#define AVIO_FLAG_DIRECT
Use direct mode.
Definition: avio.h:648
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
audio.h
METADATA_PRINT
@ METADATA_PRINT
Definition: f_metadata.c:46
METADATAF_NB
@ METADATAF_NB
Definition: f_metadata.c:58
AVDictionaryEntry
Definition: dict.h:79
equal
static int equal(MetadataContext *s, const char *value1, const char *value2)
Definition: f_metadata.c:142
print_log
static void print_log(AVFilterContext *ctx, const char *msg,...)
Definition: f_metadata.c:185
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: internal.h:192
MetadataContext
Definition: f_metadata.c:77
av_dict_set
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
Definition: dict.c:70
MetadataContext::var_values
double var_values[VAR_VARS_NB]
Definition: f_metadata.c:87
timestamp.h
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:28
filter_frame
static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
Definition: f_metadata.c:303
av_ts2str
#define av_ts2str(ts)
Convenience macro, the return value should be used only directly in function arguments but never stan...
Definition: timestamp.h:54
AVDictionaryEntry::value
char * value
Definition: dict.h:81
avstring.h
int
int
Definition: ffmpeg_filter.c:153
MetadataContext::avio_context
AVIOContext * avio_context
Definition: f_metadata.c:89
MetadataContext::expr_str
char * expr_str
Definition: f_metadata.c:85