Does mpv Support Gapless Audio Playback?
The mpv media player fully supports gapless audio playback for
consecutive tracks in a playlist, ensuring transitions between audio
files occur without silence, clicks, or disruptions. This feature is
controlled primarily by the --gapless-audio configuration
option, which manages how the audio device is handled between tracks. By
default, mpv uses a baseline approach to achieve seamless playback, but
users can explicitly configure it to enforce strict gapless behavior
across varying audio formats.
Understanding the Gapless Audio Option
By default, mpv attempts to maintain an open audio device between
consecutive playlist tracks to eliminate standard hardware
initialization delays. The behavior of this feature is determined by
three specific values assigned to the --gapless-audio
option:
weak(Default): The player attempts to keep the audio device open using the initial track’s format. If a subsequent track features a different sample rate or channel layout, the audio device will close and reopen. This provides reliable gapless playback for albums or playlists with matching encoding settings, but can introduce minor gaps if the audio formats change.yes: The audio device is opened using the parameters of the first file in the playlist and is forced to stay open for all following files. If subsequent files use lower or higher sample rates, mpv automatically resamples the audio to match the initial format. This guarantees uninterrupted playback across all consecutive files, though it may alter the native output quality of mixed-format playlists.no: Disables gapless audio entirely. The audio device closes completely at the end of each track and initializes a brand-new instance for the next file.
Recommended Configuration for Optimal Playback
To ensure the most consistent gapless experience directly from the command line, you can pass the explicit flag when launching your playlist:
mpv --gapless-audio=yes --playlist=your_playlist.m3uFor persistent gapless audio without typing the flag every time, you
can add the option directly to your mpv.conf configuration
file:
# Force gapless audio behavior for all playlists
gapless-audio=yes
Potential Limitations with Network Streams
While mpv excels at local gapless transitions, network-based audio
files or cloud streams may occasionally experience buffers. This occurs
because the gapless mechanism relies heavily on the audio output
device’s buffer continuing to play while the next file loads. If network
latency delays the initial caching of the consecutive track, the
hardware buffer may run dry before data from the new file arrives. To
counteract this, users can pair gapless playback with the
--prefetch-playlist=yes option, which prompts mpv to
preload the upcoming track in the playlist before the active song
concludes.