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 },
};
...
}
對(duì)應(yīng)的宏的詳細(xì)說(shuō)明:
/**
* @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
從定義中可以看出來(lái),隨著嚴(yán)重程度逐漸下降,一共包含如下級(jí)別:
AV_LOG_PANIC,
AV_LOG_FATAL,
AV_LOG_ERROR,
AV_LOG_WARNING,
AV_LOG_INFO,
AV_LOG_VERBOSE,
AV_LOG_DEBUG。
每個(gè)級(jí)別定義的數(shù)值代表了嚴(yán)重程度,數(shù)值越小代表越嚴(yán)重。
默認(rèn)的級(jí)別是AV_LOG_INFO。
此外,還有一個(gè)級(jí)別不輸出任何信息,即AV_LOG_QUIET。
當(dāng)前系統(tǒng)存在著一個(gè)“Log級(jí)別”。
所有嚴(yán)重程度高于該級(jí)別的Log信息都會(huì)輸出出來(lái)。
例如當(dāng)前的Log級(jí)別是AV_LOG_WARNING,則會(huì)輸出AV_LOG_PANIC,AV_LOG_FATAL,AV_LOG_ERROR,AV_LOG_WARNING級(jí)別的信息,而不會(huì)輸出AV_LOG_INFO級(jí)別的信息。
可以通過(guò)av_log_get_level()獲得當(dāng)前Log的級(jí)別,通過(guò)另一個(gè)函數(shù)av_log_set_level()設(shè)置當(dāng)前的Log級(jí)別。
- 命令行中 指定
ffmpeg -loglevel error -i sample.mp4 output.mkv
- 代碼中寫(xiě)日志:
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