How to Set rav1e Frame Parallelism in FFmpeg
This article explains how to configure frame-parallelism in the
rav1e AV1 encoder when using FFmpeg. By adjusting this
setting, you can leverage multi-threading to speed up your AV1 video
encoding times, optimizing the encoder for multi-core processors.
Understanding Frame-Parallelism in rav1e
In rav1e, frame-parallelism allows the encoder to
process multiple video frames concurrently. While standard threading
splits a single frame into tiles for parallel processing,
frame-parallelism works across the temporal domain, encoding separate
frames at the same time. This significantly improves CPU utilization on
high-core-count systems.
To configure this in FFmpeg, you must pass the
frame-threads parameter to the librav1e
encoder wrapper using the -rav1e-params option.
FFmpeg Command Syntax
To enable and configure frame-parallelism, use the following syntax in your FFmpeg command:
ffmpeg -i input.mp4 -c:v librav1e -rav1e-params frame-threads=N output.mp4Replace N with the number of frames you want to process
in parallel.
Example: Encoding with 4 Frame Threads
To encode a video using 4 parallel frame threads:
ffmpeg -i input.mp4 -c:v librav1e -rav1e-params frame-threads=4 output.mp4Optimizing the Thread Settings
When configuring rav1e parallelism, there are two key
parameters you can pass inside -rav1e-params to balance
your CPU usage:
frame-threads: The number of frames processed concurrently. Increasing this value speeds up encoding but increases memory (RAM) usage. A value of 2 to 4 is generally recommended for consumer CPUs.threads: The size of the thread pool used for tile and pixel-level work within each frame.
You can combine these options by separating them with a colon
(:):
ffmpeg -i input.mp4 -c:v librav1e -rav1e-params frame-threads=4:threads=8 output.mp4In this setup, FFmpeg will encode 4 frames in parallel, utilizing a total thread pool of 8 threads to process the workload.