]> git.sesse.net Git - ffmpeg/blobdiff - cmdutils.c
Fix H.264 picture reordering, 2nd try.
[ffmpeg] / cmdutils.c
index bca7034fa7a8a468093be73a818b6d2927baa544..3a84a1482628459e01b41762f699910ab895184c 100644 (file)
@@ -213,6 +213,41 @@ int opt_default(const char *opt, const char *arg){
     return 0;
 }
 
+int opt_loglevel(const char *opt, const char *arg)
+{
+    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);
+        exit(1);
+    }
+    av_log_set_level(level);
+    return 0;
+}
+
 void set_context_opts(void *ctx, void *opts_ctx, int flags)
 {
     int i;