Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Enable OpenCV ffmpeg logging

I am using python OpenCV with FFMPEG to stream an RTSP video stream.

I want to view ffmpeg logging to see what is going on under the hood with ffmpeg.

How do I enable this logging?

like image 648
Harry Boy Avatar asked Aug 12 '26 13:08

Harry Boy


2 Answers

Actually, the full set of environment variables to control logging of ffmpeg and the video-related parts of OpenCV is as follows:

  • OPENCV_LOG_LEVEL (the general OpenCV log level. e.g.: VERBOSE)
  • OPENCV_VIDEOIO_DEBUG (set to 1 to enable debugging of the videoio module)
  • OPENCV_FFMPEG_DEBUG (set to 1 to enable debugging of the ffmpeg backend) and
  • OPENCV_FFMPEG_LOGLEVEL which expects a numerical value. you can pick one from the following defines (stripped from ffmpeg source code) :
    #define AV_LOG_QUIET    -8
    #define AV_LOG_PANIC     0
    #define AV_LOG_FATAL     8
    #define AV_LOG_ERROR    16
    #define AV_LOG_WARNING  24
    #define AV_LOG_INFO     32
    #define AV_LOG_VERBOSE  40
    #define AV_LOG_DEBUG    48
    #define AV_LOG_TRACE    56

So.. for the debug level you have to do something like:

export OPENCV_FFMPEG_LOGLEVEL=48

You'd probably want the following variables as well:

export OPENCV_VIDEOWRITER_DEBUG=1
export OPENCV_VIDEOCAPTURE_DEBUG=1

Sooo.. for maximum logging of OpenCV/videoio/ffmpeg:

export OPENCV_VIDEOIO_DEBUG=1
export OPENCV_FFMPEG_DEBUG=1
export OPENCV_LOG_LEVEL=VERBOSE
export OPENCV_FFMPEG_LOGLEVEL=56

but there are many more environment variables you can use to get a better picture of what is going on. the following are a collection of additional variables i use for debugging:

export OPENCV_OPENCL_RAISE_ERROR=1
export OPENCV_OPENCL_ABORT_ON_BUILD_ERROR=1
export OPENCV_DUMP_ERRORS=1
export OPENCV_DUMP_CONFIG=1
export OPENCV_TRACE=1
export OPENCV_TRACE_DEPTH_OPENCV=1
export OPENCV_TRACE_SYNC_OPENCL=1
like image 115
kallaballa Avatar answered Aug 15 '26 02:08

kallaballa


Hello you can set those env variable:

export OPENCV_VIDEOIO_DEBUG=1
export OPENCV_FFMPEG_DEBUG=1
export OPENCV_LOG_LEVEL=DEBUG
like image 37
michou Avatar answered Aug 15 '26 04:08

michou



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!