So, when use my old computer to watch some fun video in youtube, its so laggy and sometimes freeze, i think “What the heck? why its so lag even though i just watch video about dog and cat length 10 minutes?”, when think about solution, i have idea “What happen if i watch this video on terminal?” and that’s time i realize how cool this idea can be, i trying to find many way to run it in terminal and successfully with mpv and yt-dlp:
First things i want to say is i use Linux, so with other OS, you need to find a way prefer with that OS
1: Install mpv
and and yt-dlp
:
sudo apt-get install mpv
Use pip for install yt-dlp
sudo pip install --upgrade yt-dlp
or if you isn’t like yt-dlp, you can also use youtube-dl
sudo pip install --upgrade youtube_dl
2: Config mpv:
Create a file config for mpv
nano ~/.config/mpv/mpv.conf
write this line on to config file:
script-opts=ytdl_hook-ytdl_path=yt-dlp
or use youtube-dl
script-opts=ytdl_hook-ytdl_path=youtube-dl
Save and close this file
Now you will able to watch youtube video use this command:
mpv "path to your youtube video"
Example:
mpv "https://www.youtube.com/watch?v=Z11_ceId5HE"
(this guy really make me laugh so hard i can)
You can also play playlist use same command:
mpv "path to your playlist"
, like mpv "https://www.youtube.com/playlist?list=PLC3y8-rFHvwjifDNQYYWI6i06D7PjF0Ua"
Or you can play video in particular index in this playlist by:
mpv --playlist-start=index_of_this_playlist "path to your playlist"
(its use zero indexed like array, 0 for first video and 1 for second)
This way use for streaming video, not need to download video you want to play or anything other, for more information, you can go to official website of mpv or some tutorial.
If you have trouble with youtube-dl
, you can use yt-dlp
as alternative
If you worry about its cache, you can check it by:
du -sh ~/.cache/mpv
(remove this file when you want clean up cache)