Avutil.LogFFmpeg's log: its level, and the capture of its messages by an OCaml function. Both are state of the whole process.
FFmpeg's log levels, from the most silent to the most verbose. Each is the FFmpeg constant of the same name (AV_LOG_QUIET to AV_LOG_TRACE).
val set_level : level -> unitset_level l sets FFmpeg's log level for the whole process: FFmpeg reports the messages of level l and of the less verbose levels.
val log : level -> string -> unitlog l message sends message to FFmpeg's log at level l, where it is reported, filtered and captured as FFmpeg's own messages are.
set_callback f captures FFmpeg's log messages, for the whole process, and delivers them to f. It replaces a callback installed earlier. FFmpeg's default logger prints nothing while a callback is installed.
Capture. FFmpeg logs from any thread, its own worker threads included. From the return of set_callback on, each message at or below the current level (set_level) is formatted as FFmpeg's default logger formats it, prefix included, cut at a fixed length, and put on a queue by the thread that logs. That thread runs no OCaml code and does not wait for the delivery. There is one message per log call of FFmpeg, so a message may be a part of a line.
Delivery. One thread of this library calls the callback, never the thread that logged. The first set_callback of the program starts it, in the domain of the caller, and it runs until the program exits. It delivers the messages in the order they were queued, each at most once, and each to the callback that was installed when the message was queued: messages still queued for an earlier callback reach that callback, not f. It waits for messages with the OCaml runtime lock released.
The callback runs with the runtime lock held. It may call any function of the bindings, set_callback and clear_callback included, and functions that log. An exception it raises is caught and printed on standard error, and delivery goes on with the next message.
f is kept alive until it is replaced or cleared and its last message is delivered.
val set_callback_with_level : (level -> string -> unit) -> unitAs set_callback, with each message's level: FFmpeg's numeric level mapped to the named level at or above it in severity.
clear_callback () restores FFmpeg's default logging and drops the installed callback.
It blocks until every message queued before the call has been delivered to that callback; other threads run meanwhile. Called from the callback itself it returns at once, and those messages are delivered after the callback returns. The outgoing callback receives nothing after that, and a callback installed later receives none of those messages.
With no callback installed it only restores FFmpeg's default logging. set_callback may be called again at any time afterwards.