summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--DOCS/man/en/options.rst27
-rw-r--r--mpvcore/screenshot.c12
2 files changed, 17 insertions, 22 deletions
diff --git a/DOCS/man/en/options.rst b/DOCS/man/en/options.rst
index 8ed9ba8066..1c07403ea7 100644
--- a/DOCS/man/en/options.rst
+++ b/DOCS/man/en/options.rst
@@ -1880,27 +1880,26 @@
numbers would be more intuitive, but are not easily implementable
because container formats usually use time stamps for identifying
frames.)
- ``%w{X}``
- Specify the current playback time using the format string ``X``. The
- nested time format string is contained within ``{`` and ``}``.
- ``%p`` is like ``%w{%H:%M:%S}``, and ``%P`` is like ``%w{%H:%M:%S.%T}``.
+ ``%wX``
+ Specify the current playback time using the format string ``X``.
+ ``%p`` is like ``%wH:%wM:%wS``, and ``%P`` is like ``%wH:%wM:%wS.%wT``.
Valid format specifiers:
- ``%H``
+ ``%wH``
hour (padded with 0 to two digits)
- ``%h``
+ ``%wh``
hour (not padded)
- ``%M``
+ ``%wM``
minutes (00-59)
- ``%m``
- total minutes (includes hours, unlike ``%M``)
- ``%S``
+ ``%wm``
+ total minutes (includes hours, unlike ``%wM``)
+ ``%wS``
seconds (00-59)
- ``%s``
+ ``%ws``
total seconds (includes hours and minutes)
- ``%f``
- like ``%s``, but as float
- ``%T``
+ ``%wf``
+ like ``%ws``, but as float
+ ``%wT``
milliseconds (000-999)
``%tX``
diff --git a/mpvcore/screenshot.c b/mpvcore/screenshot.c
index 0afa88182b..161bfac1e5 100644
--- a/mpvcore/screenshot.c
+++ b/mpvcore/screenshot.c
@@ -187,20 +187,16 @@ static char *create_fname(struct MPContext *mpctx, char *template,
break;
}
case 'w': {
- if (template[0] != '{')
+ char tfmt = *template;
+ if (!tfmt)
goto error_exit;
template++;
- char *end = strchr(template, '}');
- if (!end)
- goto error_exit;
- char *fmt = talloc_strndup(res, template, end - template);
- char *s = mp_format_time_fmt(fmt, get_current_time(mpctx));
+ char fmtstr[] = {'%', tfmt, '\0'};
+ char *s = mp_format_time_fmt(fmtstr, get_current_time(mpctx));
if (!s)
goto error_exit;
append_filename(&res, s);
talloc_free(s);
- talloc_free(fmt);
- template = end + 1;
break;
}
case 't': {