screenshot: make it possible to format playback time in various ways

This commit is contained in:
wm4 2013-03-25 20:32:29 +01:00
parent 58cff195e7
commit aa43405020
2 changed files with 40 additions and 0 deletions

View File

@ -1880,6 +1880,29 @@
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}``.
Valid format specifiers:
``%H``
hour (padded with 0 to two digits)
``%h``
hour (not padded)
``%M``
minutes (00-59)
``%m``
total minutes (includes hours, unlike ``%M``)
``%S``
seconds (00-59)
``%s``
total seconds (includes hours and minutes)
``%f``
like ``%s``, but as float
``%T``
milliseconds (000-999)
``%tX``
Specify the current local date/time using the format ``X``. This format
specifier uses the UNIX ``strftime()`` function internally, and inserts

View File

@ -186,6 +186,23 @@ static char *create_fname(struct MPContext *mpctx, char *template,
talloc_free(t);
break;
}
case 'w': {
if (template[0] != '{')
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));
if (!s)
goto error_exit;
append_filename(&res, s);
talloc_free(s);
talloc_free(fmt);
template = end + 1;
break;
}
case 't': {
char tfmt = *template;
if (!tfmt)