mirror of
https://github.com/opencv/opencv.git
synced 2025-08-06 06:26:29 +08:00
Merge pull request #11618 from alalek:ffmpeg_debug_log
This commit is contained in:
commit
133e9f2012
@ -754,6 +754,17 @@ private:
|
||||
AutoLock& operator = (const AutoLock&); // disabled
|
||||
};
|
||||
|
||||
static void ffmpeg_log_callback(void *ptr, int level, const char *fmt, va_list vargs)
|
||||
{
|
||||
static bool skip_header = false;
|
||||
static int prev_level = -1;
|
||||
(void)ptr;
|
||||
if (!skip_header || level != prev_level) printf("[OPENCV:FFMPEG:%02d] ", level);
|
||||
vprintf(fmt, vargs);
|
||||
size_t fmt_len = strlen(fmt);
|
||||
skip_header = fmt_len > 0 && fmt[fmt_len - 1] != '\n';
|
||||
prev_level = level;
|
||||
}
|
||||
|
||||
class InternalFFMpegRegister
|
||||
{
|
||||
@ -773,7 +784,18 @@ public:
|
||||
/* register a callback function for synchronization */
|
||||
av_lockmgr_register(&LockCallBack);
|
||||
|
||||
av_log_set_level(AV_LOG_ERROR);
|
||||
#ifndef NO_GETENV
|
||||
char* debug_option = getenv("OPENCV_FFMPEG_DEBUG");
|
||||
if (debug_option != NULL)
|
||||
{
|
||||
av_log_set_level(AV_LOG_VERBOSE);
|
||||
av_log_set_callback(ffmpeg_log_callback);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
av_log_set_level(AV_LOG_ERROR);
|
||||
}
|
||||
|
||||
_initialized = true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user