2016-02-06 12:19:45 +02:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2016 Paul B Mahol
|
|
|
|
*
|
|
|
|
* This file is part of FFmpeg.
|
|
|
|
*
|
|
|
|
* FFmpeg is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* FFmpeg is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with FFmpeg; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @file
|
|
|
|
* filter for manipulating frame metadata
|
|
|
|
*/
|
|
|
|
|
2022-02-23 14:56:49 +02:00
|
|
|
#include "config_components.h"
|
|
|
|
|
2016-02-11 14:35:19 +02:00
|
|
|
#include <float.h>
|
|
|
|
|
2016-02-06 12:19:45 +02:00
|
|
|
#include "libavutil/avassert.h"
|
|
|
|
#include "libavutil/avstring.h"
|
|
|
|
#include "libavutil/eval.h"
|
|
|
|
#include "libavutil/internal.h"
|
|
|
|
#include "libavutil/opt.h"
|
2016-05-09 11:35:37 +02:00
|
|
|
#include "libavutil/timestamp.h"
|
2016-07-08 14:53:15 +02:00
|
|
|
#include "libavformat/avio.h"
|
2016-02-06 12:19:45 +02:00
|
|
|
#include "avfilter.h"
|
|
|
|
#include "audio.h"
|
2024-08-06 08:50:21 +02:00
|
|
|
#include "filters.h"
|
2016-02-06 12:19:45 +02:00
|
|
|
#include "video.h"
|
|
|
|
|
|
|
|
enum MetadataMode {
|
|
|
|
METADATA_SELECT,
|
|
|
|
METADATA_ADD,
|
|
|
|
METADATA_MODIFY,
|
|
|
|
METADATA_DELETE,
|
|
|
|
METADATA_PRINT,
|
|
|
|
METADATA_NB
|
|
|
|
};
|
|
|
|
|
|
|
|
enum MetadataFunction {
|
2016-02-11 16:39:57 +02:00
|
|
|
METADATAF_SAME_STR,
|
2016-02-11 14:35:20 +02:00
|
|
|
METADATAF_STARTS_WITH,
|
2016-02-06 12:19:45 +02:00
|
|
|
METADATAF_LESS,
|
|
|
|
METADATAF_EQUAL,
|
|
|
|
METADATAF_GREATER,
|
|
|
|
METADATAF_EXPR,
|
2019-09-30 12:13:46 +02:00
|
|
|
METADATAF_ENDS_WITH,
|
2016-02-06 12:19:45 +02:00
|
|
|
METADATAF_NB
|
|
|
|
};
|
|
|
|
|
|
|
|
static const char *const var_names[] = {
|
|
|
|
"VALUE1",
|
|
|
|
"VALUE2",
|
2021-05-14 12:20:30 +02:00
|
|
|
"FRAMEVAL",
|
|
|
|
"USERVAL",
|
2016-02-06 12:19:45 +02:00
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
enum var_name {
|
|
|
|
VAR_VALUE1,
|
|
|
|
VAR_VALUE2,
|
2021-05-14 12:20:30 +02:00
|
|
|
VAR_FRAMEVAL,
|
|
|
|
VAR_USERVAL,
|
2016-02-06 12:19:45 +02:00
|
|
|
VAR_VARS_NB
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct MetadataContext {
|
|
|
|
const AVClass *class;
|
|
|
|
|
|
|
|
int mode;
|
|
|
|
char *key;
|
|
|
|
char *value;
|
|
|
|
int function;
|
|
|
|
|
|
|
|
char *expr_str;
|
|
|
|
AVExpr *expr;
|
|
|
|
double var_values[VAR_VARS_NB];
|
|
|
|
|
2016-07-08 14:53:15 +02:00
|
|
|
AVIOContext* avio_context;
|
2016-02-11 14:35:21 +02:00
|
|
|
char *file_str;
|
|
|
|
|
2016-02-06 12:19:45 +02:00
|
|
|
int (*compare)(struct MetadataContext *s,
|
2016-02-11 16:39:57 +02:00
|
|
|
const char *value1, const char *value2);
|
2016-02-11 14:35:21 +02:00
|
|
|
void (*print)(AVFilterContext *ctx, const char *msg, ...) av_printf_format(2, 3);
|
2020-01-07 14:00:34 +02:00
|
|
|
|
|
|
|
int direct; // reduces buffering when printing to user-supplied URL
|
2016-02-06 12:19:45 +02:00
|
|
|
} MetadataContext;
|
|
|
|
|
|
|
|
#define OFFSET(x) offsetof(MetadataContext, x)
|
2016-02-11 14:35:22 +02:00
|
|
|
#define DEFINE_OPTIONS(filt_name, FLAGS) \
|
|
|
|
static const AVOption filt_name##_options[] = { \
|
2024-02-11 16:41:05 +02:00
|
|
|
{ "mode", "set a mode of operation", OFFSET(mode), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, METADATA_NB-1, FLAGS, .unit = "mode" }, \
|
|
|
|
{ "select", "select frame", 0, AV_OPT_TYPE_CONST, {.i64 = METADATA_SELECT }, 0, 0, FLAGS, .unit = "mode" }, \
|
|
|
|
{ "add", "add new metadata", 0, AV_OPT_TYPE_CONST, {.i64 = METADATA_ADD }, 0, 0, FLAGS, .unit = "mode" }, \
|
|
|
|
{ "modify", "modify metadata", 0, AV_OPT_TYPE_CONST, {.i64 = METADATA_MODIFY }, 0, 0, FLAGS, .unit = "mode" }, \
|
|
|
|
{ "delete", "delete metadata", 0, AV_OPT_TYPE_CONST, {.i64 = METADATA_DELETE }, 0, 0, FLAGS, .unit = "mode" }, \
|
|
|
|
{ "print", "print metadata", 0, AV_OPT_TYPE_CONST, {.i64 = METADATA_PRINT }, 0, 0, FLAGS, .unit = "mode" }, \
|
2016-02-06 12:19:45 +02:00
|
|
|
{ "key", "set metadata key", OFFSET(key), AV_OPT_TYPE_STRING, {.str = NULL }, 0, 0, FLAGS }, \
|
|
|
|
{ "value", "set metadata value", OFFSET(value), AV_OPT_TYPE_STRING, {.str = NULL }, 0, 0, FLAGS }, \
|
2024-02-11 16:41:05 +02:00
|
|
|
{ "function", "function for comparing values", OFFSET(function), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, METADATAF_NB-1, FLAGS, .unit = "function" }, \
|
|
|
|
{ "same_str", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = METADATAF_SAME_STR }, 0, 3, FLAGS, .unit = "function" }, \
|
|
|
|
{ "starts_with", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = METADATAF_STARTS_WITH }, 0, 0, FLAGS, .unit = "function" }, \
|
|
|
|
{ "less", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = METADATAF_LESS }, 0, 3, FLAGS, .unit = "function" }, \
|
|
|
|
{ "equal", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = METADATAF_EQUAL }, 0, 3, FLAGS, .unit = "function" }, \
|
|
|
|
{ "greater", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = METADATAF_GREATER }, 0, 3, FLAGS, .unit = "function" }, \
|
|
|
|
{ "expr", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = METADATAF_EXPR }, 0, 3, FLAGS, .unit = "function" }, \
|
|
|
|
{ "ends_with", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = METADATAF_ENDS_WITH }, 0, 0, FLAGS, .unit = "function" }, \
|
2016-02-06 12:19:45 +02:00
|
|
|
{ "expr", "set expression for expr function", OFFSET(expr_str), AV_OPT_TYPE_STRING, {.str = NULL }, 0, 0, FLAGS }, \
|
2016-02-11 14:35:21 +02:00
|
|
|
{ "file", "set file where to print metadata information", OFFSET(file_str), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, FLAGS }, \
|
2020-01-07 14:00:34 +02:00
|
|
|
{ "direct", "reduce buffering when printing to user-set file or pipe", OFFSET(direct), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, FLAGS }, \
|
2016-02-11 14:35:22 +02:00
|
|
|
{ NULL } \
|
2016-02-06 12:19:45 +02:00
|
|
|
}
|
|
|
|
|
2016-02-11 16:39:57 +02:00
|
|
|
static int same_str(MetadataContext *s, const char *value1, const char *value2)
|
2016-02-06 12:19:45 +02:00
|
|
|
{
|
2016-02-11 16:39:57 +02:00
|
|
|
return !strcmp(value1, value2);
|
2016-02-06 12:19:45 +02:00
|
|
|
}
|
|
|
|
|
2016-02-11 16:39:57 +02:00
|
|
|
static int starts_with(MetadataContext *s, const char *value1, const char *value2)
|
2016-02-11 14:35:20 +02:00
|
|
|
{
|
|
|
|
return !strncmp(value1, value2, strlen(value2));
|
|
|
|
}
|
|
|
|
|
2019-09-30 12:13:46 +02:00
|
|
|
static int ends_with(MetadataContext *s, const char *value1, const char *value2)
|
|
|
|
{
|
|
|
|
const int len1 = strlen(value1);
|
|
|
|
const int len2 = strlen(value2);
|
|
|
|
|
|
|
|
return !strncmp(value1 + FFMAX(len1 - len2, 0), value2, len2);
|
|
|
|
}
|
|
|
|
|
2016-02-11 16:39:57 +02:00
|
|
|
static int equal(MetadataContext *s, const char *value1, const char *value2)
|
2016-02-06 12:19:45 +02:00
|
|
|
{
|
|
|
|
float f1, f2;
|
|
|
|
|
|
|
|
if (sscanf(value1, "%f", &f1) + sscanf(value2, "%f", &f2) != 2)
|
|
|
|
return 0;
|
|
|
|
|
2016-02-11 14:35:19 +02:00
|
|
|
return fabsf(f1 - f2) < FLT_EPSILON;
|
2016-02-06 12:19:45 +02:00
|
|
|
}
|
|
|
|
|
2016-02-11 16:39:57 +02:00
|
|
|
static int less(MetadataContext *s, const char *value1, const char *value2)
|
2016-02-06 12:19:45 +02:00
|
|
|
{
|
|
|
|
float f1, f2;
|
|
|
|
|
|
|
|
if (sscanf(value1, "%f", &f1) + sscanf(value2, "%f", &f2) != 2)
|
|
|
|
return 0;
|
|
|
|
|
2016-02-11 14:35:19 +02:00
|
|
|
return (f1 - f2) < FLT_EPSILON;
|
2016-02-06 12:19:45 +02:00
|
|
|
}
|
|
|
|
|
2016-02-11 16:39:57 +02:00
|
|
|
static int greater(MetadataContext *s, const char *value1, const char *value2)
|
2016-02-06 12:19:45 +02:00
|
|
|
{
|
|
|
|
float f1, f2;
|
|
|
|
|
|
|
|
if (sscanf(value1, "%f", &f1) + sscanf(value2, "%f", &f2) != 2)
|
|
|
|
return 0;
|
|
|
|
|
2016-02-11 14:35:19 +02:00
|
|
|
return (f2 - f1) < FLT_EPSILON;
|
2016-02-06 12:19:45 +02:00
|
|
|
}
|
|
|
|
|
2016-02-11 16:39:57 +02:00
|
|
|
static int parse_expr(MetadataContext *s, const char *value1, const char *value2)
|
2016-02-06 12:19:45 +02:00
|
|
|
{
|
|
|
|
double f1, f2;
|
|
|
|
|
|
|
|
if (sscanf(value1, "%lf", &f1) + sscanf(value2, "%lf", &f2) != 2)
|
|
|
|
return 0;
|
|
|
|
|
2021-05-14 12:20:30 +02:00
|
|
|
s->var_values[VAR_VALUE1] = s->var_values[VAR_FRAMEVAL] = f1;
|
|
|
|
s->var_values[VAR_VALUE2] = s->var_values[VAR_USERVAL] = f2;
|
2016-02-06 12:19:45 +02:00
|
|
|
|
|
|
|
return av_expr_eval(s->expr, s->var_values, NULL);
|
|
|
|
}
|
|
|
|
|
2016-02-11 14:35:21 +02:00
|
|
|
static void print_log(AVFilterContext *ctx, const char *msg, ...)
|
|
|
|
{
|
|
|
|
va_list argument_list;
|
|
|
|
|
|
|
|
va_start(argument_list, msg);
|
|
|
|
if (msg)
|
|
|
|
av_vlog(ctx, AV_LOG_INFO, msg, argument_list);
|
|
|
|
va_end(argument_list);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void print_file(AVFilterContext *ctx, const char *msg, ...)
|
|
|
|
{
|
|
|
|
MetadataContext *s = ctx->priv;
|
|
|
|
va_list argument_list;
|
|
|
|
|
|
|
|
va_start(argument_list, msg);
|
2016-07-08 14:53:15 +02:00
|
|
|
if (msg) {
|
|
|
|
char buf[128];
|
|
|
|
vsnprintf(buf, sizeof(buf), msg, argument_list);
|
|
|
|
avio_write(s->avio_context, buf, av_strnlen(buf, sizeof(buf)));
|
|
|
|
}
|
2016-02-11 14:35:21 +02:00
|
|
|
va_end(argument_list);
|
|
|
|
}
|
|
|
|
|
2016-02-06 12:19:45 +02:00
|
|
|
static av_cold int init(AVFilterContext *ctx)
|
|
|
|
{
|
|
|
|
MetadataContext *s = ctx->priv;
|
|
|
|
int ret;
|
|
|
|
|
2016-10-01 13:55:35 +02:00
|
|
|
if (!s->key && s->mode != METADATA_PRINT && s->mode != METADATA_DELETE) {
|
2016-02-06 12:19:45 +02:00
|
|
|
av_log(ctx, AV_LOG_WARNING, "Metadata key must be set\n");
|
|
|
|
return AVERROR(EINVAL);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((s->mode == METADATA_MODIFY ||
|
|
|
|
s->mode == METADATA_ADD) && !s->value) {
|
|
|
|
av_log(ctx, AV_LOG_WARNING, "Missing metadata value\n");
|
|
|
|
return AVERROR(EINVAL);
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (s->function) {
|
2016-02-11 16:39:57 +02:00
|
|
|
case METADATAF_SAME_STR:
|
|
|
|
s->compare = same_str;
|
2016-02-06 12:19:45 +02:00
|
|
|
break;
|
2016-02-11 14:35:20 +02:00
|
|
|
case METADATAF_STARTS_WITH:
|
|
|
|
s->compare = starts_with;
|
|
|
|
break;
|
2019-09-30 12:13:46 +02:00
|
|
|
case METADATAF_ENDS_WITH:
|
|
|
|
s->compare = ends_with;
|
|
|
|
break;
|
2016-02-06 12:19:45 +02:00
|
|
|
case METADATAF_LESS:
|
|
|
|
s->compare = less;
|
|
|
|
break;
|
|
|
|
case METADATAF_EQUAL:
|
|
|
|
s->compare = equal;
|
|
|
|
break;
|
|
|
|
case METADATAF_GREATER:
|
|
|
|
s->compare = greater;
|
|
|
|
break;
|
|
|
|
case METADATAF_EXPR:
|
|
|
|
s->compare = parse_expr;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
av_assert0(0);
|
|
|
|
};
|
|
|
|
|
|
|
|
if (s->function == METADATAF_EXPR) {
|
|
|
|
if (!s->expr_str) {
|
|
|
|
av_log(ctx, AV_LOG_WARNING, "expr option not set\n");
|
|
|
|
return AVERROR(EINVAL);
|
|
|
|
}
|
|
|
|
if ((ret = av_expr_parse(&s->expr, s->expr_str,
|
|
|
|
var_names, NULL, NULL, NULL, NULL, 0, ctx)) < 0) {
|
|
|
|
av_log(ctx, AV_LOG_ERROR, "Error while parsing expression '%s'\n", s->expr_str);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-07-08 14:53:15 +02:00
|
|
|
if (s->mode == METADATA_PRINT && s->file_str) {
|
2016-02-11 14:35:21 +02:00
|
|
|
s->print = print_file;
|
|
|
|
} else {
|
|
|
|
s->print = print_log;
|
|
|
|
}
|
|
|
|
|
2016-07-08 14:53:15 +02:00
|
|
|
s->avio_context = NULL;
|
|
|
|
if (s->file_str) {
|
|
|
|
if (!strcmp("-", s->file_str)) {
|
|
|
|
ret = avio_open(&s->avio_context, "pipe:1", AVIO_FLAG_WRITE);
|
|
|
|
} else {
|
|
|
|
ret = avio_open(&s->avio_context, s->file_str, AVIO_FLAG_WRITE);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ret < 0) {
|
|
|
|
char buf[128];
|
|
|
|
av_strerror(ret, buf, sizeof(buf));
|
|
|
|
av_log(ctx, AV_LOG_ERROR, "Could not open %s: %s\n",
|
|
|
|
s->file_str, buf);
|
|
|
|
return ret;
|
|
|
|
}
|
2020-01-07 14:00:34 +02:00
|
|
|
|
|
|
|
if (s->direct)
|
|
|
|
s->avio_context->direct = AVIO_FLAG_DIRECT;
|
2016-07-08 14:53:15 +02:00
|
|
|
}
|
|
|
|
|
2016-02-06 12:19:45 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-02-11 14:35:21 +02:00
|
|
|
static av_cold void uninit(AVFilterContext *ctx)
|
|
|
|
{
|
|
|
|
MetadataContext *s = ctx->priv;
|
|
|
|
|
2019-09-30 12:24:06 +02:00
|
|
|
av_expr_free(s->expr);
|
|
|
|
s->expr = NULL;
|
2016-07-08 14:53:15 +02:00
|
|
|
if (s->avio_context) {
|
|
|
|
avio_closep(&s->avio_context);
|
|
|
|
}
|
2016-02-11 14:35:21 +02:00
|
|
|
}
|
|
|
|
|
2016-02-06 12:19:45 +02:00
|
|
|
static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
|
|
|
|
{
|
2024-08-06 08:50:21 +02:00
|
|
|
FilterLink *inl = ff_filter_link(inlink);
|
2016-02-06 12:19:45 +02:00
|
|
|
AVFilterContext *ctx = inlink->dst;
|
|
|
|
AVFilterLink *outlink = ctx->outputs[0];
|
|
|
|
MetadataContext *s = ctx->priv;
|
2017-04-22 10:57:18 +02:00
|
|
|
AVDictionary **metadata = &frame->metadata;
|
2022-11-26 16:46:31 +02:00
|
|
|
const AVDictionaryEntry *e;
|
2016-02-06 12:19:45 +02:00
|
|
|
|
2016-10-01 14:15:27 +02:00
|
|
|
e = av_dict_get(*metadata, !s->key ? "" : s->key, NULL,
|
2016-02-06 12:19:45 +02:00
|
|
|
!s->key ? AV_DICT_IGNORE_SUFFIX: 0);
|
|
|
|
|
|
|
|
switch (s->mode) {
|
|
|
|
case METADATA_SELECT:
|
|
|
|
if (!s->value && e && e->value) {
|
|
|
|
return ff_filter_frame(outlink, frame);
|
|
|
|
} else if (s->value && e && e->value &&
|
2016-02-11 16:39:57 +02:00
|
|
|
s->compare(s, e->value, s->value)) {
|
2016-02-06 12:19:45 +02:00
|
|
|
return ff_filter_frame(outlink, frame);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case METADATA_ADD:
|
|
|
|
if (e && e->value) {
|
|
|
|
;
|
|
|
|
} else {
|
2016-10-01 14:15:27 +02:00
|
|
|
av_dict_set(metadata, s->key, s->value, 0);
|
2016-02-06 12:19:45 +02:00
|
|
|
}
|
|
|
|
return ff_filter_frame(outlink, frame);
|
|
|
|
case METADATA_MODIFY:
|
|
|
|
if (e && e->value) {
|
2016-10-01 14:15:27 +02:00
|
|
|
av_dict_set(metadata, s->key, s->value, 0);
|
2016-02-06 12:19:45 +02:00
|
|
|
}
|
|
|
|
return ff_filter_frame(outlink, frame);
|
|
|
|
case METADATA_PRINT:
|
|
|
|
if (!s->key && e) {
|
2017-09-27 14:29:21 +02:00
|
|
|
s->print(ctx, "frame:%-4"PRId64" pts:%-7s pts_time:%s\n",
|
2024-08-06 08:50:21 +02:00
|
|
|
inl->frame_count_out, av_ts2str(frame->pts), av_ts2timestr(frame->pts, &inlink->time_base));
|
2016-02-11 14:35:21 +02:00
|
|
|
s->print(ctx, "%s=%s\n", e->key, e->value);
|
2022-11-26 16:46:31 +02:00
|
|
|
while ((e = av_dict_iterate(*metadata, e)) != NULL) {
|
2016-02-11 14:35:21 +02:00
|
|
|
s->print(ctx, "%s=%s\n", e->key, e->value);
|
2016-02-06 12:19:45 +02:00
|
|
|
}
|
2016-02-11 16:39:57 +02:00
|
|
|
} else if (e && e->value && (!s->value || (e->value && s->compare(s, e->value, s->value)))) {
|
2017-09-27 14:29:21 +02:00
|
|
|
s->print(ctx, "frame:%-4"PRId64" pts:%-7s pts_time:%s\n",
|
2024-08-06 08:50:21 +02:00
|
|
|
inl->frame_count_out, av_ts2str(frame->pts), av_ts2timestr(frame->pts, &inlink->time_base));
|
2016-02-11 14:35:21 +02:00
|
|
|
s->print(ctx, "%s=%s\n", s->key, e->value);
|
2016-02-06 12:19:45 +02:00
|
|
|
}
|
|
|
|
return ff_filter_frame(outlink, frame);
|
|
|
|
case METADATA_DELETE:
|
2016-10-01 13:55:35 +02:00
|
|
|
if (!s->key) {
|
|
|
|
av_dict_free(metadata);
|
2016-10-06 23:43:03 +02:00
|
|
|
} else if (e && e->value && (!s->value || s->compare(s, e->value, s->value))) {
|
2016-10-01 14:15:27 +02:00
|
|
|
av_dict_set(metadata, s->key, NULL, 0);
|
2016-02-06 12:19:45 +02:00
|
|
|
}
|
|
|
|
return ff_filter_frame(outlink, frame);
|
|
|
|
default:
|
|
|
|
av_assert0(0);
|
|
|
|
};
|
|
|
|
|
|
|
|
av_frame_free(&frame);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#if CONFIG_AMETADATA_FILTER
|
|
|
|
|
|
|
|
DEFINE_OPTIONS(ametadata, AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM);
|
|
|
|
AVFILTER_DEFINE_CLASS(ametadata);
|
|
|
|
|
|
|
|
static const AVFilterPad ainputs[] = {
|
|
|
|
{
|
|
|
|
.name = "default",
|
|
|
|
.type = AVMEDIA_TYPE_AUDIO,
|
|
|
|
.filter_frame = filter_frame,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2021-04-19 18:33:56 +02:00
|
|
|
const AVFilter ff_af_ametadata = {
|
2016-02-06 12:19:45 +02:00
|
|
|
.name = "ametadata",
|
|
|
|
.description = NULL_IF_CONFIG_SMALL("Manipulate audio frame metadata."),
|
|
|
|
.priv_size = sizeof(MetadataContext),
|
|
|
|
.priv_class = &ametadata_class,
|
|
|
|
.init = init,
|
2016-02-11 14:35:21 +02:00
|
|
|
.uninit = uninit,
|
2021-08-12 13:05:31 +02:00
|
|
|
FILTER_INPUTS(ainputs),
|
2023-08-03 00:59:02 +02:00
|
|
|
FILTER_OUTPUTS(ff_audio_default_filterpad),
|
2021-11-22 15:39:11 +02:00
|
|
|
.flags = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC |
|
|
|
|
AVFILTER_FLAG_METADATA_ONLY,
|
2016-02-06 12:19:45 +02:00
|
|
|
};
|
|
|
|
#endif /* CONFIG_AMETADATA_FILTER */
|
|
|
|
|
|
|
|
#if CONFIG_METADATA_FILTER
|
|
|
|
|
|
|
|
DEFINE_OPTIONS(metadata, AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM);
|
|
|
|
AVFILTER_DEFINE_CLASS(metadata);
|
|
|
|
|
|
|
|
static const AVFilterPad inputs[] = {
|
|
|
|
{
|
|
|
|
.name = "default",
|
|
|
|
.type = AVMEDIA_TYPE_VIDEO,
|
|
|
|
.filter_frame = filter_frame,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2021-04-19 18:33:56 +02:00
|
|
|
const AVFilter ff_vf_metadata = {
|
2016-02-06 12:19:45 +02:00
|
|
|
.name = "metadata",
|
|
|
|
.description = NULL_IF_CONFIG_SMALL("Manipulate video frame metadata."),
|
|
|
|
.priv_size = sizeof(MetadataContext),
|
|
|
|
.priv_class = &metadata_class,
|
|
|
|
.init = init,
|
2016-02-11 14:35:21 +02:00
|
|
|
.uninit = uninit,
|
2021-08-12 13:05:31 +02:00
|
|
|
FILTER_INPUTS(inputs),
|
2023-08-03 14:37:51 +02:00
|
|
|
FILTER_OUTPUTS(ff_video_default_filterpad),
|
2021-11-22 15:39:11 +02:00
|
|
|
.flags = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC |
|
|
|
|
AVFILTER_FLAG_METADATA_ONLY,
|
2016-02-06 12:19:45 +02:00
|
|
|
};
|
|
|
|
#endif /* CONFIG_METADATA_FILTER */
|