How to Use Multiple CPU Cores in FFmpeg on Windows
This article explains how to configure and run FFmpeg commands on Windows to utilize multiple CPU cores for faster video and audio encoding. You will learn how to use the built-in threading parameters, apply codec-specific multi-threading options, and use Windows-specific command prompt tools to optimize CPU performance.
The -threads Parameter
By default, modern versions of FFmpeg are configured to automatically
detect your CPU’s cores and threads to maximize performance. However,
you can explicitly control this behavior using the -threads
parameter.
To tell FFmpeg to use all available CPU cores, use
-threads 0 (which is the default auto-detect setting):
ffmpeg -i input.mp4 -c:v libx264 -threads 0 output.mp4To limit FFmpeg to a specific number of CPU threads (for example, 4
threads to prevent 100% CPU utilization so you can do other tasks),
replace 0 with your desired number:
ffmpeg -i input.mp4 -c:v libx264 -threads 4 output.mp4Codec-Specific Threading Controls
Different encoders handle multi-threading differently. If the global
-threads option does not yield the desired CPU usage, you
can pass parameters directly to the specific encoder.
For H.264 (libx264)
The libx264 encoder has excellent native
multi-threading. You can control its threading behavior using
-x264opts or -x264-params:
ffmpeg -i input.mp4 -c:v libx264 -x264-params threads=8 output.mp4For H.265 / HEVC (libx265)
The libx265 encoder organizes threads into “pools.” To
force it to use a specific number of threads or CPU pools on Windows,
use the pools option inside -x265-params:
ffmpeg -i input.mp4 -c:v libx265 -x265-params pools=8 output.mp4Optimizing CPU Priority in Windows
Even with multi-threading enabled, the Windows operating system
determines how much CPU priority is given to the FFmpeg process. You can
force Windows to prioritize FFmpeg using the command prompt’s
start command.
To run FFmpeg with “High” CPU priority using all available cores:
start /high /wait ffmpeg -i input.mp4 -c:v libx264 -threads 0 output.mp4/high: Instructs Windows to allocate more CPU cycles to FFmpeg over background processes./wait: Prevents the command prompt window from closing or accepting new commands until the FFmpeg process is finished.