For a while I had expensive internet and low bandwidth, but I loved listening to music and lectures on YouTube. At some point I realized that getting only the audio stream would save me 90% in bandwidth costs. [0]
youtube-dl (and yt-dlp) has a flag, I believe -G, which gives you the URL(s) for the requested format/quality. I used the command line on my computer and put the link in VLC. On my phone I had this elaborate workaround involving downloading the file to my VPS first over SSH, then downloading it to my phone, until I realized my phone browser can consume the URL directly, so I set up a PHP frontend for `youtube-dl -G -f bestaudio {url}`
It's no longer online and I lost the code, but it was like one line of code.
I mention this because you-get seems to support the same usecase (via --url / -u), so I wanted to let people know how useful this is!
(While it was online I shared it on some forums and got very positive feedback, people used it for audiobooks etc.)
[0] Also playing with screen off saves 80% battery life! YouTube knows these facts and that's why they made background playback (which fetches only audio stream) a paid feature...
There are a lot of people that don't like Brave's business model. But I've never given Brave a dime and turn off their ad network stuff and they've saved me hundreds of dollars on Youtube Premium over the years.
For me, it was as easy as adding a shortcut to the YouTube homepage on Brave that it basically acts like the YouTube app, but with ad blocking built in. It's the only way I watch YT videos on mobile.
Seems like youtube-dl doesn't work anymore. I had to use a fork yt-dlp. Always makes me nervous hopping from one project to another like that, but seems like it's commonly used at least.
youtube-dl has been dead for many years now; it's a lot like XFree86, where the original project is a zombie with very few real users, but the original maintainers refuse to acknowledge reality and just shutter the thing, so newcomers get confused. Everyone's moved to yt-dlp now.
For providing a tool that lets people download YT videos? The same should apply to yt-dlp, but that project is hosted on github.com with no apparent problems. What's stopping the youtube-dl people from doing the same and just ignoring this silly court ruling?
> It's no longer online and I lost the code, but it was like one line of code.
My mom is really into audiobooks and I made telegram bot for her via node-red where she can share youtube links. The links are sent to a fifo where a little daemon (1) downdloads them sequential and saves them into an incoming folder I setup for this special purpose. The bot can either download only audio (for her telegram ID its only audio) or complete videos.
This folder is watched by jellyfin which she can access to download or listen. She loves it and in two years she downloaded way over a TB of audiobooks.
I often choose 144p for low bandwidth scenarios. It is very similar to a good quality audio-only stream in terms of size, but you get the added benefit of looking at the speaker even if that's a glance every 45 mins. Same for battery life, you save that too.
Also 144p is somehow so peaceful and relaxing to watch, you don't get distracted with all the shiny colors and intricate details in the video and can just listen and not have your mind focus on some random stuff.
You can glitch out Safari on IOS -by quickly pressing the play button for the video in the now playing interface after switching off from the Safari app- to play the audio of Youtube videos on the background.
I mainly use this to play membership only videos that don't play in the background even if you have a Youtube Premium.
Every IOS version I pray that they don't patch this "glitch".
BTW if you browse YouTube with Firefox browser on Android you can play back YouTube videos with the screen locked using background player fix extension.
YouTube deliberately tries to prevent background playback by using web APIs to detect when the page is no longer visible and pausing the video. The extension prevents YouTube from doing that.
That’s the -F option to list all the formats, including the audio streams. Pick the audio format with -f to download the audio. I usually pick the .m4a format and then run it through ffmpeg to convert to mp3.
If I would make any assumptions, I would post another 30 options from my config that are nice to have when you download audio from youtube. These 3 are exactly equivalent to what gp does.
What’s the point of converting it to mp3? AAC inside an m4a container usually has better sound quality than similarly compressed mp3, and definitely better than reencoding.
Many of the little generic MP3 player modules that cost next to nothing will play MP3 (obviously) and WAV, and sometimes OGG and WMA, but AAC support is relatively rare.
A good use case would be when you own a car built somewhere between 2005 and 2015 that accepts CDs and usb drives but only mp3 files. Some supported AAC and ogg files without them being advertised as compatible, but some might not.
Or when you keep using an old mp3 player from the early 2000's.
I think the point here is that you can run `yt-dlp --extract-audio --audio-format mp3` instead of saving as .m4a (a lossy compression) and then covering that to .mp3 (another very different lossy compression).
Under the hood, there's probably an additional lossy conversion. I'm not sure if YouTube converts uploaded videos to specific formats but if they do, then the worst case scenario is:
- original uploaded video uses .ogg audio
- YouTube converts that to opus and puts it into a container format (wbem?)
- You download the video and extract the audio to .m4a using yt-dlp
- and then you convert that to .mp3 using ffmpeg
That's 4 consecutive lossy formats, each one throwing away different data.
Honestly the best thing to do here is use yt-dlp to download whatever format YouTube provides and use ffprobe to find out what audio format is already there. Then do one conversation if required.
I usually just extract the raw Opus audio, then run it through Picard to tag and save it in my music directory. I don't see any point in converting to MP3 these days -- Opus provides better audio quality at the same bitrate (or, equivalently, lower file sizes for the same audio quality), and pretty much all player software supports it now. I've actually been going the other way and converting most of my music library to Opus and getting rid of MP3s.
Same but I converted to Opus, because I was trying to squeeze it into as little bandwidth as possible. It was mostly speech content and Opus auto detects and optimizes for speech at low nitrates.
You can download the Opus directly with -f 249 / 250 / 251 (~48kbps / ~80kbps / ~128 kbps respectively, but youtube don't always make them all available, where are -f 140 for the ~128kbps AAC (.m4a) is always available, and often the format code 139 (~48kbps) - the lower bitrates being adequate for most speech based content.
When I use NNCP [1] on flights to download Youtube videos, the script I wrote to nncp-exec the download accepts a quality friendly name. I have a specific friendly name which gets the lowest quality video and mid-tier audio. These settings usually result in a pretty enjoyable experience and offer plenty of entertainment even on a longer flight.
Just switching tabs will dramatically lower energy usage without using any scripts. I assume the YouTube video player may download and just drop the video information if not showing it, no need to render decrypt the video stream.
on Android YTDLnis solves this very nicely. simply share the video URL to the app and it can download whichever format you like https://github.com/deniscerri/ytdlnis
The advantage is that you're setting this for a utility which can play media directly (e.g., you don't have to separately download and then play content), and that you can set preferences independently for mpv vs. other tools.
You can also of course configure your own aliases, shell functions, shell scripts, or config files for various preferred configurations, whether using mpv, ytdl, or other tools.
It's worth noting, though, that ytdl can output video content to stdout, so it is possible to stream video by piping to any player, although mpv's method is much more convenient.
Sometimes it is necessary to download files regardless, though, due to DASH separating audio and video into distinct files. You often need to remux them with a container like MP4, AVI, or Matroska in order to use them locally.
mpv's bonus is convenience, and the fact that it will seamlessly play much of what you throw at it, whether that's local files, network resources, web sites, etc. Much of that majyck is in fact ytdl/yt-download, but having a standard interface is quite handy.
And yes, I've run into streams that need mixing, which ytdl/yt-download can handle; you point it at both the video and audio sources, typically. (I do this infrequently, thankfully).
youtube-dl (and yt-dlp) has a flag, I believe -G, which gives you the URL(s) for the requested format/quality. I used the command line on my computer and put the link in VLC. On my phone I had this elaborate workaround involving downloading the file to my VPS first over SSH, then downloading it to my phone, until I realized my phone browser can consume the URL directly, so I set up a PHP frontend for `youtube-dl -G -f bestaudio {url}`
It's no longer online and I lost the code, but it was like one line of code.
I mention this because you-get seems to support the same usecase (via --url / -u), so I wanted to let people know how useful this is!
(While it was online I shared it on some forums and got very positive feedback, people used it for audiobooks etc.)
[0] Also playing with screen off saves 80% battery life! YouTube knows these facts and that's why they made background playback (which fetches only audio stream) a paid feature...