How to Enable Hardware Acceleration in mpv?
This article provides a straightforward guide on how to enable hardware acceleration in the mpv media player to lower CPU utilization and ensure smoother video playback. It covers the necessary configuration file edits, the specific video decoding API options available for different operating systems, and how to verify that hardware acceleration is active during playback.
Understanding mpv Hardware Acceleration
By default, mpv may rely on software decoding, which uses your CPU to process video frames. For high-resolution files like 4K or HEVC, this can lead to high CPU usage, stuttering, and increased power consumption. Enabling hardware acceleration offloads this processing to your dedicated or integrated Graphics Processing Unit (GPU), resulting in cooler system temperatures and seamless playback.
Step-by-Step Configuration
To permanently enable hardware acceleration, you need to add a
specific command to your mpv.conf configuration file.
1. Locate or Create your
mpv.conf File
The location of the configuration file depends on your operating system:
- Windows:
C:\Users\Username\AppData\Roaming\mpv\mpv.conf(or inside a folder namedportable_configin your mpv installation directory if using a portable version). - Linux:
~/.config/mpv/mpv.conf - macOS:
~/.config/mpv/mpv.conf
If the file does not exist, create a blank text file and name it
mpv.conf.
2. Add the Hardware Decoding Command
Open the mpv.conf file in a text editor and add the
following line for a safe, auto-detecting setup:
hwdec=auto-safe
The auto-safe option tells mpv to automatically select
the best hardware decoding method available for your system that is
known to be stable. If you want mpv to try any available hardware
decoder, including experimental ones, you can use:
hwdec=auto
3. Advanced Platform-Specific Options
If auto-safe does not deliver the desired results, you
can manually specify the API tailored to your hardware:
- Windows (NVIDIA/AMD/Intel):
hwdec=d3d11va(Recommended for modern Windows setups) orhwdec=nvdec(Exclusive to NVIDIA cards). - Linux (Intel/AMD):
hwdec=vaapi - Linux (NVIDIA):
hwdec=nvdecorhwdec=vdpau - macOS:
hwdec=videotoolbox
Replace auto-safe with your chosen API in the
mpv.conf file, save it, and restart mpv.
How to Verify Hardware Acceleration is Working
To ensure that mpv is successfully using your GPU instead of your CPU, follow these steps during video playback:
- Open a video in mpv.
- Press Shift + I on your keyboard to bring up the stats overlay.
- Look at the first page of statistics for the Decoder line.
- If hardware acceleration is working, it will display the video
format followed by the hardware API in parentheses (for example:
h264 (d3d11va-copy)orhevc (nvdec)). If it sayssoftware, hardware acceleration is not active.