Can I use mpv to rip audio streams from online video?

Yes, you can use the versatile command-line media player mpv to extract and save audio streams directly from online videos without downloading the entire video file. By leveraging its integration with yt-dlp (or youtube-dl), mpv can stream the online media source, isolate the audio track, and decode it directly into a local file on your system. This article will provide a quick overview of how this process works, the exact commands you need to use, and how to select specific audio formats.


How to Extract Audio with mpv

To rip an audio stream, you combine mpv’s ability to play network URLs with its encoding options (the --o or --stream-record flags). Because mpv uses yt-dlp under the hood to parse websites, this method works for thousands of video hosting platforms.

The most efficient way to rip the audio stream in its original, uncompressed digital format (without re-encoding) is by using the following command:

mpv --no-video --stream-record=output.ogg "URL_OF_ONLINE_VIDEO"

In this command:

Re-encoding Audio to MP3 or WAV

If you want to force the audio into a specific format like MP3 or a high-quality WAV file, you can use mpv’s encoding driver (--o). This requires your mpv installation to be compiled with libavfilter support (which is standard in most modern distributions).

To convert the online stream directly to an MP3:

mpv "URL_OF_ONLINE_VIDEO" --no-video --o=output.mp3

Selecting Best Audio Quality

By default, mpv will ask yt-dlp to hand over the best combined video and audio stream. Since you only want the audio, you can optimize the download speed and ensure you get the absolute highest quality audio track available by passing format selectors directly to the underlying downloader:

mpv --ytdl-format=bestaudio --no-video --o=highquality.wav "URL_OF_ONLINE_VIDEO"

Using --ytdl-format=bestaudio instructs the scraper to completely bypass the video stream on the server side, ensuring a fast, audio-only extraction process directly from the web to your local hard drive.