Debugging and Logging#

Logging Overview#

PyNvVideoCodec provides a logging system that helps diagnose issues and understand the library’s behavior. The logging system is primarily based on FFmpeg’s built-in logging capabilities, which can be controlled using environment variables.

Setting Log Levels#

The logging level can be controlled by setting the LOGGER_LEVEL environment variable. When set, this environment variable controls the verbosity of FFmpeg logs used by PyNvVideoCodec.

Available log levels (from most verbose to least verbose):

  • TRACE: Most detailed information (maps to FFmpeg’s AV_LOG_VERBOSE)

  • DEBUG: Debugging information (maps to FFmpeg’s AV_LOG_DEBUG)

  • INFO: General information messages (maps to FFmpeg’s AV_LOG_INFO)

  • WARN: Warning messages (maps to FFmpeg’s AV_LOG_WARNING)

  • ERROR: Error messages (maps to FFmpeg’s AV_LOG_ERROR)

  • FATAL: Critical error messages (maps to FFmpeg’s AV_LOG_FATAL)

If the LOGGER_LEVEL environment variable is not set, logging defaults to AV_LOG_QUIET, which suppresses most messages.

Example Usage#

Linux/macOS: Set with export LOGGER_LEVEL=DEBUG before running your script.

Windows (Command Prompt): Set with set LOGGER_LEVEL=DEBUG before running your script.

Windows (PowerShell): Set with $env:LOGGER_LEVEL="DEBUG" before running your script.

Setting in Python code: Set os.environ["LOGGER_LEVEL"] = "DEBUG" before importing PyNvVideoCodec.