diff --git a/doc/tutorials/introduction/env_reference/env_reference.markdown b/doc/tutorials/introduction/env_reference/env_reference.markdown index 88b4008c8f..d4e2881f42 100644 --- a/doc/tutorials/introduction/env_reference/env_reference.markdown +++ b/doc/tutorials/introduction/env_reference/env_reference.markdown @@ -273,6 +273,7 @@ Some external dependencies can be detached into a dynamic library, which will be | OPENCV_FFMPEG_THREADS | num | | set FFmpeg thread count | | OPENCV_FFMPEG_DEBUG | bool | false | enable logging messages from FFmpeg | | OPENCV_FFMPEG_LOGLEVEL | num | | set FFmpeg logging level | +| OPENCV_FFMPEG_SKIP_LOG_CALLBACK | bool | false | do not install OpenCV's FFmpeg log callback (preserve default/user callback) | | OPENCV_FFMPEG_DLL_DIR | dir path | | directory with FFmpeg plugin (legacy) | | OPENCV_FFMPEG_IS_THREAD_SAFE | bool | false | enabling this option will turn off thread safety locks in the FFmpeg backend (use only if you are sure FFmpeg is built with threading support, tested on Linux) | | OPENCV_FFMPEG_READ_ATTEMPTS | num | 4096 | number of failed `av_read_frame` attempts before failing read procedure | diff --git a/modules/videoio/src/cap_ffmpeg_impl.hpp b/modules/videoio/src/cap_ffmpeg_impl.hpp index 7ce18fdfbf..6d7749d21c 100644 --- a/modules/videoio/src/cap_ffmpeg_impl.hpp +++ b/modules/videoio/src/cap_ffmpeg_impl.hpp @@ -937,6 +937,8 @@ static void ffmpeg_log_callback(void *ptr, int level, const char *fmt, va_list v class InternalFFMpegRegister { + static bool skip_log_callback; + public: static void init(const bool threadSafe) { @@ -949,6 +951,7 @@ public: { const bool debug_option = utils::getConfigurationParameterBool("OPENCV_FFMPEG_DEBUG"); std::string level_option = utils::getConfigurationParameterString("OPENCV_FFMPEG_LOGLEVEL"); + skip_log_callback = utils::getConfigurationParameterBool("OPENCV_FFMPEG_SKIP_LOG_CALLBACK"); int level = AV_LOG_VERBOSE; if (!level_option.empty()) { @@ -957,7 +960,10 @@ public: if ( debug_option || (!level_option.empty()) ) { av_log_set_level(level); - av_log_set_callback(ffmpeg_log_callback); + if (!skip_log_callback) + { + av_log_set_callback(ffmpeg_log_callback); + } } else { @@ -986,10 +992,15 @@ public: #ifdef CV_FFMPEG_LOCKMGR av_lockmgr_register(NULL); #endif - av_log_set_callback(NULL); + if (!skip_log_callback) + { + av_log_set_callback(NULL); + } } }; +bool InternalFFMpegRegister::skip_log_callback = false; + inline void fill_codec_context(AVCodecContext * enc, AVDictionary * dict) { if (!enc->thread_count)