FFmpeg has a logging system that it uses extensively. PyAV hooks into that system to translate FFmpeg logs into Python’s logging system.
If you are not already using Python’s logging system, you can initialize it quickly with:
import logging logging.basicConfig()
You can disable hooking the logging system with an environment variable:
or at runtime with
This will leave (or restore) the FFmpeg logging system, which prints to the terminal. This may also result in raised errors having less detailed messages.
- class av.logging.Capture(bool local=True)¶
A context manager for capturing logs.
local (bool) – Should logs from all threads be captured, or just one this object is constructed in?
with Capture() as logs: # Do something. for log in logs: print(log.message)
- av.logging.adapt_level(int level)¶
Convert a library log level to a Python log level.
Get the last log that was at least
Will logging continue to
stderrafter Python shutdown?
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.
Revert back to FFmpeg’s log callback, which prints to the terminal.
Sets logging threshold when converting from FFmpeg’s logging system to Python’s. It is recommended to use the constants available in this module to set the level:
While less efficient, it is generally preferable to modify logging with Python’s
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_DEBUGwill be translated to a level 5 message, which is lower than any builtin Python logging level, so you must lower that as well:
Set if logging should continue to
stderrafter Python shutdown.
Set if identical logs will be emitted