diff --git a/av/logging.pyi b/av/logging.pyi index 1db5e4a3b..8c32de77d 100644 --- a/av/logging.pyi +++ b/av/logging.pyi @@ -13,6 +13,7 @@ CRITICAL: int def adapt_level(level: int) -> int: ... def get_level() -> int | None: ... def set_level(level: int | None) -> None: ... +def set_libav_level(level: int) -> None: ... def restore_default_callback() -> None: ... def get_skip_repeated() -> bool: ... def set_skip_repeated(v: bool) -> None: ... diff --git a/av/logging.pyx b/av/logging.pyx index 1006d094c..6b6858db6 100644 --- a/av/logging.pyx +++ b/av/logging.pyx @@ -119,6 +119,17 @@ def set_level(level): raise ValueError("level must be: int | None") +def set_libav_level(level): + """Set libav's log level. It can be set to constants available in this + module: ``PANIC``, ``FATAL``, ``ERROR``, ``WARNING``, ``INFO``, + ``VERBOSE``, ``DEBUG``. + + When PyAV logging is disabled, setting this will change the level of + the logs printed to the terminal. + """ + lib.av_log_set_level(level) + + def restore_default_callback(): """Revert back to FFmpeg's log callback, which prints to the terminal.""" lib.av_log_set_callback(lib.av_log_default_callback) diff --git a/include/libavutil/avutil.pxd b/include/libavutil/avutil.pxd index f9af7a7b0..b4184d0de 100644 --- a/include/libavutil/avutil.pxd +++ b/include/libavutil/avutil.pxd @@ -399,3 +399,4 @@ cdef extern from "libavutil/log.h" nogil: ctypedef void(*av_log_callback)(void *, int, const char *, va_list) void av_log_default_callback(void *, int, const char *, va_list) void av_log_set_callback (av_log_callback callback) + void av_log_set_level(int level)