summaryrefslogtreecommitdiffstats
path: root/player/command.c
diff options
context:
space:
mode:
authorAndrey Morozov <morozov.andrey.vmk@gmail.com>2014-08-19 23:19:38 +0400
committerwm4 <wm4@nowhere>2014-08-19 21:47:14 +0200
commit1cb15316b09fa9091d25f06603570475f5b18921 (patch)
treee69e12996f8d8fd9e22efdf1560e422366a8a74d /player/command.c
parent960f0ccfa1b714f0e129336b68739f3cbe72b2fc (diff)
downloadmpv-1cb15316b09fa9091d25f06603570475f5b18921.tar.bz2
mpv-1cb15316b09fa9091d25f06603570475f5b18921.tar.xz
command: add estimated-frame-count & estimated-frame-number properties
Signed-off-by: wm4 <wm4@nowhere>
Diffstat (limited to 'player/command.c')
-rw-r--r--player/command.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/player/command.c b/player/command.c
index 6dcfc8597f..761aba8fd6 100644
--- a/player/command.c
+++ b/player/command.c
@@ -2011,6 +2011,42 @@ static int mp_property_border(void *ctx, struct m_property *prop,
&mpctx->opts->vo.border, mpctx);
}
+static int get_frame_count(struct MPContext *mpctx)
+{
+ struct demuxer *demuxer = mpctx->demuxer;
+ if (!demuxer)
+ return 0;
+ if (!mpctx->d_video)
+ return 0;
+
+ int frame_count = (int)(get_time_length(mpctx) * mpctx->d_video->fps);
+
+ return frame_count;
+}
+
+static int mp_property_frame_number(void *ctx, struct m_property *prop,
+ int action, void *arg)
+{
+ MPContext *mpctx = ctx;
+ if (!mpctx->d_video)
+ return M_PROPERTY_UNAVAILABLE;
+
+ int frame_number = ROUND(get_current_pos_ratio(mpctx, false) *
+ (double)get_frame_count(mpctx));
+ return m_property_int_ro(action, arg, frame_number);
+}
+
+static int mp_property_frame_count(void *ctx, struct m_property *prop,
+ int action, void *arg)
+{
+ MPContext *mpctx = ctx;
+
+ if (!mpctx->d_video)
+ return M_PROPERTY_UNAVAILABLE;
+
+ return m_property_int_ro(action, arg, get_frame_count(mpctx));
+}
+
static int mp_property_framedrop(void *ctx, struct m_property *prop,
int action, void *arg)
{
@@ -2790,6 +2826,9 @@ static const struct m_property mp_properties[] = {
{"program", mp_property_program},
{"hwdec", mp_property_hwdec},
+ {"estimated-frame-count", mp_property_frame_count},
+ {"estimated-frame-number", mp_property_frame_number},
+
{"osd-width", mp_property_osd_w},
{"osd-height", mp_property_osd_h},
{"osd-par", mp_property_osd_par},