Skip to content

Allow to set av_log_set_level to reduce ffmpeg level below AV_LOG_ERROR#20897

Merged
opencv-pushbot merged 1 commit intoopencv:3.4from
ThalesGroup:master
Oct 19, 2021
Merged

Allow to set av_log_set_level to reduce ffmpeg level below AV_LOG_ERROR#20897
opencv-pushbot merged 1 commit intoopencv:3.4from
ThalesGroup:master

Conversation

@michelpromonet
Copy link
Copy Markdown

Hi,

I submit this PR in order to allow to reduce de ffmpeg loglevel below ERROR (that is 32).
During H264 decoding it is quite often ffmpeg print lots of error log (like bad SEI parsing) that may not be relevant in production.

This PR allow to set the ffmpeg level through the environment variable OPENCV_FFMPEG_LOGLEVEL

Best Regards,
Michel.

  • I agree to contribute to the project under Apache 2 License.
  • To the best of my knowledge, the proposed patch is not based on a code under GPL or other license that is incompatible with OpenCV
  • The PR is proposed to proper branch
  • There is reference to 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

av_log_set_level(atoi(level_option));
}

char* debug_option = getenv("OPENCV_FFMPEG_DEBUG");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is already OPENCV_FFMPEG_DEBUG option to "reduce de ffmpeg loglevel below ERROR".

Please note, that this is global configuration of FFmpeg, it is not about OpenCV calls only (other libraries may be affected, e.g., gst-libav plugin).


Added code doesn't work at all as expected (av_log_set_level() is called with own values below anyway)

Copy link
Copy Markdown
Author

@michelpromonet michelpromonet Oct 19, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Alexander,

The environment variable OPENCV_FFMPEG_DEBUG, only allow to set verbose, moreover as the fucntion ffmpeg_log_callback doesnot check the log level, it prints all levels.
Impacting all usage of ffmeg is the situation I would like to manage, printing thousand of errors decoding SEI frames or bad H264 code coming from a camera doesnot helps of maintenance.

I will improve the situation when OPENCV_FFMPEG_DEBUG and OPENCV_FFMPEG_LOGLEVEL are both defined.

My first idea was to extend the feature of OPENCV_FFMPEG_DEBUG, interpretaing the value of the variable as a loglevel, for me this is fine. But setting OPENCV_FFMPEG_DEBUG change the log callback and all levels are printed, and this is not what I would like.
If you prefer this way (setting level in the existing variable OPENCV_FFMPEG_DEBUG, and filtering the level active in the callback, I prefer and can update the PR in this way.

Best Regards,
Michel.

@michelpromonet
Copy link
Copy Markdown
Author

Hi,

I updated the PR in order to filter log of non active level setting OPENCV_FFMPEG_DEBUG

Best Regards,
Michel.

Copy link
Copy Markdown
Member

@alalek alalek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

This patch should go into 3.4 branch first.
We will merge changes from 3.4 into master regularly (weekly/bi-weekly).

Please:

  • change "base" branch of this PR: master => 3.4 (use "Edit" button near PR title)
  • rebase your commits from master onto 3.4 branch. For example:
    git rebase -i --onto upstream/3.4 upstream/master
    (check list of your commits, save and quit (Esc + "wq" + Enter)
    where upstream is configured by following this GitHub guide and fetched (git fetch upstream).
  • push rebased commits into source branch of your fork (with --force option)

Note: no needs to re-open PR, apply changes "inplace".

@michelpromonet michelpromonet changed the base branch from master to 3.4 October 19, 2021 08:36
Copy link
Copy Markdown
Member

@alalek alalek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you 👍

@opencv-pushbot opencv-pushbot merged commit 3f191e1 into opencv:3.4 Oct 19, 2021
@alalek alalek mentioned this pull request Oct 23, 2021
@alalek alalek mentioned this pull request Dec 30, 2021
@alalek alalek mentioned this pull request Feb 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants