[x265] memory consumption when encoding 8K video

Michael Lackner michael.lackner at unileoben.ac.at
Thu Apr 6 08:22:27 CEST 2017


I'm also working with 8K content at the moment, and my goal was mostly to push it below
16GiB of memory consumption. When working with that, I found out that there are some
things you can do to reduce memory consumption:

1.) Reduce B-Frames ('--bframes 0'), lowering efficiency
2.) Reduce chroma subsampling (If you're on YUV 4:4:4 or YUV 4:2:2, go for 4:2:0 instead)
3.) Reduce bits per color channel (probably no applicable for your 32-bit build, but 8-bit
consumes slightly less than 10-/12-bit. Only relevant if you have a patched build that
allows for deep color on 32-bit, '-D 8')
3.) Reduce threads!

When it comes to threads, it's best to just throw parallelization away entirely, consuming
much less RAM, but also being much slower on multicore machines:

-F 0 --lookahead-threads 0 --slices 1 --lookahead-slices 0 --no-wpp --no-pmode --no-pme

Additionally, you might wish to limit the CU sizes to larger blocks, which *might* (I
haven't tested this) save memory at the cost of quality in detailed parts of frames:

--ctu 64 --min-cu-size 32

(This might be really bad advice though, quality-wise, not sure...)

While I haven't tested this extensively, I managed to reduce memory from around ~30GiB to
~14GiB by just going from YUV 4:4:4 and 12-bit input to YUV 4:2:0 and 10-bit input as well
as a reduction of B-Frames from 16 to 4 at 12 logical CPUs. Initial consumption was around
~32GiB with 32 logical CPUs (more threads!). The chroma subsampling had the biggest impact
though.

It's all laymans' advice from my side, but maybe parts of this can help you.

On 04/06/2017 02:52 AM, YIRAN LI wrote:
> Hi guys,
> 
> I'm writing a program which can encode video using X265 API.  It's a 32 bit
> program.
> 
> When the program runs to encode a 8K video, I can see every
> time encoder_encode is called, the program eats about 100MB so that after
> 12 frames are sent to encoder and when encoder_encode  is called for
> another frame,  encoder_encode  returns failure. (at this time, about 1.5GB
> in total is consumed by the encoder).
> 
> 
> I guess it's caused by memory limit so compiled everything to 64bit, this
> time everything went well and I could see maximum memory consumption is
> about 6GB.
> 
> 
> But I still need to fix the problem on 32bit because a lot of customers use
> 32 bit version. Just want to know, is there any option, to make encoder
> hold less frames or what ever option that can make encoder consume less
> memory?
> 
> 
> Thanks for suggestion.

-- 
Michael Lackner
Lehrstuhl für Informationstechnologie (CiT)
Montanuniversität Leoben
Tel.: +43 (0)3842/402-1505 | Mail: michael.lackner at unileoben.ac.at
Fax.: +43 (0)3842/402-1502 | Web: http://institute.unileoben.ac.at/infotech


More information about the x265-devel mailing list