summaryrefslogtreecommitdiff
path: root/fftools/cmdutils.c
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2023-07-14 16:37:19 +0200
committerAnton Khirnov <anton@khirnov.net>2023-07-20 20:47:46 +0200
commit49ac7fc48566a5cc33c0cd1a2806251fddb52a03 (patch)
tree9fa4ddd88947e45d225984ce812989a44b0bb704 /fftools/cmdutils.c
parent9cb47c78d66c0d8abf5dbedd254d3761d5c5b06a (diff)
fftools: remove parse_time_or_die()
Replace it with calling av_parse_time() directly, which provides graceful error handling and more accurate error messages.
Diffstat (limited to 'fftools/cmdutils.c')
-rw-r--r--fftools/cmdutils.c19
1 files changed, 6 insertions, 13 deletions
diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c
index 8afa9400cc..038a5d3340 100644
--- a/fftools/cmdutils.c
+++ b/fftools/cmdutils.c
@@ -127,18 +127,6 @@ int parse_number(const char *context, const char *numstr, int type,
return AVERROR(EINVAL);
}
-int64_t parse_time_or_die(const char *context, const char *timestr,
- int is_duration)
-{
- int64_t us;
- if (av_parse_time(&us, timestr, is_duration) < 0) {
- av_log(NULL, AV_LOG_FATAL, "Invalid %s specification for %s: %s\n",
- is_duration ? "duration" : "date", context, timestr);
- exit_program(1);
- }
- return us;
-}
-
void show_help_options(const OptionDef *options, const char *msg, int req_flags,
int rej_flags, int alt_flags)
{
@@ -304,7 +292,12 @@ static int write_option(void *optctx, const OptionDef *po, const char *opt,
*(int64_t *)dst = num;
} else if (po->flags & OPT_TIME) {
- *(int64_t *)dst = parse_time_or_die(opt, arg, 1);
+ ret = av_parse_time(dst, arg, 1);
+ if (ret < 0) {
+ av_log(NULL, AV_LOG_ERROR, "Invalid duration for option %s: %s\n",
+ opt, arg);
+ return ret;
+ }
} else if (po->flags & OPT_FLOAT) {
ret = parse_number(opt, arg, OPT_FLOAT, -INFINITY, INFINITY, &num);
if (ret < 0)