How to Set Up a Custom Cache Directory for mpv?

Configuring a custom cache directory for the mpv media player allows you to control where temporary playback data is stored, which is especially useful for managing disk space or optimizing performance on solid-state drives. By default, mpv handles caching automatically, but you can override this behavior by editing your mpv.conf configuration file. This guide provides the exact configuration lines needed to change the cache path, explains what each line does, and outlines how to apply these settings across different operating systems.

Required Configuration Lines

To redirect mpv’s cache to a specific folder, you need to add the following lines to your mpv.conf file:

# Enable caching for both network streams and local files if desired
cache=yes

# Specify the custom directory path for cache storage
cache-dir="C:\path\to\your\custom\cache"

Note: Replace "C:\path\to\your\custom\cache" with your actual desired folder path. For Linux or macOS users, the path will look like "/home/username/.custom_mpv_cache". Make sure the folder already exists on your system, as mpv may not automatically create the directory structure.

Configuration Breakdown

To gain finer control over your new custom cache directory, you can also include these optional performance tweaks right below your directory path:

# Set the maximum cache size (e.g., 500MB)
demuxer-max-bytes=500MiB

# Set the maximum look-ahead cache size (e.g., 100MB)
demuxer-max-back-bytes=100MiB

Where to Put the Configuration Lines

To make these changes take effect, you must save them in your global or user-specific mpv.conf file. The location of this file depends entirely on your operating system:

Operating System Typical mpv.conf Directory Path
Windows C:\Users\YourUsername\AppData\Roaming\mpv\ or the portable_config folder in your mpv installation directory.
Linux /home/yourusername/.config/mpv/
macOS /Users/yourusername/.config/mpv/

Once you have added the lines to the file, save it and restart mpv. Your media player will immediately begin routing all temporary video and audio stream segments into your newly designated custom folder.