[FFmpeg-devel] [PATCH V2] lavc/libvpx: increase thread limit to 64

Dmitrii Ovchinnikov ovchinnikov.dmitrii at gmail.com
Thu Oct 6 17:03:27 EEST 2022


Removed unnecessary comment as requested by Ronald S. Bultje.

some more thoughts about the patch:

This is my deduction from what I could find - There was a hard limit of 16
threads in libvpx as there was no benefit to adding more threads based upon
the parallelism  available in the the codec. This was based upon
resolutions upto 3840x2160 (more details below). For 4k/8K videos this
restriction does not allow enough parallelism to be exploited. Adding more
threads improves performance for higher resolution videos.

Details:
Tiling and Threading Recommendations
Tiling splits the video frame into multiple columns, which slightly reduces
quality but speeds up encoding performance. Tiles must be at least 256
pixels wide, so there is a limit to how many tiles can be used. Depending
upon the number of tiles and the resolution of the output frame, more CPU
threads may be useful. There is limited value to multiple threads when the
output frame size is very small.

The following settings are recommended for tiling and threading at various
resolutions. The number of threads is doubled as there is an option row-mt
when set allows row-based multithreading within the tiles.

Frame Size | Number of tile-columns | Number of threads
320x240 | 1 (-tile-columns 0) | 2
640x360 | 2 (-tile-columns 1) | 4
640x480 | 2 (-tile-columns 1) | 4
1280x720 | 4 (-tile-columns 2) | 8
1920x1080 | 4 (-tile-columns 2) | 8
2560x1440 | 8 (-tile-columns 3) | 16
3840x2160 | 8 (-tile-columns 3) | 16

In ffmpeg, the number of tiles is controlled with the -tile-columns
parameter and the number of threads by -threads. For example, a 640x480
encode would use the command-line -tile-columns 2 -threads 4.


More information about the ffmpeg-devel mailing list