Utilities

Logging

class av.logging.Capture(local=True)

Bases: object

Context manager for capturing logs.

Parameters:local (bool) – Should logs from all threads be captured, or just one this object is constructed in?

e.g.:

with Capture() as logs:
    # Do something.
for log in logs:
    print(log.message)
local
logs
av.logging.adapt_level(int level)

Convert a library log level to a Python log level.

av.logging.get_last_error()

Get the last log that was at least ERROR.

av.logging.get_level()

Return current logging threshold. See set_level().

av.logging.get_print_after_shutdown()

Will logging continue to stderr after Python shutdown?

av.logging.get_skip_repeated()

Will identical logs be emitted?

av.logging.log(int level, str name, str message)

Send a log through the library logging system.

This is mostly for testing.

av.logging.set_level(level)

Sets logging threshold when converting from the library’s logging system to Python’s. It is recommended to use the constants availible in this module to set the level: QUIET, PANIC, FATAL, ERROR, WARNING, INFO, VERBOSE, and DEBUG.

While less efficient, it is generally preferable to modify logging with Python’s logging, e.g.:

logging.getLogger('libav').setLevel(logging.ERROR)

PyAV defaults to translating everything except AV_LOG_DEBUG, so this function is only nessesary to use if you want to see those messages as well. AV_LOG_DEBUG will be translated to a level 5 message, which is lower than any builting Python logging level, so you must lower that as well:

logging.getLogger().setLevel(5)
av.logging.set_print_after_shutdown(v)

Set if logging should continue to stderr after Python shutdown.

av.logging.set_skip_repeated(v)

Set if identical logs will be emitted

Other

class av.utils.AVError

Bases: OSError

Exception class for errors from within FFmpeg.

av.utils.err_check(int res=0, filename=None) → int