Load Local Subtitles While MPV Plays Remote Videos

Motivation

Recently I’ve been using PikPak on Linux and ran into a usability issue. There’s no native Linux client, and the web player isn’t always reliable—some videos fail to decode due to codec issues.

My workaround is to use the local player MPV, which can play PikPak files directly via their remote links—very convenient. However, another problem appeared: many external subtitle files are not loaded automatically. When MPV handles a remote URL, it won’t probe the same remote path for a matching subtitle file. So I started looking for a better solution.

Approach

The core idea is to treat video and subtitle files differently and leverage distinct rclone capabilities:

  1. Video: Use rclone serve http to provide remote video files as an HTTP stream to MPV. In my testing, this gives the best experience for smooth playback and fast seeking.
  2. Subtitles: Use rclone mount to mount the remote subtitles folder locally. Subtitle files are small; exposing them as virtual local files lets MPV discover and match them easily with negligible performance cost.

Step-by-step

Step 1: Serve videos via rclone serve http

I do not recommend using rclone mount directly for the video directory. From my tests, streaming large remote files through a FUSE mount performs poorly—especially after seeking, where stutter and buffering are obvious. HTTP streaming avoids these issues.

Assume videos are under the videos directory within an rclone remote named PikPak. Run:

rclone serve http PikPak:videos --addr localhost:8080

After this, rclone starts an HTTP service on localhost:8080. All files under PikPak:videos/ are now accessible at http://localhost:8080/<filename>.

Step 2: Mount the subtitles directory via rclone mount

Subtitle files are tiny; mounting them is the simplest and most efficient approach. Alternatively, you could download them locally.

Suppose subtitles live under the subtitles directory of the PikPak remote. First create a local mount point (for example /mnt/subtitles), then mount:

# Create mount point
mkdir -p /mnt/subtitles

# Mount in the background
rclone mount PikPak:subtitles /mnt/subtitles --daemon

Now the remote subtitle files appear locally at /mnt/subtitles, and MPV can access them like regular local files.

Step 3: Create a playlist

To avoid copying and pasting video URLs every time, create a simple text file as a playlist.

For example, create playlist.txt and put one HTTP link per line:

http://localhost:8080/电视剧/S01E01.mp4
http://localhost:8080/电视剧/S01E02.mp4

Step 4: Launch MPV

With everything ready, start playback with:

mpv --playlist=/path/to/playlist.txt --sub-file-paths=/mnt/subtitles
  • --playlist points to the playlist file created above.
  • --sub-file-paths tells MPV to look for subtitles under /mnt/subtitles.

With this, each video in the playlist will automatically look for and load a matching subtitle file from the subtitles directory.

Extra tip: Handle imperfect subtitle filenames

Sometimes downloaded subtitle filenames aren’t standard—extra language codes or suffixes can prevent MPV from matching them by default rules.

In such cases, add --sub-auto=all or --sub-auto=fuzzy to MPV:

  • --sub-auto=all loads all subtitle files under the subtitle path.
  • --sub-auto=fuzzy loads any subtitle files that contain the video filename.

Example:

mpv --playlist=/path/to/playlist.txt --sub-file-paths=/mnt/subtitles --sub-auto=all

Conclusion

This works, but it’s admittedly a bit involved—you need to run several commands. I’m still looking for a more streamlined approach.

0%