Playing YouTube Videos with VLC/MPV
Quick trick to play YouTube videos in VLC/MPV
This site has moved to snehit.dev
Here’s a quick tip - you can play YouTube videos from your terminal. I like YouTube because its home to lot of content that otherwise is difficult to find. For example, I get my fill of 80’s City Pop from YouTube.
Now I’m not a fan of bloated websites. The YouTube video player page does lot more than just playing a video. It shows suggestions, comments and a bloated user interface.
So, the easy way out is to use your own video player to play the video!
Go to a terminal and run
mpv "https://www.youtube.com/watch?v=_cPJHqMBR7M"
This will stream the video in MPV. If you are more of a VLC person, you can use that too.
vlc "https://www.youtube.com/watch?v=_cPJHqMBR7M"
To play only audio, you can pass --no-video
flag while invoking mpv.
mpv "https://www.youtube.com/watch?v=_cPJHqMBR7M" --no-video
You can play/pause with spacebar. Seek with arrow keys. Volume is controlled with number keys 9 and 0.
The only problem with the above approach is that you still need to open the browser and bear along with the web interface to search for video and get those links. Well, there’s a solution for that too!
Mps-youtube is a command line utility that lets you search and play content from YouTube. You can install the application from your distro repositories or via pip. On Arch Linux, you need to install mps-youtube-git
from AUR because the stable release from community repo does not work with mpv. If you want to use VLC as your player, then the mps-youtube
package from community repo will work too. If you don’t want to install via AUR, you can use pip to install the development version.
pip install git+https://github.com/mps-youtube/mps-youtube.git
You can launch the application with mpsyt
in your shell. Then you need to set your YouTube API keys which is a five minute task.
In the application, I recommend running set search_music false
because lot of songs are not recognized as music by YouTube. But it depends on the artists you usually listen. Then you can search in vim style! Press forward slash followed by your search term. It will present a list of results. Choose the one to play by entering the corresponding number.
By default, it plays only audio. If you want to play videos too, you will need to run show_video true
inside the application. If using a new version of mpv, I also recommend running set player vlc
because I had issues with using mpv for video.
Thats it for this post!
You can receive latest updates from this blog as an RSS feed. See Follow this blog via RSS.
Follow me on GitHub : flyingcakes85