mirror of
https://github.com/opencv/opencv.git
synced 2026-07-30 07:43:03 +04:00
Merge pull request #27864 from peters:patch-2
Add OPENCV_FFMPEG_SKIP_LOG_CALLBACK to preserve custom FFmpeg logging #27864 OpenCV’s InternalFFMpegRegister overwrites av_log_set_callback, blocking custom FFmpeg log handlers in statically linked apps. Add `OPENCV_FFMPEG_SKIP_LOG_CALLBACK` to let applications keep their own logging. ### Pull Request Readiness Checklist See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [x] I agree to contribute to the project under Apache 2 License. - [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV - [x] The PR is proposed to the proper branch - [ ] There is a reference to the original bug report and related work - [ ] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [ ] The feature is well documented and sample code can be built with the project CMake
This commit is contained in:
committed by
GitHub
parent
14aae55450
commit
4e94116e7a
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user