Play online videos in mpv with yt-dlp

Streaming6 min readUpdated

A web video URL passing through yt-dlp into mpv, with the command mpv "https://…" shown below.

mpv can open a web page URL as if it were a local file. It shows the stream in its own window, with its own keys, subtitles and quality settings. The piece that makes this work is yt-dlp, a separate download tool. Once mpv can find it, playing a link is a single command.

How URL playback works

mpv ships with a built-in script called the ytdl hook. When you open an http(s) link, the hook asks yt-dlp to work out the actual audio and video stream addresses for that page. mpv then plays those streams itself. mpv handles separate audio and video streams directly, so you don't need a separate FFmpeg install for playback.

So the only requirement is that mpv can find a working yt-dlp.

Setting it up on Windows

Pick one of these:

  • Next to mpv: download yt-dlp.exe from the yt-dlp project's GitHub releases and place it in the same folder as mpv.exe. Simple, and it travels with a portable install.
  • winget: winget install yt-dlp.yt-dlp installs it and puts it on your PATH.
  • Scoop: scoop install yt-dlp.

Some mpv builds include an updater.bat script that can also fetch yt-dlp for you. Check your build's folder.

macOS and Linux

Install yt-dlp with your package manager (brew install yt-dlp on macOS, or your distribution's package). Distribution packages can lag behind, and yt-dlp needs frequent updates, so many Linux users install the latest release directly from the yt-dlp project instead.

Playing a link

mpv "https://www.example.com/watch?v=…"

Quote the URL, because characters like & and ? mean something to your shell. You can also drag a link from the browser's address bar onto the mpv window. In mpv 0.41, pressing Ctrl+v in the window appends whatever is on your clipboard to the playlist.

Choosing quality

By default yt-dlp picks the best available streams, which might be 4K and heavy on bandwidth. Cap it in mpv.conf:

# up to 1080p video plus the best audio
ytdl-format=bestvideo[height<=?1080]+bestaudio/best

Change 1080 to 720 on slow connections. The value is passed straight to yt-dlp, so anything in yt-dlp's format selection syntax works here.

When links suddenly stop working

Video sites change often, and yt-dlp is updated to keep up. If links that used to play now fail, an outdated yt-dlp is the likely cause:

yt-dlp -U

(For winget or Scoop installs, use winget upgrade yt-dlp.yt-dlp or scoop update yt-dlp instead.) To see what's happening, run mpv from a terminal. Errors from yt-dlp are printed there. Check that yt-dlp --version works in the same terminal. If it doesn't, mpv can't find it either.

A note on terms of use

mpv and yt-dlp are tools. Whether you may stream or save particular content depends on the website's terms and your local law. Use them for content you're entitled to watch.

Ready to try it? The homepage has the Windows download and a short setup checklist.

Download Now