summaryrefslogtreecommitdiff
path: root/ffmpeg.c
diff options
context:
space:
mode:
authorRamiro Polla <ramiro@lisha.ufsc.br>2009-06-16 23:02:53 +0000
committerStefano Sabatini <stefano.sabatini-lala@poste.it>2009-06-16 23:02:53 +0000
commit77ddf4df944cf14e6f5cc3d407d383e7e4dc0de0 (patch)
tree88d3a54dd5733ff27b28f2a246fa65641d92a05b /ffmpeg.c
parentd2d5e067359873c3eebaa8e6fbedb5d2ddaab2e3 (diff)
Make ffmpeg able to set the loglevel option using strings
corresponding to the various log levels. Patch by Ramiro. Originally committed as revision 19208 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'ffmpeg.c')
-rw-r--r--ffmpeg.c32
1 files changed, 30 insertions, 2 deletions
diff --git a/ffmpeg.c b/ffmpeg.c
index a1cb5097b4..cb11dc1e31 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -2356,7 +2356,35 @@ static int opt_me_threshold(const char *opt, const char *arg)
static int opt_loglevel(const char *opt, const char *arg)
{
- int level = parse_number_or_die(opt, arg, OPT_INT, INT_MIN, INT_MAX);
+ const struct { const char *name; int level; } const log_levels[] = {
+ { "quiet" , AV_LOG_QUIET },
+ { "panic" , AV_LOG_PANIC },
+ { "fatal" , AV_LOG_FATAL },
+ { "error" , AV_LOG_ERROR },
+ { "warning", AV_LOG_WARNING },
+ { "info" , AV_LOG_INFO },
+ { "verbose", AV_LOG_VERBOSE },
+ { "debug" , AV_LOG_DEBUG },
+ };
+ char *tail;
+ int level;
+ int i;
+
+ for (i = 0; i < FF_ARRAY_ELEMS(log_levels); i++) {
+ if (!strcmp(log_levels[i].name, arg)) {
+ av_log_set_level(log_levels[i].level);
+ return 0;
+ }
+ }
+
+ level = strtol(arg, &tail, 10);
+ if (*tail) {
+ fprintf(stderr, "Invalid loglevel \"%s\". "
+ "Possible levels are numbers or:\n", arg);
+ for (i = 0; i < FF_ARRAY_ELEMS(log_levels); i++)
+ fprintf(stderr, "\"%s\"\n", log_levels[i].name);
+ av_exit(1);
+ }
av_log_set_level(level);
return 0;
}
@@ -3800,7 +3828,7 @@ static const OptionDef options[] = {
{ "loop_input", OPT_BOOL | OPT_EXPERT, {(void*)&loop_input}, "loop (current only works with images)" },
{ "loop_output", HAS_ARG | OPT_INT | OPT_EXPERT, {(void*)&loop_output}, "number of times to loop output in formats that support looping (0 loops forever)", "" },
{ "v", HAS_ARG | OPT_FUNC2, {(void*)opt_verbose}, "set ffmpeg verbosity level", "number" },
- { "loglevel", HAS_ARG | OPT_FUNC2, {(void*)opt_loglevel}, "set libav* logging level", "number" },
+ { "loglevel", HAS_ARG | OPT_FUNC2, {(void*)opt_loglevel}, "set libav* logging level", "logging level number or string" },
{ "target", HAS_ARG, {(void*)opt_target}, "specify target file type (\"vcd\", \"svcd\", \"dvd\", \"dv\", \"dv50\", \"pal-vcd\", \"ntsc-svcd\", ...)", "type" },
{ "threads", OPT_FUNC2 | HAS_ARG | OPT_EXPERT, {(void*)opt_thread_count}, "thread count", "count" },
{ "vsync", HAS_ARG | OPT_INT | OPT_EXPERT, {(void*)&video_sync_method}, "video sync method", "" },