ffmpeg # 利用loglevel控制打印日志的信息

cmdutil.c中:

int opt_loglevel(void *optctx, const char *opt, const char *arg)
{
    const struct { const char *name; int level; } 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   },
        { "trace"  , AV_LOG_TRACE   },
    };

...
}

对应的宏的详细说明:

/**
 * @addtogroup lavu_log
 *
 * @{
 *
 * @defgroup lavu_log_constants Logging Constants
 *
 * @{
 */

/**
 * Print no output.
 */
#define AV_LOG_QUIET    -8

/**
 * Something went really wrong and we will crash now.
 */
#define AV_LOG_PANIC     0

/**
 * Something went wrong and recovery is not possible.
 * For example, no header was found for a format which depends
 * on headers or an illegal combination of parameters is used.
 */
#define AV_LOG_FATAL     8

/**
 * Something went wrong and cannot losslessly be recovered.
 * However, not all future data is affected.
 */
#define AV_LOG_ERROR    16

/**
 * Something somehow does not look correct. This may or may not
 * lead to problems. An example would be the use of '-vstrict -2'.
 */
#define AV_LOG_WARNING  24

/**
 * Standard information.
 */
#define AV_LOG_INFO     32

/**
 * Detailed information.
 */
#define AV_LOG_VERBOSE  40

/**
 * Stuff which is only useful for libav* developers.
 */
#define AV_LOG_DEBUG    48

/**
 * Extremely verbose debugging, useful for libav* development.
 */
#define AV_LOG_TRACE    56

从定义中可以看出来,随着严重程度逐渐下降,一共包含如下级别:
AV_LOG_PANIC,
AV_LOG_FATAL,
AV_LOG_ERROR,
AV_LOG_WARNING,
AV_LOG_INFO,
AV_LOG_VERBOSE,
AV_LOG_DEBUG。
每个级别定义的数值代表了严重程度,数值越小代表越严重。
默认的级别是AV_LOG_INFO
此外,还有一个级别不输出任何信息,即AV_LOG_QUIET。

当前系统存在着一个“Log级别”。
所有严重程度高于该级别的Log信息都会输出出来
例如当前的Log级别是AV_LOG_WARNING,则会输出AV_LOG_PANIC,AV_LOG_FATAL,AV_LOG_ERROR,AV_LOG_WARNING级别的信息,而不会输出AV_LOG_INFO级别的信息。
可以通过av_log_get_level()获得当前Log的级别,通过另一个函数av_log_set_level()设置当前的Log级别。

  • 命令行中 指定
ffmpeg -loglevel error -i sample.mp4 output.mkv
  • 代码中写日志:
av_log(NULL, AV_LOG_ERROR, "Error while filtering: %s\n", errbuf);


...
int64_t seek_timestamp = timestamp;
...
av_log(NULL, AV_LOG_INFO, "seek_timestamp : %"PRId64"\n",seek_timestamp);

...
uint64_t total_packets = 0, total_size = 0;
...
av_log(NULL, AV_LOG_VERBOSE, "  Total: %"PRIu64" packets (%"PRIu64" bytes) demuxed\n",
               total_packets, total_size);

References:

https://blog.csdn.net/openswc/article/details/54694477
https://blog.csdn.net/leixiaohua1020/article/details/44243155

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • From:Python之日志处理(logging模块) - 云游道士 - 博客园 https://www.cnbl...
    vigny的先生阅读 2,703评论 3 5
  • 在应用程序中添加日志记录总的来说基于三个目的:监视代码中变量的变化情况,周期性的记录到文件中供其他应用进行统计分析...
    时待吾阅读 5,023评论 0 6
  • 在应用程序中添加日志记录总的来说基于三个目的:监视代码中变量的变化情况,周期性的记录到文件中供其他应用进行统计分析...
    时待吾阅读 5,081评论 1 13
  • 职业化,就是商业世界的教养。 无论生活还是工作 ,都要有分寸感 ,有教养。我们每个人都是独一无二的 ,就像...
    素黑素黑阅读 320评论 0 1
  • 国内常用的素材网站,千图网,包图网,千库网,素材岛,我图网。一般的设计师都会在里面挑选素材进行二次创作。但是唯一的...
    有创意的草图君阅读 25,255评论 4 37