summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-11-22 18:54:22 +0100
committerwm4 <wm4@nowhere>2015-11-22 18:54:22 +0100
commit01a2af6c7c98c04e7cc834ea019f31f8c698d125 (patch)
tree1dedd5cb26e0697ea165b2f614102786ac318bef
parentb38094ad919b082e59438ddb8c1c590cd9af3e02 (diff)
downloadmpv-01a2af6c7c98c04e7cc834ea019f31f8c698d125.tar.bz2
mpv-01a2af6c7c98c04e7cc834ea019f31f8c698d125.tar.xz
command: export some per-video-frame information
Utterly useless, but requested. Fixes #2444.
-rw-r--r--DOCS/man/input.rst13
-rw-r--r--player/command.c25
2 files changed, 38 insertions, 0 deletions
diff --git a/DOCS/man/input.rst b/DOCS/man/input.rst
index b581c5a8ad..367d9f185b 100644
--- a/DOCS/man/input.rst
+++ b/DOCS/man/input.rst
@@ -1441,6 +1441,19 @@ Property list
Has the same sub-properties as ``video-params``.
+``video-frame-info``
+ Approximate information of the current frame. Note that if any of these
+ are used on OSD, the information might be off by a few frames due to OSD
+ redrawing and frame display being somewhat disconnected, and you might
+ have to pause and force a redraw.
+
+ Sub-properties:
+
+ ``video-frame-info/picture-type``
+ ``video-frame-info/interlaced``
+ ``video-frame-info/tff``
+ ``video-frame-info/repeat``
+
``fps``
Container FPS. This can easily contain bogus values. For videos that use
modern container formats or video codecs, this will often be incorrect.
diff --git a/player/command.c b/player/command.c
index 7d520d78ac..c6fb5d6fdd 100644
--- a/player/command.c
+++ b/player/command.c
@@ -2528,6 +2528,30 @@ static int mp_property_vd_imgparams(void *ctx, struct m_property *prop,
return M_PROPERTY_UNAVAILABLE;
}
+static int mp_property_video_frame_info(void *ctx, struct m_property *prop,
+ int action, void *arg)
+{
+ MPContext *mpctx = ctx;
+ struct mp_image *f =
+ mpctx->video_out ? vo_get_current_frame(mpctx->video_out) : NULL;
+ if (!f)
+ return M_PROPERTY_UNAVAILABLE;
+
+ const char *pict_types[] = {0, "I", "P", "B"};
+ const char *pict_type = f->pict_type >= 1 && f->pict_type <= 3
+ ? pict_types[f->pict_type] : NULL;
+
+ struct m_sub_property props[] = {
+ {"picture-type", SUB_PROP_STR(pict_type), .unavailable = !pict_type},
+ {"interlaced", SUB_PROP_FLAG(!!(f->fields & MP_IMGFIELD_INTERLACED))},
+ {"tff", SUB_PROP_FLAG(!!(f->fields & MP_IMGFIELD_TOP_FIRST))},
+ {"repeat", SUB_PROP_FLAG(!!(f->fields & MP_IMGFIELD_REPEAT_FIRST))},
+ {0}
+ };
+
+ return m_property_read_sub(props, action, arg);
+}
+
static int mp_property_window_scale(void *ctx, struct m_property *prop,
int action, void *arg)
{
@@ -3506,6 +3530,7 @@ static const struct m_property mp_properties[] = {
{"video-out-params", mp_property_vo_imgparams},
{"video-params", mp_property_vd_imgparams},
{"video-format", mp_property_video_format},
+ {"video-frame-info", mp_property_video_frame_info},
{"video-codec", mp_property_video_codec},
M_PROPERTY_ALIAS("dwidth", "video-out-params/dw"),
M_PROPERTY_ALIAS("dheight", "video-out-params/dh"),