Commit 83ec0f52 authored by Alexander Alekhin's avatar Alexander Alekhin

videoio(ffmpeg): add option to enable debug logs

parent 06c18906
......@@ -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;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment