summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilip Sequeira <phsequei@gmail.com>2013-08-13 21:25:50 -0400
committerwm4 <wm4@nowhere>2013-08-17 21:32:52 +0200
commitb018c7d936879dc2ea1bd49b78157a70f9353430 (patch)
tree53221ab06169baa10c007cb46f1c7ee64cb90f5e
parent8cebec62621cb6e9ed03aab65f5b011393ac588d (diff)
downloadmpv-b018c7d936879dc2ea1bd49b78157a70f9353430.tar.bz2
mpv-b018c7d936879dc2ea1bd49b78157a70f9353430.tar.xz
command: more intuitive chapter seek behavior
If close to chapter start, skipping back goes to previous chapter (no change). If more than <threshold> seconds in, skipping back will now go to the beginning of the current chapter instead. The threshold is set by the new option --chapter-seek-threshold and defaults to 5 seconds. A negative value disables the new functionality.
-rw-r--r--DOCS/man/en/mpv.rst4
-rw-r--r--DOCS/man/en/options.rst7
-rw-r--r--mpvcore/command.c23
-rw-r--r--mpvcore/options.c3
-rw-r--r--mpvcore/options.h1
5 files changed, 36 insertions, 2 deletions
diff --git a/DOCS/man/en/mpv.rst b/DOCS/man/en/mpv.rst
index af905539f0..8931a129f2 100644
--- a/DOCS/man/en/mpv.rst
+++ b/DOCS/man/en/mpv.rst
@@ -176,7 +176,9 @@ P
Show progression bar, elapsed time and total duration on the OSD.
! and @
- Seek to the beginning of the previous/next chapter.
+ Seek to the beginning of the previous/next chapter. In most cases,
+ "previous" will actually go to the beginning of the current chapter; see
+ ``--chapter-seek-threshold``.
D (``--vo=vdpau``, ``--vf=yadif`` only)
Activate/deactivate deinterlacer.
diff --git a/DOCS/man/en/options.rst b/DOCS/man/en/options.rst
index 5a9aa5fc12..21e4a7991a 100644
--- a/DOCS/man/en/options.rst
+++ b/DOCS/man/en/options.rst
@@ -459,6 +459,13 @@
the start of the next one then keep playing video normally over the
chapter change instead of doing a seek.
+``--chapter-seek-threshold=<seconds>``
+ Distance in seconds from the beginning of a chapter within which a backward
+ chapter seek will go to the previous chapter (default: 5.0). Past this
+ threshold, a backward chapter seek will go to the beginning of the current
+ chapter instead. A negative value means always go back to the previous
+ chapter.
+
``--colormatrix=<colorspace>``
Controls the YUV to RGB color space conversion when playing video. There
are various standards. Normally, BT.601 should be used for SD video, and
diff --git a/mpvcore/command.c b/mpvcore/command.c
index b04c05c9e6..b7aa9dfe6a 100644
--- a/mpvcore/command.c
+++ b/mpvcore/command.c
@@ -390,9 +390,30 @@ static int mp_property_chapter(m_option_t *prop, int action, void *arg,
*(char **) arg = chapter_name;
return M_PROPERTY_OK;
}
+ case M_PROPERTY_SWITCH:
case M_PROPERTY_SET: ;
- int step_all = *(int *)arg - chapter;
+ int step_all;
+ if (action == M_PROPERTY_SWITCH) {
+ struct m_property_switch_arg *sarg = arg;
+ step_all = ROUND(sarg->inc);
+ // Check threshold for relative backward seeks
+ if (mpctx->opts->chapter_seek_threshold >= 0 && step_all < 0) {
+ if (chapter < -1)
+ return M_PROPERTY_UNAVAILABLE;
+ double current_chapter_start =
+ chapter_start_time(mpctx, chapter);
+ // If we are far enough into a chapter, seek back to the
+ // beginning of current chapter instead of previous one
+ if (current_chapter_start >= 0 &&
+ get_current_time(mpctx) - current_chapter_start >
+ mpctx->opts->chapter_seek_threshold)
+ step_all++;
+ }
+ } else // Absolute set
+ step_all = *(int *)arg - chapter;
chapter += step_all;
+ if (chapter < -1)
+ chapter = -1;
if (chapter >= get_chapter_count(mpctx) && step_all > 0) {
mpctx->stop_play = PT_NEXT_ENTRY;
} else {
diff --git a/mpvcore/options.c b/mpvcore/options.c
index e0d138a545..4a3c067404 100644
--- a/mpvcore/options.c
+++ b/mpvcore/options.c
@@ -661,6 +661,8 @@ const m_option_t mp_opts[] = {
OPT_FLAG("ordered-chapters", ordered_chapters, 0),
OPT_INTRANGE("chapter-merge-threshold", chapter_merge_threshold, 0, 0, 10000),
+ OPT_DOUBLE("chapter-seek-threshold", chapter_seek_threshold, 0),
+
// a-v sync stuff:
OPT_FLAG("correct-pts", correct_pts, 0),
OPT_CHOICE("pts-association-mode", user_pts_assoc_mode, 0,
@@ -772,6 +774,7 @@ const struct MPOpts mp_default_opts = {
.loop_times = -1,
.ordered_chapters = 1,
.chapter_merge_threshold = 100,
+ .chapter_seek_threshold = 5.0,
.load_config = 1,
.position_resume = 1,
.stream_cache_min_percent = 20.0,
diff --git a/mpvcore/options.h b/mpvcore/options.h
index ff2b5954ff..9309cc1a85 100644
--- a/mpvcore/options.h
+++ b/mpvcore/options.h
@@ -83,6 +83,7 @@ typedef struct MPOpts {
int loop_times;
int ordered_chapters;
int chapter_merge_threshold;
+ double chapter_seek_threshold;
int quiet;
int load_config;
int use_filedir_conf;