[Libav-user] Multithreaded decoding of multi-program transport streams

Adi Shavit adishavit at gmail.com
Tue Dec 3 08:12:14 CET 2013


As Andy explained I want multiple decoders for different elementary
streams running
simultaneously on different threads. What you are suggesting should improve
the performance of (each) single decoder.

Thanks,
Adi


On Mon, Dec 2, 2013 at 11:46 PM, Bruce Wheaton <bruce at spearmorgan.com>wrote:

> On Dec 1, 2013, at 2:43 AM, Adi Shavit <adishavit at gmail.com> wrote:
>
> Does anyone have any insights or some references I should follow regarding
> this issue?
>
>
> Adi, are you aware that ffmpeg does/can employ multi-threaded decoding
> already? If you set the correct number of threads by setting thread_count in
> your avcodeccontext before opening the codec, it will do exactly what you
> propose.
>
> In effect, the first few decode calls will return immediately, then your
> frames will start to come out, having been delayed by the number of threads
> you requested.
>
> Bruce
>
>
>
>
> On Tue, Nov 26, 2013 at 9:15 PM, Adi Shavit <adishavit at gmail.com> wrote:
>
>> Hi,
>>
>>   I am consuming a multi-program transport stream with several video
>> streams and decoding them simultaneously. This works well.
>>
>> I am currently doing it al on a single thread.
>> Each AVPacket received by av_read_frame() is checked for the relevant
>> stream_index and passed to a *corresponding* decoder.
>> Hence, I have one AVCodecContext per decoded elementary stream. Each such
>> AVCodecContext handles one elementary stream, calling
>> avcodec_decode_video2() etc.
>>
>> The current single threaded design means that the next packet isn't
>> decoded until the one before it is decoded.
>> I'd like to move to a multi-threaded design where each AVCodecContext
>> resides in a separate thread with its own AVPacket (concurrent SPSC-)queue
>> and the master thread calls av_read_frame() and inserts the coded packet
>> into the relevant queue (Actor Model / Erlang style).
>> Note that each elementary stream is always decoded by the same single
>> thread.
>>
>> Before I refactor my code to do this, I'd like to know if there is
>> anything on the avlib side *preventing* me from implementing this
>> approach.
>>
>>    - AVPacket is a pointer to internal and external data. Are there any
>>    such data that are shared between elementary streams?
>>    - What should I beware of?
>>
>> Please advise,
>> Thanks,
>> Adi
>>
>>
>>
> _______________________________________________
> Libav-user mailing list
> Libav-user at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/libav-user
>
>
>
> _______________________________________________
> Libav-user mailing list
> Libav-user at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/libav-user
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20131203/75991e7f/attachment.html>


More information about the Libav-user mailing list