summaryrefslogtreecommitdiffstats
path: root/sub/dec_sub.c
diff options
context:
space:
mode:
authorStefano Pigozzi <stefano.pigozzi@gmail.com>2019-09-21 20:11:18 +0200
committerStefano Pigozzi <stefano.pigozzi@gmail.com>2019-09-22 09:19:45 +0200
commitcb32ad68f31de784a13ca5a2847143c4c37738ce (patch)
tree9d9d5497c9a58d54ae5ef7cb226e81dd5fb14cb7 /sub/dec_sub.c
parent0f938b197a79c09b01a9dcf39f02e95d9d7fb4a2 (diff)
downloadmpv-cb32ad68f31de784a13ca5a2847143c4c37738ce.tar.bz2
mpv-cb32ad68f31de784a13ca5a2847143c4c37738ce.tar.xz
command: add sub-start & sub-end properties
These properties contain the current subtitle's start and end times. Can be useful to cut sample audio through the scripting interface.
Diffstat (limited to 'sub/dec_sub.c')
-rw-r--r--sub/dec_sub.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/sub/dec_sub.c b/sub/dec_sub.c
index a31cad77bc..27cab201d9 100644
--- a/sub/dec_sub.c
+++ b/sub/dec_sub.c
@@ -372,6 +372,23 @@ char *sub_get_text(struct dec_sub *sub, double pts)
return text;
}
+struct sd_times sub_get_times(struct dec_sub *sub, double pts)
+{
+ pthread_mutex_lock(&sub->lock);
+ struct sd_times res = { .start = MP_NOPTS_VALUE, .end = MP_NOPTS_VALUE };
+
+ pts = pts_to_subtitle(sub, pts);
+
+ sub->last_vo_pts = pts;
+ update_segment(sub);
+
+ if (sub->sd->driver->get_times)
+ res = sub->sd->driver->get_times(sub->sd, pts);
+
+ pthread_mutex_unlock(&sub->lock);
+ return res;
+}
+
void sub_reset(struct dec_sub *sub)
{
pthread_mutex_lock(&sub->lock);