
Building a YouTube MP3 Downloader with Exodus, FFmpeg, and AWS Lambda - yarapavan
https://intoli.com/blog/youtube-mp3-downloader/
======
dddddaviddddd
The bookmarklet is neat, but this seems over-worked compared to just

    
    
        youtube-dl --extract-audio --audio-format mp3 youtube.com/watch?v=00000000
    

[1] [https://rg3.github.io/youtube-dl/](https://rg3.github.io/youtube-dl/)

~~~
themodelplumber
youtube-dl is awesome. I built a bash script around this use case, with some
additional bits just for file management. I run "yety
[https://www.youtube.com/watch?v=thnXzUFJnfQ"](https://www.youtube.com/watch?v=thnXzUFJnfQ")
and poof, the mp3 is dropboxed and available on all my devices.

------
TAForObvReasons
The actual youtube metadata extraction is performed by the _awesome_ ytdl-core
library [https://www.npmjs.com/package/ytdl-
core](https://www.npmjs.com/package/ytdl-core) [https://github.com/fent/node-
ytdl-core](https://github.com/fent/node-ytdl-core)

For local work,
[https://www.npmjs.com/package/ytdl](https://www.npmjs.com/package/ytdl) is a
CLI powered by the same module. There is also a python-based youtube-dl
command [https://rg3.github.io/youtube-dl/](https://rg3.github.io/youtube-dl/)
that supports a ton of sites

~~~
qz3
Downloading YouTube files is ridiculously simple.

[http://m.youtube.com/watch?v=XxXxXx&layout=mobile&ajax=1](http://m.youtube.com/watch?v=XxXxXx&layout=mobile&ajax=1)

There you have all stream files in a nice json format, which means opus and
m4a for audio files.

I have a python project which is very quick to gather metadata, because I
wanted to have a responsive YouTube app without using the browser. Had no time
for it recently, though.

~~~
slow_donkey
Thanks this is actually really useful. Never knew about it

------
jwilk
Why MP3? You could download AAC files from YouTube and don't bother with
(necessarily lossy) conversion.

~~~
k__
Maybe file size is an issue here?

Wouldn't ogg be a viable alternative too?

~~~
Noctem
In their previous tutorial [1] their encoding settings show that they're
targeting roughly 128 kb/s VBR, which is what YouTube AACs typically are, so
that doesn't explain it. AAC (and Opus for that matter, which YouTube also
often has) are superior formats, and lossy encoding should only happen once if
possible- so this honestly makes me cringe a bit. In this case the (probably
already lossy) source audio is lossily converted by YouTube and then again by
ffmpeg/LAME with rather low bitrates at each step. A lot of quality is lost
along the way.

Support for Opus is unfortunately still somewhat sparse, but AAC support is
essentially universal on modern devicese. So I can't think of any reason to
favor this approach over:

    
    
      youtube-dl -f bestaudio[ext=m4a] "$URL"
    

Even YouTube's 128 kb/s copies won't satisfy audiophiles.

[1] [https://intoli.com/blog/transcoding-on-aws-
lambda/](https://intoli.com/blog/transcoding-on-aws-lambda/)

~~~
foob
I can definitely understand you cringing about the re-encoding, but I just
wanted to point out that the reason that we took this approach was simply to
give a semi-plausible real-world example of how tools like aws-serverless-
express [1] and Exodus [2] can be used to build useful APIs with AWS Lambda
[3] and AWS Gateway [4]. These articles are primarily meant to be educational
tutorials that people can use as a reference when writing and deploying their
own APIs. The whole "converting to MP3" thing is just an easily understandable
premise which lays out a clear goal for the tutorials to build upon.

[1] - [https://github.com/awslabs/aws-serverless-
express](https://github.com/awslabs/aws-serverless-express)

[2] - [https://github.com/intoli/exodus](https://github.com/intoli/exodus)

[3] - [https://aws.amazon.com/lambda/](https://aws.amazon.com/lambda/)

[4] - [https://aws.amazon.com/api-gateway/](https://aws.amazon.com/api-
gateway/)

------
ballenf
Are there any tools that can take my subscription activity in YT and convert
it into a podcast or RSS feed for me?

I’m just so tired of the algorithmic hooks to waste my time.

There are 5-6 channels I really enjoy but get tired of the effort needed to
fend off the constant temptation tailored to my tastes.

~~~
m-localhost
[https://podsync.net/](https://podsync.net/) \+ Pocket Cast = <3 - doesn't
work always unfortunately. For audio only I use
[https://huffduffer.com/](https://huffduffer.com/) (well it's just adding
single youtube videos to a customized podcast feed)

------
isostatic
Isn't using this sort of thing against YouTube tos?

~~~
jwilk
Yes:

4C. _You agree not to access Content through any technology or means other
than the video playback pages of the Service itself, the Embeddable Player, or
other explicitly authorized means YouTube may designate._

Source:
[https://www.youtube.com/static?gl=US&template=terms](https://www.youtube.com/static?gl=US&template=terms)

~~~
textmode
How to define "the video playback pages"?

Is
[https://www.youtube.com/watch?v=[videoID]](https://www.youtube.com/watch?v=\[videoID\])
a "video playback page"?

Most "YouTube downloaders", just like any popular web browser, access the
Content through these pages.

These pages contain the (escaped) URLs for the video in various formats.

Do the terms restrict the software, e.g. HTTP client, one can use to access to
these URLs?

For example, "You agree not to access Content through any software other than
Google Chrome, official Google mobile app, etc."

If a user prefers some other http client not approved by Google, is that a
violation of the ToS?

~~~
gsich
I think they try to say "browser" without actually saying it. Who knows why.

~~~
posterboy
The less specific, the more wiggle room for lawyers. You know perfectly well
that they don't offer download buttons. I'm actually surprised that ytdl still
works, so I guess it's not a serious problem actually and no need to obscure
further than they already do. I as an amateur could not figure out how to get
the files of yt or soundcloud. Reading scdl.py it looked simple enough but I'd
need to register a developer api key. For ytdl I guess the source has become
bloated and obscure by now so i wouldn't even try. Having a bunch of
dependencies already seemed too cluttered.

------
direction534
YouTube horribly compresses their audio. I don't know why you would want to
download mp3 from them. (music?)

~~~
zeta0134
I haven't had nearly that much trouble with more recent videos, which seem to
have excellent sound reproduction. It very much depends on the original upload
quality though. Some older videos (anything stuck on 240p or lower) are from a
time before HD uploads were a thing, and surely used more aggressive
compression.

Some uploaders are also simply unskilled; I'm mostly after video game
soundtracks to listen to in my car, and especially for newer soundtracks you
have to watch out for the uploaders trying to be "first" to gain the
popularity, while sometimes using poor settings or a bad rip. There's nothing
youtube can do to improve bad source audio.

~~~
londt8
they seem to use Opus with 160 kbit bitrate now, you can view the formats with
youtube-dl -F. Bandcamp disallows using compressed source audio, i wish
youtube would too.

