summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Mitchell <kevmitch@gmail.com>2014-04-13 07:08:58 -0700
committerwm4 <wm4@nowhere>2014-04-13 18:03:01 +0200
commit9eb061a72b66702d394584fac371358050f7ad18 (patch)
tree56493ad73652a68e06cabc35211fcbcf1f2a8c64
parentf09134b76d9dfda8001de82fa33bc1aab967cae7 (diff)
downloadmpv-9eb061a72b66702d394584fac371358050f7ad18.tar.bz2
mpv-9eb061a72b66702d394584fac371358050f7ad18.tar.xz
command: add vf-metadata property
This is a read-only property that uses VFCTRL_GET_METADATA to retrieve mp_tags metadata from a filter specified by label Signed-off-by: wm4 <wm4@nowhere>
-rw-r--r--DOCS/man/en/input.rst13
-rw-r--r--player/command.c38
2 files changed, 49 insertions, 2 deletions
diff --git a/DOCS/man/en/input.rst b/DOCS/man/en/input.rst
index f6a0f04833..d6e3affcad 100644
--- a/DOCS/man/en/input.rst
+++ b/DOCS/man/en/input.rst
@@ -731,7 +731,7 @@ Property list
(key and string value for each metdata entry)
``chapter-metadata``
- Metadata of current chapter. Works similar to ``metadata`` property. IT
+ Metadata of current chapter. Works similar to ``metadata`` property. It
also allows the same access methods (using sub-properties).
Per-chapter metadata is very rare. Usually, only the chapter name
@@ -740,6 +740,17 @@ Property list
For accessing other information, like chapter start, see the
``chapter-list`` property.
+``vf-metadata/<filter-label>``
+ Metadata added by video filters. Accessed by the filter label,
+ which if not explicitly specified using the ``@filter-label:`` syntax,
+ will be ``<filter-name>NN``.
+
+ Works similar to ``metadata`` property. It allows the same access
+ methods (using sub-properties).
+
+ An example of these kind of metadata are the cropping parameters
+ added by ``--vf=lavfi=cropdetect``.
+
``pause`` (RW)
Pause status. This is usually ``yes`` or ``no``. See ``--pause``.
diff --git a/player/command.c b/player/command.c
index 8891fdd3f3..cc4cc0892a 100644
--- a/player/command.c
+++ b/player/command.c
@@ -617,7 +617,6 @@ static int mp_property_edition(m_option_t *prop, int action, void *arg,
return M_PROPERTY_NOT_IMPLEMENTED;
}
-
static int get_edition_entry(int item, int action, void *arg, void *ctx)
{
struct MPContext *mpctx = ctx;
@@ -933,6 +932,42 @@ static int mp_property_chapter_metadata(m_option_t *prop, int action, void *arg,
return tag_property(prop, action, arg, demuxer->chapters[chapter].metadata);
}
+static int mp_property_vf_metadata(m_option_t *prop, int action, void *arg,
+ MPContext *mpctx)
+{
+ if (!(mpctx->d_video && mpctx->d_video->vfilter))
+ return M_PROPERTY_UNAVAILABLE;
+ struct vf_chain *vf = mpctx->d_video->vfilter;
+
+ switch(action) {
+ case M_PROPERTY_GET_TYPE:
+ case M_PROPERTY_GET:
+ case M_PROPERTY_GET_NODE:
+ return M_PROPERTY_NOT_IMPLEMENTED;
+ case M_PROPERTY_KEY_ACTION: {
+ struct m_property_action_arg *ka = arg;
+ bstr key;
+ char *rem;
+ m_property_split_path(ka->key, &key, &rem);
+ struct mp_tags vf_metadata;
+ if (vf_control_by_label(vf, VFCTRL_GET_METADATA, &vf_metadata, key)
+ == CONTROL_UNKNOWN)
+ return M_PROPERTY_UNKNOWN;
+
+ if (strlen(rem)) {
+ struct m_property_action_arg next_ka = *ka;
+ next_ka.key = rem;
+ return tag_property(prop, M_PROPERTY_KEY_ACTION, &next_ka,
+ &vf_metadata);
+ } else {
+ return tag_property(prop, ka->action, ka->arg, &vf_metadata);
+ }
+ return M_PROPERTY_OK;
+ }
+ }
+ return M_PROPERTY_UNAVAILABLE;
+}
+
static int mp_property_pause(m_option_t *prop, int action, void *arg,
void *ctx)
{
@@ -2206,6 +2241,7 @@ static const m_option_t mp_properties[] = {
{ "angle", mp_property_angle, &m_option_type_dummy },
M_PROPERTY("metadata", mp_property_metadata),
M_PROPERTY("chapter-metadata", mp_property_chapter_metadata),
+ M_PROPERTY( "vf-metadata", mp_property_vf_metadata),
M_OPTION_PROPERTY_CUSTOM("pause", mp_property_pause),
{ "cache", mp_property_cache, CONF_TYPE_INT },
{ "cache-size", mp_property_cache_size, CONF_TYPE_INT, M_OPT_MIN, 0 },