Hacker News new | past | comments | ask | show | jobs | submit login

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...




Brave Mobile browser allows turning on background video audio thus eliminating the need for YouTube Premium and similar subscriptions.



This works great, thank you.

For others: Settings > Media > Enable Background Audio


I don't know why your comment is downvoted because I use this feature of Brave very often and I also exclusively watch YT in Brave mobile (no ads).


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.


You might be interested in GrayJay app.


It's a really cool idea for an app. Pity that Google takes down the videos where Rossman talks about it.


New Pipe X if you need a full client does that as well.


I know of NewPipe (Android) but can't find anything about New Pipe X



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.


The author(s) got into legal trouble.

https://youtube-dl.org

> Due to a ruling of the Hamburg Regional Court, access to this website is blocked.

https://openjur.de/u/2466945.html


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?


The case is about downloading music or rather enabling others to do so ("Beihilfe"). GEMA really is quite terrible.

What's stopping them? Dunno, (the threat of) police showing up at the door? Shitty pop songs are not worth going to prison for.


Apparently this isn't stopping the yt-dlp people.


Maybe they aren't German


I am using the GUI version on windows https://oleksis.github.io/youtube-dl-gui/


Yeah, yt-dlp is the successor. I've been using it for years.


> 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.

1: https://gist.github.com/entropie/d265e94136b9777cc6b3190189b...


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.


Me too, i don't enjoy observing people's pimples on the nose


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".


Interesting, I don't use premium but is there a reason membership only videos don't support background audio? Seems like a weird exclusion


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.


That works fine without any extensions at all, so I'm unsure what does the extension even does?


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.


Or just switch FFA to desktop mode.


A service that takes arbitrary user input and then attempts to download/proxy whatever is at the end of that input. Brave soul.


One of my last weekend projects was something similar: convert youtube playlists into podcast-compstible URLs:

https://github.com/cquintana92/yt2pc


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.


That's really unnecessarily complicated workflow you have. It's achievable by yt-dlp with just 3 flags:

--extract-audio

--format bestaudio

--audio-format mp3


Direct to mp3 doesn't expose all the encoding options one may want.


you're unnecessarily making huge assumptions. Some people don't want the bestaudio or 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.


separate from above - willing to share your config anyways? I love me some yt-dlp configurations


> then run it through ffmpeg to convert to mp3.

> Some people don't want [...] mp3


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.


MP3 is accepted by far more players.


Do you have examples of this that aren't 20+ years old?


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.


Which players only accept mp3? Maybe this was true in the early 2000s


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.


But why not just download the mp3 then?


From where?


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.


NewPipe can do this very nicely, it even lets you build a playlist of videos.


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.

[1]: http://www.nncpgo.org/


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.


YouTube doesn’t encrypt the media stream other than TLS. Decoding the video can be skipped though.


I think it's -x to just rip audio now


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


mpv similarly has this option. I listen to far more videos than I watch.

<https://mpv.io/>


MPV is just passing the stream selection arguments over to youtube-dl/yt-dlp.


Sure, and you can set that directly in your mpv config:

  ytdl-format=bestaudio[ext=m4a]/bestaudio[ext=webm]/bestaudio
  vo=null
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.


Yup, it's pretty great.

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.


And yup back at'chya.

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).




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: