This might sound complicated, but youtube videos come in many shapes, many of them have either video only, or audio only !
the best way to get a full resolution video is to download then combine video and audio ! this can be done automatically by yt-dlp
Installing
The copy of yt-dlp in the debian repositories is currently out of date and non functional, so instead you might want to install it with
sudo curl -L https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp -o /usr/local/bin/yt-dlp
sudo chmod a+rx /usr/local/bin/yt-dlp
yt-dlp -v
In addition to the above, make sure you have nodejs and python3 and ffmpeg installed
Configuring
I use the following settings in my config file (note to self: this is on vm129)
--no-js-runtimes
--js-runtimes node
--format "bv*[vcodec^=avc1][height<=1080]+ba[ext=m4a]/b[ext=mp4]"
--merge-output-format mp4
-o "%(title)s.%(ext)s"
With the above in my config file, All i need to do is fire up “yt-dlp URL”
Other setups
Following, i explain how it is done manually, for me, to download files that work great with my cheap chinese android tv box (that keeps trying to hack my network) on VLC *(Using hardware decoder)….
But before we go there, youtube throttles the speed you download videos at ! so youtube-dl needs patching, an alternative would be yt-dlp (See here)
The easier way to install would be
apt install yt-dlp
Now, if you insist on pip, you can do the following
apt install python3-pip
python3 -m pip install --force-reinstall https://github.com/yt-dlp/yt-dlp/archive/master.tar.gz
Now, let us try downloading a video/audio
youtube-dl -F https://www.youtube.com/watch?v=mUvrLxaSolc
The line above will show you a bunch of options and their IDs, what you need to do now is to download the ones you need with a command such as
youtube-dl -f 270 https://www.youtube.com/watch?v=mUvrLxaSolc
Now, to combine them (Audio and video) without re-encoding…
ffmpeg -i ao.webm -i vo.webm -c:v copy -c:a copy output.webm
But remember when you download,
Only VP8 or VP9 or AV1 video and Vorbis or Opus audio and WebVTT subtitles are supported for WebM.
If you have installed via pip3
/usr/local/bin/yt-dlp ...