[MPlayer-dev-eng] [PATCH] Add support for arbitrary metadata in the lavf muxer.
Alex Converse
alex.converse at gmail.com
Tue Sep 20 23:02:57 CEST 2011
---
libmpdemux/muxer_lavf.c | 37 +++++++++++++++++++++++++++++++++++++
1 files changed, 37 insertions(+), 0 deletions(-)
diff --git a/libmpdemux/muxer_lavf.c b/libmpdemux/muxer_lavf.c
index 5b5ab61..ce8cc3b 100644
--- a/libmpdemux/muxer_lavf.c
+++ b/libmpdemux/muxer_lavf.c
@@ -66,6 +66,7 @@ static int mux_packet_size= 0;
static float mux_preload= 0.5;
static float mux_max_delay= 0.7;
static char *mux_avopt = NULL;
+static char *mux_avmetadata = NULL;
const m_option_t lavfopts_conf[] = {
{"format", &(conf_format), CONF_TYPE_STRING, 0, 0, 0, NULL},
@@ -74,6 +75,7 @@ const m_option_t lavfopts_conf[] = {
{"preload", &mux_preload, CONF_TYPE_FLOAT, CONF_RANGE, 0, INT_MAX, NULL},
{"delay", &mux_max_delay, CONF_TYPE_FLOAT, CONF_RANGE, 0, INT_MAX, NULL},
{"o", &mux_avopt, CONF_TYPE_STRING, 0, 0, 0, NULL},
+ {"metadata", &mux_avmetadata, CONF_TYPE_STRING, 0, 0, 0, NULL},
{NULL, NULL, 0, 0, 0, 0, NULL}
};
@@ -313,6 +315,32 @@ static void list_formats(void) {
mp_msg(MSGT_DEMUX, MSGL_INFO, "%15s : %s\n", fmt->name, fmt->long_name);
}
+static int parse_avmetadata(AVDictionary **v, const char *metadata_string) {
+ char *start, *str;
+ start = str = strdup(metadata_string);
+
+ while (str && *str) {
+ char *next_opt, *arg;
+
+ next_opt = strchr(str, ',');
+ if (next_opt)
+ *next_opt++ = 0;
+
+ arg = strchr(str, '=');
+ if (arg)
+ *arg++ = 0;
+
+ if (av_dict_set(v, str, arg, 0)) {
+ free(start);
+ return -1;
+ }
+ str = next_opt;
+ }
+
+ free(start);
+ return 0;
+}
+
int muxer_init_muxer_lavf(muxer_t *muxer)
{
muxer_priv_t *priv;
@@ -377,6 +405,15 @@ int muxer_init_muxer_lavf(muxer_t *muxer)
}
}
+ if (mux_avmetadata) {
+ if (parse_avmetadata(&priv->oc->metadata, mux_avmetadata) < 0) {
+ mp_msg(MSGT_MUXER,MSGL_ERR,
+ "Your metadata /%s/ looks like gibberish to me pal.\n",
+ mux_avmetadata);
+ goto fail;
+ }
+ }
+
priv->oc->pb = avio_alloc_context(priv->buffer, BIO_BUFFER_SIZE, 1, muxer, NULL, mp_write, mp_seek);
if ((muxer->stream->flags & MP_STREAM_SEEK) != MP_STREAM_SEEK)
priv->oc->pb->is_streamed = 1;
--
1.7.3.1
More information about the MPlayer-dev-eng
mailing list