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

Tr3wory tr3w at freemail.hu
Mon Jan 16 12:38:12 CET 2012

So basically the only possible way of doing this, is to use the
parent_log_context_offset from AVClass, and go upwards from child to
parent until I found the topmost context which is an AVFormatContext
or an AVCodecContext what I used when I called the libav functions. Is
that right? Will it work?


On Sun, Jan 15, 2012 at 8:26 PM, Andrey Utkin
<andrey.krieger.utkin at gmail.com> wrote:
> 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
> _______________________________________________
> Libav-user mailing list
> Libav-user at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/libav-user

More information about the Libav-user mailing list