ffmpeg#loglevel을 이용하여 로그 출력 정보를 제어합니다

2987 단어
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 레벨은 AV_LOG_경고, AV_ 내보내기LOG_PANIC,AV_LOG_FATAL,AV_LOG_ERROR,AV_LOG_AV_를 내보내지 않고 WARNING 수준 정보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
    ", errbuf); ... int64_t seek_timestamp = timestamp; ... av_log(NULL, AV_LOG_INFO, "seek_timestamp : %"PRId64"
    ",seek_timestamp); ... uint64_t total_packets = 0, total_size = 0; ... av_log(NULL, AV_LOG_VERBOSE, " Total: %"PRIu64" packets (%"PRIu64" bytes) demuxed
    ", total_packets, total_size);

    References:


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

    좋은 웹페이지 즐겨찾기