int (*compare)(struct MetadataContext *s,
const char *value1, const char *value2);
void (*print)(AVFilterContext *ctx, const char *msg, ...) av_printf_format(2, 3);
+
+ int direct; // reduces buffering when printing to user-supplied URL
} MetadataContext;
#define OFFSET(x) offsetof(MetadataContext, x)
{ "ends_with", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = METADATAF_ENDS_WITH }, 0, 0, FLAGS, "function" }, \
{ "expr", "set expression for expr function", OFFSET(expr_str), AV_OPT_TYPE_STRING, {.str = NULL }, 0, 0, FLAGS }, \
{ "file", "set file where to print metadata information", OFFSET(file_str), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, FLAGS }, \
+ { "direct", "reduce buffering when printing to user-set file or pipe", OFFSET(direct), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, FLAGS }, \
{ NULL } \
}
s->file_str, buf);
return ret;
}
+
+ if (s->direct)
+ s->avio_context->direct = AVIO_FLAG_DIRECT;
}
return 0;
AVDictionary **metadata = &frame->metadata;
AVDictionaryEntry *e;
- if (!*metadata)
+ if (!*metadata && s->mode != METADATA_ADD)
return ff_filter_frame(outlink, frame);
e = av_dict_get(*metadata, !s->key ? "" : s->key, NULL,
av_dict_set(metadata, s->key, s->value, 0);
}
return ff_filter_frame(outlink, frame);
- break;
case METADATA_MODIFY:
if (e && e->value) {
av_dict_set(metadata, s->key, s->value, 0);
}
return ff_filter_frame(outlink, frame);
- break;
case METADATA_PRINT:
if (!s->key && e) {
s->print(ctx, "frame:%-4"PRId64" pts:%-7s pts_time:%s\n",
s->print(ctx, "%s=%s\n", s->key, e->value);
}
return ff_filter_frame(outlink, frame);
- break;
case METADATA_DELETE:
if (!s->key) {
av_dict_free(metadata);
av_dict_set(metadata, s->key, NULL, 0);
}
return ff_filter_frame(outlink, frame);
- break;
default:
av_assert0(0);
};
{ NULL }
};
-AVFilter ff_af_ametadata = {
+const AVFilter ff_af_ametadata = {
.name = "ametadata",
.description = NULL_IF_CONFIG_SMALL("Manipulate audio frame metadata."),
.priv_size = sizeof(MetadataContext),
{ NULL }
};
-AVFilter ff_vf_metadata = {
+const AVFilter ff_vf_metadata = {
.name = "metadata",
.description = NULL_IF_CONFIG_SMALL("Manipulate video frame metadata."),
.priv_size = sizeof(MetadataContext),