Skip to content

Commit

Permalink
Support libav's av_log_set_level
Browse files Browse the repository at this point in the history
  • Loading branch information
materight committed Jul 2, 2024
1 parent cd3f4c2 commit b98a12e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions av/logging.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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: ...
Expand Down
11 changes: 11 additions & 0 deletions av/logging.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions include/libavutil/avutil.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit b98a12e

Please sign in to comment.