[Libav-user] Questions about using libav in a multi-threaded application

Andrey Utkin andrey.krieger.utkin at gmail.com
Sun Jan 15 20:26:16 CET 2012


2012/1/15 Tr3wory <tr3w at freemail.hu>:
> Hi all!
>
> I started writing a multi-threaded program which can read multiple
> videos simultaneously.
> Basically every thread read it's own video, and use it's own
> AVFormatContext and AVCodecContext so no libav related shared data
> exist.
> What is not clear to me: is this scenario supported by default, or I
> need to use av_lockmgr_register etc.?

You should use av_lockmgr_register(), otherwise you'll have warnings
on avcodec_open.
Although i quite don't get the reason why avcodec_open should require
this from library user.

> My other questions is logging related: I know I can register a new
> callback with av_log_set_callback, but because I have more than one
> video in processing, how can I know where the logging information came
> from?

The first callback arg, void *ptr, is the 'context' of what log
message is related to.
Although you can get many different values in this field:
AVFormatContext*, AVCodecContext, even URLContext* or so. So you get
the idea, it'll not be easy to check what is about what in this case.
But still possible, as you can traverse all AVCodecContexts of each
AVFormatContext, and so on.

-- 
Andrey Utkin


More information about the Libav-user mailing list