Commit 77ddf4df authored by Ramiro Polla's avatar Ramiro Polla Committed by Stefano Sabatini

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
parent d2d5e067
......@@ -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", "" },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment