[Libav-user] multi-thread decoding

Carl Eugen Hoyos ceffmpeg at gmail.com
Mon Oct 24 14:31:16 EEST 2016

2016-10-24 13:02 GMT+02:00 YIRAN LI <mrfun.china at gmail.com>:
> 2016-10-24 19:49 GMT+11:00 Carl Eugen Hoyos <ceffmpeg at gmail.com>:
>> 2016-10-24 7:26 GMT+02:00 YIRAN LI <mrfun.china at gmail.com>:
>> > I'm researching the impact multi-thread decoding may have on memory
>> > usage.
>> > Does anyone know if enabling multi thread decoding will use more memory
>> > ?
>> Multi-threaded decoding can be more memory-consuming than single-threaded
>> decoding, FFmpeg developers do not agree whether this is unavoidable or a
>> disadvantage of our implementation.
>> > (so that more threads used, more memory required?)
>> >
>> > I tried to decode an H.264 encoded 4K video using command:
>> >  ffmpeg.exe -v error -i a.mp4  -threads 0 -f null - 2>error.log
>> How did you encode the H.264 input file?
>> Test with eight reference frames and yuv 4:4:4.
> Thanks Carl, does that mean multi-thread decoding doesn't work
> for all H.264 videos?

That is not what I wrote but I believe that for inter-dependency
codecs like h264, this is always true.

> I'm at home so I can only do the test tomorrow, but could you tell
> me, if you know, if more threads used in decoding will generally
> consume more memory?

I believe I already answered this but I suspect it depends on
your definition of "generally" and "more" (even if FFmpeg
would not allocate additional resources for multi-threaded
decoding which I believe it does, the operating system would
have to anyway).

> If decoding speed is not that important, is
> there any other reason to use multi-thread decoding?

Again, this depends on your definition of "decoding speed":
Multi-threaded (h264) decoding has a huge overhead / scales
very badly, so some will argue that to increase decoding speed
(for many videos), you have to use single-threaded decoding
for h264.

Carl Eugen

More information about the Libav-user mailing list