summaryrefslogtreecommitdiffstats
path: root/stream
diff options
context:
space:
mode:
authorMohammad AlSaleh <CE.Mohammad.AlSaleh@gmail.com>2020-09-09 17:48:45 +0300
committerwm4 <1387750+wm4@users.noreply.github.com>2020-09-17 10:34:57 +0200
commitb959a2229176a98ba83c196ad32cad538520c3aa (patch)
tree5bdff0892b3d3971eb73b44ec8b67584ae2b682a /stream
parent49f5c9b4820b082b8d25b753ff010562939a754f (diff)
downloadmpv-b959a2229176a98ba83c196ad32cad538520c3aa.tar.bz2
mpv-b959a2229176a98ba83c196ad32cad538520c3aa.tar.xz
stream_slice: interpret `end` as offset if it starts with '+'
Example: slice://1g-2g@file.ts (1 to 2) slice://1g-+2g@file.ts (1 to 3) Signed-off-by: Mohammad AlSaleh <CE.Mohammad.AlSaleh@gmail.com>
Diffstat (limited to 'stream')
-rw-r--r--stream/stream_slice.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/stream/stream_slice.c b/stream/stream_slice.c
index 7889c8d059..d7d0a6bf05 100644
--- a/stream/stream_slice.c
+++ b/stream/stream_slice.c
@@ -116,11 +116,15 @@ static int parse_slice_range(stream_t *stream)
if (m_option_parse(stream->log, &opt, bstr0("slice_start"), start, &p->slice_start) < 0)
return STREAM_ERROR;
+ bool max_end_is_offset = bstr_startswith0(end, "+");
if (has_end) {
if (m_option_parse(stream->log, &opt, bstr0("slice_max_end"), end, &p->slice_max_end) < 0)
return STREAM_ERROR;
}
+ if (max_end_is_offset)
+ p->slice_max_end += p->slice_start;
+
if (p->slice_max_end && p->slice_max_end < p->slice_start) {
MP_ERR(stream, "The byte range end (%"PRId64") can't be smaller than the start (%"PRId64"): '%s'\n",
p->slice_max_end,