How to listen to a YouTube playlist with mpv from the command line

This is mostly a note pad for myself with quick instructions about how to listen to a YouTube playlist with mpv from the command line.

mpv is a great player which integrates the usage of yt-dlp. That way, it is capable of playing any of the content supported by yt-dlp.

I was looking for a way to listen to a YouTube playlist without any GUI and avoiding to waste my CPU on decoding the video part I am not interested in.

This is the quick reference command to copy and paste:

$ mpv --input-ipc-server=<custom_path_to>/socket --vo=null --ytdl-raw-options="yes-playlist=,format=best*[vcodec=none]" "<youtube_playlist_url>" &

Explanation of the parameters:

  • --vo=null: No video output.

  • --ytdl-raw-options: Comma separated list of command options that will be directly passed to yt-dlp.
    • yes-playlist=: Needs the “=” and to be empty. If provided a playlist, iterate over its elements.
    • format=best*[vcodec=none]: Select the best available format and discard the video content.
  • --input-ipc-server=<custom_path_to>/socket: Creation of a socket for direct communication with mpv. Since we don’t have a GUI, this socket will allow us to control the mpv instance. For example, if we want to move to the next item in a playlist, we will run:
$ echo playlist-next | socat - <custom_path_to>/socket

I hope this is helpful!


Don’t use --vo=null if you would like to have a GUI. Then, you could also skip creating the socket with --input-ipc-server=<custom_path_to>/socket.

In that case, you could just avoid the whole format=best*[vcodec=none] yt-dlp option by passing the --no-video flag. That will save you the video processing although I’m unsure it will avoid the network transfer of the stream so better keep passing that option.